mirror of
https://github.com/oven-sh/bun
synced 2026-02-10 02:48:50 +00:00
* Add bun-types to packages * Improve typing * Fix types in tests * Fix dts tests * Run formatter * Fix all type errors * Add strict mode, fix type errors * Add ffi changes * Move workflows to root * Add workflows * Remove labeler * Add child_process types * Fix synthetic defaults issue * Remove docs * Move scripts * Run prettier * Include examples in typechecking * captureStackTrace types * moved captureStackTrace types to globals * Address reviews Co-authored-by: Colin McDonnell <colinmcd@alum.mit.edu> Co-authored-by: Dylan Conway <dylan.conway567@gmail.com>
84 lines
1.7 KiB
TypeScript
84 lines
1.7 KiB
TypeScript
// @ts-nocheck
|
|
var __BuildError;
|
|
var __ResolveError;
|
|
var __ImportKind;
|
|
{
|
|
enum ImportKind {
|
|
entry_point = 0,
|
|
stmt = 1,
|
|
require = 2,
|
|
dynamic = 3,
|
|
require_resolve = 4,
|
|
at = 5,
|
|
at_conditional = 6,
|
|
url = 7,
|
|
}
|
|
|
|
type ErrorPosition = {
|
|
file: string;
|
|
namespace: string;
|
|
line: number; // 1-based
|
|
column: number; // 0-based, byte offset relative to lineText
|
|
length: number; // in bytes
|
|
/** line of text, possibly empty */
|
|
lineText: string;
|
|
/** byte offset relative to the start of the file */
|
|
offset: number;
|
|
};
|
|
|
|
interface BuildErrorImplementation {
|
|
position: ErrorPosition;
|
|
name: string;
|
|
message: string;
|
|
}
|
|
|
|
interface ResolveErrorImplementation extends BuildErrorImplementation {
|
|
specifier: string;
|
|
importKind: ImportKind;
|
|
}
|
|
|
|
class BuildError extends Error {
|
|
constructor(data: BuildErrorImplementation) {
|
|
super(data.message);
|
|
this.name = data.name;
|
|
this.data = data;
|
|
}
|
|
data: BuildErrorImplementation;
|
|
|
|
get position() {
|
|
return this.data.position;
|
|
}
|
|
|
|
get [Symbol.toStringTag]() {
|
|
return `${this.name}: ${this.message}`;
|
|
}
|
|
}
|
|
|
|
class ResolveError extends BuildError {
|
|
constructor(data: ResolveErrorImplementation) {
|
|
super(data);
|
|
this.name = data.name;
|
|
this.data = data;
|
|
}
|
|
data: ResolveErrorImplementation;
|
|
|
|
get importKind() {
|
|
return this.data.importKind;
|
|
}
|
|
|
|
get specifier() {
|
|
return this.data.specifier || "";
|
|
}
|
|
}
|
|
|
|
__ResolveError = ResolveError;
|
|
__BuildError = BuildError;
|
|
__ImportKind = ImportKind;
|
|
}
|
|
|
|
export {
|
|
__ResolveError as ResolveError,
|
|
__BuildError as BuildError,
|
|
__ImportKind as ImportKind,
|
|
};
|