@scriptc/compiler 0.0.0 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/ambient/package.json +3 -0
- package/ambient/scriptc-node-fallback.d.ts +3001 -0
- package/ambient/scriptc-overrides.d.ts +95 -0
- package/ambient/scriptc.d.ts +74 -0
- package/dist/backend/cc.d.ts +169 -0
- package/dist/backend/cc.js +897 -0
- package/dist/backend/cc.js.map +1 -0
- package/dist/backend/emission/emit-async.d.ts +145 -0
- package/dist/backend/emission/emit-async.js +996 -0
- package/dist/backend/emission/emit-async.js.map +1 -0
- package/dist/backend/emission/emit-exprs.d.ts +3 -0
- package/dist/backend/emission/emit-exprs.js +5949 -0
- package/dist/backend/emission/emit-exprs.js.map +1 -0
- package/dist/backend/emission/emit-island.d.ts +45 -0
- package/dist/backend/emission/emit-island.js +271 -0
- package/dist/backend/emission/emit-island.js.map +1 -0
- package/dist/backend/emission/emit-shapes.d.ts +142 -0
- package/dist/backend/emission/emit-shapes.js +575 -0
- package/dist/backend/emission/emit-shapes.js.map +1 -0
- package/dist/backend/emission/emit-stmts.d.ts +78 -0
- package/dist/backend/emission/emit-stmts.js +960 -0
- package/dist/backend/emission/emit-stmts.js.map +1 -0
- package/dist/backend/emission/emit-types.d.ts +65 -0
- package/dist/backend/emission/emit-types.js +652 -0
- package/dist/backend/emission/emit-types.js.map +1 -0
- package/dist/backend/emission/emit-walkers.d.ts +154 -0
- package/dist/backend/emission/emit-walkers.js +1587 -0
- package/dist/backend/emission/emit-walkers.js.map +1 -0
- package/dist/backend/emission/emitter.d.ts +452 -0
- package/dist/backend/emission/emitter.js +1249 -0
- package/dist/backend/emission/emitter.js.map +1 -0
- package/dist/backend/emission/may-throw.d.ts +15 -0
- package/dist/backend/emission/may-throw.js +250 -0
- package/dist/backend/emission/may-throw.js.map +1 -0
- package/dist/backend/llvm/blocks.d.ts +21 -0
- package/dist/backend/llvm/blocks.js +68 -0
- package/dist/backend/llvm/blocks.js.map +1 -0
- package/dist/backend/llvm/classes.d.ts +84 -0
- package/dist/backend/llvm/classes.js +438 -0
- package/dist/backend/llvm/classes.js.map +1 -0
- package/dist/backend/llvm/dyn.d.ts +123 -0
- package/dist/backend/llvm/dyn.js +2624 -0
- package/dist/backend/llvm/dyn.js.map +1 -0
- package/dist/backend/llvm/emitter.d.ts +3 -0
- package/dist/backend/llvm/emitter.js +10102 -0
- package/dist/backend/llvm/emitter.js.map +1 -0
- package/dist/backend/llvm/shapes.d.ts +78 -0
- package/dist/backend/llvm/shapes.js +754 -0
- package/dist/backend/llvm/shapes.js.map +1 -0
- package/dist/backend/llvm/unsupported.d.ts +6 -0
- package/dist/backend/llvm/unsupported.js +12 -0
- package/dist/backend/llvm/unsupported.js.map +1 -0
- package/dist/backend/llvm/walkers.d.ts +58 -0
- package/dist/backend/llvm/walkers.js +793 -0
- package/dist/backend/llvm/walkers.js.map +1 -0
- package/dist/backend/mangle.d.ts +124 -0
- package/dist/backend/mangle.js +232 -0
- package/dist/backend/mangle.js.map +1 -0
- package/dist/coverage/report.d.ts +65 -0
- package/dist/coverage/report.js +238 -0
- package/dist/coverage/report.js.map +1 -0
- package/dist/diagnostics/diagnostic.d.ts +140 -0
- package/dist/diagnostics/diagnostic.js +458 -0
- package/dist/diagnostics/diagnostic.js.map +1 -0
- package/dist/diagnostics/render.d.ts +11 -0
- package/dist/diagnostics/render.js +58 -0
- package/dist/diagnostics/render.js.map +1 -0
- package/dist/frontend/cjs-lexer.d.ts +20 -0
- package/dist/frontend/cjs-lexer.js +813 -0
- package/dist/frontend/cjs-lexer.js.map +1 -0
- package/dist/frontend/lowering/http2-constants.d.ts +1 -0
- package/dist/frontend/lowering/http2-constants.js +251 -0
- package/dist/frontend/lowering/http2-constants.js.map +1 -0
- package/dist/frontend/lowering/lib-boundary.d.ts +6 -0
- package/dist/frontend/lowering/lib-boundary.js +143 -0
- package/dist/frontend/lowering/lib-boundary.js.map +1 -0
- package/dist/frontend/lowering/lower-assert.d.ts +18 -0
- package/dist/frontend/lowering/lower-assert.js +1269 -0
- package/dist/frontend/lowering/lower-assert.js.map +1 -0
- package/dist/frontend/lowering/lower-builtins.d.ts +511 -0
- package/dist/frontend/lowering/lower-builtins.js +5249 -0
- package/dist/frontend/lowering/lower-builtins.js.map +1 -0
- package/dist/frontend/lowering/lower-calls.d.ts +581 -0
- package/dist/frontend/lowering/lower-calls.js +6286 -0
- package/dist/frontend/lowering/lower-calls.js.map +1 -0
- package/dist/frontend/lowering/lower-classes.d.ts +727 -0
- package/dist/frontend/lowering/lower-classes.js +4701 -0
- package/dist/frontend/lowering/lower-classes.js.map +1 -0
- package/dist/frontend/lowering/lower-comptime.d.ts +53 -0
- package/dist/frontend/lowering/lower-comptime.js +244 -0
- package/dist/frontend/lowering/lower-comptime.js.map +1 -0
- package/dist/frontend/lowering/lower-containers.d.ts +486 -0
- package/dist/frontend/lowering/lower-containers.js +6345 -0
- package/dist/frontend/lowering/lower-containers.js.map +1 -0
- package/dist/frontend/lowering/lower-dgram.d.ts +20 -0
- package/dist/frontend/lowering/lower-dgram.js +319 -0
- package/dist/frontend/lowering/lower-dgram.js.map +1 -0
- package/dist/frontend/lowering/lower-emitter.d.ts +10 -0
- package/dist/frontend/lowering/lower-emitter.js +688 -0
- package/dist/frontend/lowering/lower-emitter.js.map +1 -0
- package/dist/frontend/lowering/lower-enums.d.ts +22 -0
- package/dist/frontend/lowering/lower-enums.js +235 -0
- package/dist/frontend/lowering/lower-enums.js.map +1 -0
- package/dist/frontend/lowering/lower-expando.d.ts +35 -0
- package/dist/frontend/lowering/lower-expando.js +276 -0
- package/dist/frontend/lowering/lower-expando.js.map +1 -0
- package/dist/frontend/lowering/lower-exprs.d.ts +524 -0
- package/dist/frontend/lowering/lower-exprs.js +8111 -0
- package/dist/frontend/lowering/lower-exprs.js.map +1 -0
- package/dist/frontend/lowering/lower-generators.d.ts +50 -0
- package/dist/frontend/lowering/lower-generators.js +421 -0
- package/dist/frontend/lowering/lower-generators.js.map +1 -0
- package/dist/frontend/lowering/lower-inspect.d.ts +20 -0
- package/dist/frontend/lowering/lower-inspect.js +1074 -0
- package/dist/frontend/lowering/lower-inspect.js.map +1 -0
- package/dist/frontend/lowering/lower-island.d.ts +108 -0
- package/dist/frontend/lowering/lower-island.js +650 -0
- package/dist/frontend/lowering/lower-island.js.map +1 -0
- package/dist/frontend/lowering/lower-mixins.d.ts +96 -0
- package/dist/frontend/lowering/lower-mixins.js +534 -0
- package/dist/frontend/lowering/lower-mixins.js.map +1 -0
- package/dist/frontend/lowering/lower-modules.d.ts +135 -0
- package/dist/frontend/lowering/lower-modules.js +1613 -0
- package/dist/frontend/lowering/lower-modules.js.map +1 -0
- package/dist/frontend/lowering/lower-namespaces.d.ts +168 -0
- package/dist/frontend/lowering/lower-namespaces.js +706 -0
- package/dist/frontend/lowering/lower-namespaces.js.map +1 -0
- package/dist/frontend/lowering/lower-server.d.ts +90 -0
- package/dist/frontend/lowering/lower-server.js +3471 -0
- package/dist/frontend/lowering/lower-server.js.map +1 -0
- package/dist/frontend/lowering/lower-stmts.d.ts +361 -0
- package/dist/frontend/lowering/lower-stmts.js +5341 -0
- package/dist/frontend/lowering/lower-stmts.js.map +1 -0
- package/dist/frontend/lowering/lower-stream.d.ts +88 -0
- package/dist/frontend/lowering/lower-stream.js +1533 -0
- package/dist/frontend/lowering/lower-stream.js.map +1 -0
- package/dist/frontend/lowering/lower-test.d.ts +27 -0
- package/dist/frontend/lowering/lower-test.js +353 -0
- package/dist/frontend/lowering/lower-test.js.map +1 -0
- package/dist/frontend/lowering/lowerer.d.ts +1748 -0
- package/dist/frontend/lowering/lowerer.js +6257 -0
- package/dist/frontend/lowering/lowerer.js.map +1 -0
- package/dist/frontend/lowering/surfaces.d.ts +272 -0
- package/dist/frontend/lowering/surfaces.js +1096 -0
- package/dist/frontend/lowering/surfaces.js.map +1 -0
- package/dist/frontend/npm-static.d.ts +55 -0
- package/dist/frontend/npm-static.js +300 -0
- package/dist/frontend/npm-static.js.map +1 -0
- package/dist/frontend/npm.d.ts +330 -0
- package/dist/frontend/npm.js +1259 -0
- package/dist/frontend/npm.js.map +1 -0
- package/dist/frontend/program.d.ts +186 -0
- package/dist/frontend/program.js +2255 -0
- package/dist/frontend/program.js.map +1 -0
- package/dist/frontend/provenance-registry.d.ts +48 -0
- package/dist/frontend/provenance-registry.js +87 -0
- package/dist/frontend/provenance-registry.js.map +1 -0
- package/dist/frontend/provenance.d.ts +6 -0
- package/dist/frontend/provenance.js +459 -0
- package/dist/frontend/provenance.js.map +1 -0
- package/dist/frontend/resolve.d.ts +56 -0
- package/dist/frontend/resolve.js +682 -0
- package/dist/frontend/resolve.js.map +1 -0
- package/dist/frontend/shared.d.ts +67 -0
- package/dist/frontend/shared.js +241 -0
- package/dist/frontend/shared.js.map +1 -0
- package/dist/frontend/ts7/adapter.d.ts +7 -0
- package/dist/frontend/ts7/adapter.js +54 -0
- package/dist/frontend/ts7/adapter.js.map +1 -0
- package/dist/frontend/ts7/ast.d.ts +50 -0
- package/dist/frontend/ts7/ast.js +211 -0
- package/dist/frontend/ts7/ast.js.map +1 -0
- package/dist/frontend/ts7/census-check.d.ts +1 -0
- package/dist/frontend/ts7/census-check.js +12 -0
- package/dist/frontend/ts7/census-check.js.map +1 -0
- package/dist/frontend/ts7/checker.d.ts +140 -0
- package/dist/frontend/ts7/checker.js +544 -0
- package/dist/frontend/ts7/checker.js.map +1 -0
- package/dist/frontend/ts7/enums.d.ts +18 -0
- package/dist/frontend/ts7/enums.js +43 -0
- package/dist/frontend/ts7/enums.js.map +1 -0
- package/dist/frontend/ts7/program.d.ts +99 -0
- package/dist/frontend/ts7/program.js +278 -0
- package/dist/frontend/ts7/program.js.map +1 -0
- package/dist/frontend/ts7/world-check.d.ts +3 -0
- package/dist/frontend/ts7/world-check.js +34 -0
- package/dist/frontend/ts7/world-check.js.map +1 -0
- package/dist/frontend/types.d.ts +205 -0
- package/dist/frontend/types.js +2485 -0
- package/dist/frontend/types.js.map +1 -0
- package/dist/index.d.ts +85 -0
- package/dist/index.js +429 -0
- package/dist/index.js.map +1 -0
- package/dist/ir/nodes.d.ts +4334 -0
- package/dist/ir/nodes.js +1906 -0
- package/dist/ir/nodes.js.map +1 -0
- package/dist/ir/serialize.d.ts +4 -0
- package/dist/ir/serialize.js +34 -0
- package/dist/ir/serialize.js.map +1 -0
- package/dist/ir/validate.d.ts +36 -0
- package/dist/ir/validate.js +4885 -0
- package/dist/ir/validate.js.map +1 -0
- package/package.json +30 -6
- package/README.md +0 -3
- package/index.js +0 -2
|
@@ -0,0 +1,458 @@
|
|
|
1
|
+
export const UNSUPPORTED = {
|
|
2
|
+
SC1010: {
|
|
3
|
+
feature: "package imports",
|
|
4
|
+
milestone: "M4",
|
|
5
|
+
hint: "relative imports (./file, ../dir/file), package.json-mediated project " +
|
|
6
|
+
"imports (#alias via the imports field, self-name references via " +
|
|
7
|
+
"exports), installed npm packages (their code runs under --dynamic), " +
|
|
8
|
+
"and the built-in fs, fs/promises, path, os, url, crypto, zlib, " +
|
|
9
|
+
"child_process, net, http, tls, https, http2, dgram, dns, util, " +
|
|
10
|
+
"util/types, string_decoder, readline, events, stream, buffer, " +
|
|
11
|
+
"assert, assert/strict, worker_threads, cluster, tty, async_hooks, " +
|
|
12
|
+
"timers, timers/promises, diagnostics_channel, and node:test modules " +
|
|
13
|
+
"(bare or node:-prefixed) are supported",
|
|
14
|
+
},
|
|
15
|
+
// SC1011 (exports) shipped via export modifiers — retired, do not reuse.
|
|
16
|
+
// Default exports/imports SHIPPED (expression, function/class declaration
|
|
17
|
+
// — named and anonymous — `export { x as default }`, default re-exports,
|
|
18
|
+
// and the CJS default interop). SC1012's remaining uses are the residual
|
|
19
|
+
// edges, each named at its site: default imports of builtin modules
|
|
20
|
+
// without a default surface, default-exporting a MUTABLE binding (Node
|
|
21
|
+
// snapshots; not modeled), named imports from JSON modules, and the
|
|
22
|
+
// require()-of-JSON forms.
|
|
23
|
+
SC1012: {
|
|
24
|
+
feature: "default exports/imports",
|
|
25
|
+
milestone: "later",
|
|
26
|
+
hint: "use named exports: export function f() {} / import { f } from \"./m\"",
|
|
27
|
+
},
|
|
28
|
+
// Namespace imports of USER modules shipped (`import * as ns from
|
|
29
|
+
// "./m"` and `export * as ns from "./m"`: ns.member resolves statically
|
|
30
|
+
// to the exporter's own registrations). SC1013's remaining uses name
|
|
31
|
+
// their edges: the ns OBJECT as a first-class value, namespace imports
|
|
32
|
+
// of JSON/CommonJS modules, runtime import = require(...) forms, and
|
|
33
|
+
// require() in an ES module.
|
|
34
|
+
SC1013: { feature: "namespace imports (* as ns)", milestone: "later" },
|
|
35
|
+
SC1014: {
|
|
36
|
+
feature: "re-exports and export lists",
|
|
37
|
+
milestone: "later",
|
|
38
|
+
hint: "export declarations directly: export function f() {}",
|
|
39
|
+
},
|
|
40
|
+
SC1015: { feature: "dynamic import()", milestone: "M4" },
|
|
41
|
+
SC1016: { feature: "circular imports", milestone: "later" },
|
|
42
|
+
// Class DECLARATIONS shipped; SC1020's remaining use is class expressions.
|
|
43
|
+
SC1020: { feature: "class expressions", milestone: "later" },
|
|
44
|
+
// SC1021 (arrow functions/closures) and SC1022 (nested function
|
|
45
|
+
// declarations) shipped — codes retired, do not reuse.
|
|
46
|
+
// SC1023 (object literals) shipped as records — code retired, do not
|
|
47
|
+
// reuse. (Spread, computed keys, getters/setters and `this` in
|
|
48
|
+
// object-literal methods remain rejected via SC1090.)
|
|
49
|
+
// SC1024 (arrays) shipped — code retired, do not reuse.
|
|
50
|
+
// `var` declarations shipped (function-scope hoisting, redeclaration
|
|
51
|
+
// merge, the shared-binding loop capture semantics). SC1030's remaining
|
|
52
|
+
// uses are the var edges with no honest lowering — each names its shape
|
|
53
|
+
// and remedy inline (a reference above the declaration whose early reads
|
|
54
|
+
// would be an unrepresentable `undefined`; `var` loop bindings in
|
|
55
|
+
// `for await`).
|
|
56
|
+
SC1030: {
|
|
57
|
+
feature: "var declarations",
|
|
58
|
+
milestone: "later",
|
|
59
|
+
},
|
|
60
|
+
SC1031: { feature: "destructuring", milestone: "M2" },
|
|
61
|
+
// SC1032 (multiple declarations in one statement) shipped — code retired,
|
|
62
|
+
// do not reuse. (Multi-declaration for-loop initializers remain rejected
|
|
63
|
+
// via SC1090.)
|
|
64
|
+
// SC1033 (let without an initializer) shipped — code retired, do not
|
|
65
|
+
// reuse.
|
|
66
|
+
SC1040: {
|
|
67
|
+
feature: "loose equality (== and !=)",
|
|
68
|
+
milestone: "M4",
|
|
69
|
+
hint: "use === / !== ('x == null' / 'x != null' — the null-or-undefined test — is supported; other loose comparisons need dynamic coercion semantics)",
|
|
70
|
+
},
|
|
71
|
+
// SC1041 (bitwise operators, ToInt32 semantics) shipped — code retired,
|
|
72
|
+
// do not reuse.
|
|
73
|
+
SC1042: {
|
|
74
|
+
feature: "logical operators on mixed operand types",
|
|
75
|
+
milestone: "later",
|
|
76
|
+
hint: "give both operands the same type (number, string, or boolean)",
|
|
77
|
+
},
|
|
78
|
+
SC1043: { feature: "comparing non-number, non-string values", milestone: "M1" },
|
|
79
|
+
SC1045: {
|
|
80
|
+
feature: "increment/decrement in expression position",
|
|
81
|
+
milestone: "later",
|
|
82
|
+
hint: "use ++/-- as a standalone statement, or write x = x + 1",
|
|
83
|
+
},
|
|
84
|
+
SC1050: { feature: "labeled break/continue", milestone: "later" },
|
|
85
|
+
// SC1051 (do-while loops) shipped — code retired, do not reuse.
|
|
86
|
+
SC1052: { feature: "for-in loops", milestone: "M4" }, // for-of over arrays shipped in M1
|
|
87
|
+
// SC1060 (switch statements) shipped — code retired, do not reuse.
|
|
88
|
+
// SC1061 (exceptions: throw/try/catch/finally) shipped — code retired, do
|
|
89
|
+
// not reuse. (Identifier catch bindings shipped too; what remains rejected
|
|
90
|
+
// is destructuring patterns — SC1062 — un-narrowed binding uses —
|
|
91
|
+
// SC1063 — and jumps crossing a finally — SC1090.)
|
|
92
|
+
SC1062: {
|
|
93
|
+
feature: "destructuring catch clause bindings",
|
|
94
|
+
milestone: "later",
|
|
95
|
+
hint: "bind an identifier (catch (e)) and narrow it — 'e instanceof Error' exposes .name/.message, typeof tests expose primitives",
|
|
96
|
+
},
|
|
97
|
+
SC1063: {
|
|
98
|
+
feature: "this use of a catch binding",
|
|
99
|
+
milestone: "later",
|
|
100
|
+
hint: "a catch binding is typed by what was thrown — narrow before reading: 'if (e instanceof Error)' (then .name/.message), 'typeof e === \"string\"/\"number\"/\"boolean\"', or rethrow with 'throw e'; String(e) and `${e}` also compile ('Error: msg' for Error payloads — Node's String(), which has no stack), so 'e instanceof Error ? e.message : String(e)' works as-is",
|
|
101
|
+
},
|
|
102
|
+
SC1070: { feature: "async/await", milestone: "M3" },
|
|
103
|
+
SC1071: { feature: "generators", milestone: "later" },
|
|
104
|
+
// `this` in class methods (+ lexical capture by arrows) shipped; what
|
|
105
|
+
// remains is `this` outside any method (top level, plain functions).
|
|
106
|
+
SC1080: { feature: "'this' outside a class method", milestone: "later" },
|
|
107
|
+
SC1090: { feature: "this syntax", milestone: "later" }, // generic fallback; message names the construct
|
|
108
|
+
SC1100: {
|
|
109
|
+
feature: "operations on 'unknown' values",
|
|
110
|
+
milestone: "later",
|
|
111
|
+
hint: "validate with 'as <type>' first — the cast checks the dynamic value at runtime and throws on mismatch",
|
|
112
|
+
},
|
|
113
|
+
SC1101: {
|
|
114
|
+
feature: "converting typed values to 'unknown'",
|
|
115
|
+
milestone: "later",
|
|
116
|
+
hint: "numbers, strings, booleans, JSON-safe records/arrays/unions (a deep copy — the 'unknown' value never aliases the original), and functions over those (boxed, identity preserved) convert into 'unknown' slots; this value's type has no dynamic representation yet",
|
|
117
|
+
},
|
|
118
|
+
// Regex fences. SC1120 is the shared code for regex features outside the
|
|
119
|
+
// supported slice (the rejection site names the construct); SC1121 is
|
|
120
|
+
// the statefulness fence, with its own hint.
|
|
121
|
+
SC1120: {
|
|
122
|
+
feature: "this regex feature",
|
|
123
|
+
milestone: "later",
|
|
124
|
+
hint: "supported: literal regexes with the g/i/m/s/u/y flags — .test(), .source/.flags, and string replace/replaceAll/split with string replacement templates",
|
|
125
|
+
},
|
|
126
|
+
SC1121: {
|
|
127
|
+
feature: "'.test()' on a regex with the 'g' or 'y' flag",
|
|
128
|
+
milestone: "later",
|
|
129
|
+
hint: "g/y regexes carry mutable lastIndex state between calls, which is not modeled; drop the flag for a plain match test, or use replace/replaceAll/split (their iteration is internal)",
|
|
130
|
+
},
|
|
131
|
+
};
|
|
132
|
+
export function unsupportedDiag(code, loc, featureOverride, hintOverride) {
|
|
133
|
+
const entry = UNSUPPORTED[code];
|
|
134
|
+
const feature = featureOverride ?? entry.feature;
|
|
135
|
+
const diag = {
|
|
136
|
+
code,
|
|
137
|
+
message: `${feature} ${plural(feature) ? "are" : "is"} not supported yet`,
|
|
138
|
+
loc,
|
|
139
|
+
milestone: entry.milestone,
|
|
140
|
+
};
|
|
141
|
+
const hint = hintOverride ?? entry.hint;
|
|
142
|
+
if (hint !== undefined)
|
|
143
|
+
diag.hint = hint;
|
|
144
|
+
return diag;
|
|
145
|
+
}
|
|
146
|
+
function plural(feature) {
|
|
147
|
+
const head = feature.split(" (")[0].trim();
|
|
148
|
+
return /s$/.test(head) && !/(?:ness|this|ss)$/.test(head);
|
|
149
|
+
}
|
|
150
|
+
export function tscPassthroughDiag(message, loc) {
|
|
151
|
+
return { code: "SC0001", message, loc };
|
|
152
|
+
}
|
|
153
|
+
/** The project's tsconfig disables strictNullChecks, which scriptc cannot
|
|
154
|
+
* adopt: null and undefined are DISTINCT STATIC TYPES in the value model
|
|
155
|
+
* (union arms with their own runtime representation) — with the knob off,
|
|
156
|
+
* every type silently includes them and nothing about the model holds. The
|
|
157
|
+
* config gate fails loudly instead of silently re-enabling the knob. */
|
|
158
|
+
/** True for the sync channel's surfaced Go panics: typescript-go wraps a
|
|
159
|
+
* server-side panic into a thrown Error whose message starts "panic:" and
|
|
160
|
+
* keeps the server intact (the prefetch fence's original finding). The
|
|
161
|
+
* 2026-07-19 sweep's three upstream panics — the TupleType interface
|
|
162
|
+
* conversion, the import.defer Debug failure, the 1e999 JSON marshal — all
|
|
163
|
+
* arrive in this shape. */
|
|
164
|
+
export function isCheckerPanic(e) {
|
|
165
|
+
return e instanceof Error && e.message.startsWith("panic:");
|
|
166
|
+
}
|
|
167
|
+
/** A Go panic inside the typescript-go checker reached through a query
|
|
168
|
+
* about this source position. Upstream bugs from scriptc's point of view —
|
|
169
|
+
* but scriptc still owes a source-anchored diagnostic, never a crashed
|
|
170
|
+
* CLI. */
|
|
171
|
+
export function checkerPanicDiag(detail, loc) {
|
|
172
|
+
// Go's encoding/json/v2 Hyrum-proofs its error strings: each process
|
|
173
|
+
// coin-flips between "cannot" and "unable to" as the modal verb
|
|
174
|
+
// (errorModalVerb over randomized map iteration), so the same panic
|
|
175
|
+
// renders two ways across tsgo spawns. scriptc's output is deterministic;
|
|
176
|
+
// pin one spelling before relaying.
|
|
177
|
+
const stable = detail.replace(/\bunable to (marshal|unmarshal|handle)\b/g, "cannot $1");
|
|
178
|
+
return {
|
|
179
|
+
code: "SC0004",
|
|
180
|
+
message: `the TypeScript checker crashed answering a query here (an upstream typescript-go bug): ${stable}`,
|
|
181
|
+
loc,
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
/** An imported .json module whose text strict JSON.parse rejects (a leading
|
|
185
|
+
* `//` comment line — the importAttributes11 shape). tsgo tolerates it, so
|
|
186
|
+
* the SC0001 passthrough never fires; Node itself refuses to import such a
|
|
187
|
+
* module at runtime, and the honest answer is a source-anchored gate at the
|
|
188
|
+
* import, never an uncaught parse throw. */
|
|
189
|
+
export function invalidJsonModuleDiag(fileName, detail, loc) {
|
|
190
|
+
return {
|
|
191
|
+
code: "SC0003",
|
|
192
|
+
message: `imported JSON module '${fileName}' is not valid JSON (${detail})`,
|
|
193
|
+
loc,
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
export function strictNullChecksFloorDiag(configFile) {
|
|
197
|
+
return {
|
|
198
|
+
code: "SC0002",
|
|
199
|
+
message: "this project's tsconfig disables strictNullChecks, which scriptc requires " +
|
|
200
|
+
"(null and undefined are modeled as distinct static types; without the knob " +
|
|
201
|
+
"every type silently includes them)",
|
|
202
|
+
loc: { file: configFile, start: 0, end: 0 },
|
|
203
|
+
hint: 'set "strictNullChecks": true (or "strict": true) in the project tsconfig',
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
export function unsupportedTypeDiag(typeText, loc) {
|
|
207
|
+
// `any` gets its own wording AND its own code: it is not an unsupported
|
|
208
|
+
// value type but a construct with a DYNAMIC lowering — under --dynamic,
|
|
209
|
+
// any-typed code runs in the embedded engine. This build didn't opt in,
|
|
210
|
+
// so each site reports the choice: pay ~620KB, or stay static with
|
|
211
|
+
// 'unknown' + a checked cast. The distinct code lets the coverage report
|
|
212
|
+
// separate "runs with --dynamic" from "cannot compile". One voice with
|
|
213
|
+
// SC2010/SC2012: same message shape, same cost figure, same
|
|
214
|
+
// stay-static alternative shape.
|
|
215
|
+
if (typeText === "any") {
|
|
216
|
+
return {
|
|
217
|
+
code: "SC2011",
|
|
218
|
+
message: `values of type 'any' run in the embedded dynamic engine, which this build does not include`,
|
|
219
|
+
loc,
|
|
220
|
+
milestone: "M4",
|
|
221
|
+
hint: "build with --dynamic to run 'any'-typed code in the embedded engine (adds ~620KB to the binary), or stay static with 'unknown' and a checked cast ('x as T')",
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
return {
|
|
225
|
+
code: "SC2001",
|
|
226
|
+
message: `values of type '${typeText}' cannot be compiled yet ` +
|
|
227
|
+
`(supported: number, string, boolean, arrays, Maps, Sets, RegExp, functions, classes, records, unions of those, and 'unknown')`,
|
|
228
|
+
loc,
|
|
229
|
+
milestone: "M2",
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
/** A type with a DYNAMIC representation but no static one — `any[]`,
|
|
233
|
+
* records/functions with `any`-typed members, or a shipped-.d.ts type whose
|
|
234
|
+
* values are island handles. The caller PROVED the claim by re-running
|
|
235
|
+
* mapType with `dynamic: true` before choosing this wording, so the message
|
|
236
|
+
* is a measured fact, not a guess. SC2011 like the bare-`any` arm of
|
|
237
|
+
* unsupportedTypeDiag (one dynamic-family code per story: this is the
|
|
238
|
+
* "values of this TYPE run in the engine" story), and "runs in" voice like
|
|
239
|
+
* SC2012 — the value exists under --dynamic; the build just didn't opt in. */
|
|
240
|
+
export function requiresDynamicTypeDiag(typeText, loc) {
|
|
241
|
+
return {
|
|
242
|
+
code: "SC2011",
|
|
243
|
+
message: `values of type '${typeText}' have no static representation but run in the embedded dynamic engine, which this build does not include`,
|
|
244
|
+
loc,
|
|
245
|
+
milestone: "M4",
|
|
246
|
+
hint: "build with --dynamic to run these values in the embedded engine (adds ~620KB to the binary), or restate the type inside the static surface (https://scriptc.dev/limitations describes the boundary)",
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
/** A value whose type keeps a GENERIC call signature (`let g: <T>(x: T) =>
|
|
250
|
+
* T`, a stored generic function, a call result the checker left
|
|
251
|
+
* higher-order generic): every compiled function is one concrete
|
|
252
|
+
* signature, so a slot that keeps type parameters has no instance to hold
|
|
253
|
+
* — the generic-value monomorphization rule, named instead of the generic
|
|
254
|
+
* supported-types recitation. */
|
|
255
|
+
export function genericSignatureTypeDiag(typeText, loc) {
|
|
256
|
+
return {
|
|
257
|
+
code: "SC2001",
|
|
258
|
+
message: `values of type '${typeText}' cannot be compiled: the signature keeps its type parameters, and a compiled function is always one concrete signature (generic functions monomorphize per pinned signature — declarations, methods, and never-reassigned module-scope bindings initialized with a generic arrow/function expression)`,
|
|
259
|
+
loc,
|
|
260
|
+
milestone: "M2",
|
|
261
|
+
hint: "annotate the destination with a concrete signature (e.g. '(x: number) => number'), instantiate explicitly ('f<number>'), or call the generic function directly",
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
/** An index-signature object type that STILL does not map: STRING and
|
|
265
|
+
* NUMBER index signatures compile (declared fields + an overflow map for
|
|
266
|
+
* undeclared keys, number keys canonicalized to their JS string spelling),
|
|
267
|
+
* so reaching this means a symbol-keyed signature, dual signatures with
|
|
268
|
+
* UNEQUAL value types, a value type outside the supported set (functions,
|
|
269
|
+
* Maps, promises, ...), or a declared `unknown` field under the signature.
|
|
270
|
+
* The message points at the working alternatives. */
|
|
271
|
+
export function indexSignatureTypeDiag(typeText, loc) {
|
|
272
|
+
return {
|
|
273
|
+
code: "SC2001",
|
|
274
|
+
message: `values of type '${typeText}' cannot be compiled: this index signature is outside the supported shape (string or number keys; values limited to numbers, strings, booleans, records, classes, arrays, unions, or 'unknown')`,
|
|
275
|
+
loc,
|
|
276
|
+
milestone: "M2",
|
|
277
|
+
hint: "string- and number-keyed index signatures over the supported value types compile directly; richer value types want Map<string, V>, and symbol keys have no lowering",
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
/** A REACHED use of standard-library surface with no lowering — the scope
|
|
281
|
+
* fence of the real-lib type world. The checker sees the full es2025
|
|
282
|
+
* standard library, so `Symbol`, `new Date()`, `p.then(...)`, `Math.min`
|
|
283
|
+
* with three arguments all TYPECHECK; each use site of surface (or a call
|
|
284
|
+
* form of it) that nothing lowers reports here instead of the old minimal-
|
|
285
|
+
* ambient "Cannot find name" — and never ICEs. `surface` names what was
|
|
286
|
+
* used ('Symbol', 'Math.sumPrecise', 'new Date', 'string.normalize'). */
|
|
287
|
+
export function noLoweringDiag(surface, loc, hint, viaNodeTypes = false) {
|
|
288
|
+
// Same code, two provenances: with the project's @types/node adopted,
|
|
289
|
+
// the checker also sees everything IT declares (Buffer, process.stdout,
|
|
290
|
+
// fetch, the undici web globals, ...) — a reached use of node-typed
|
|
291
|
+
// surface nothing lowers is the same fence, blamed at @types/node so the
|
|
292
|
+
// report reads honestly ("typed by @types/node" — not "standard
|
|
293
|
+
// library").
|
|
294
|
+
return {
|
|
295
|
+
code: "SC2020",
|
|
296
|
+
message: viaNodeTypes
|
|
297
|
+
? `'${surface}' is typed by @types/node but has no scriptc lowering yet`
|
|
298
|
+
: `'${surface}' is part of the standard library types but has no scriptc lowering yet`,
|
|
299
|
+
loc,
|
|
300
|
+
milestone: "later",
|
|
301
|
+
hint: hint ??
|
|
302
|
+
(viaNodeTypes
|
|
303
|
+
? "the type checker sees everything @types/node declares, but only the supported surface compiles (https://scriptc.dev/limitations)"
|
|
304
|
+
: "the type checker sees the full standard library, but only the supported surface compiles (https://scriptc.dev/limitations)"),
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
/** Records are monomorphic structs, so a value's shape must match the
|
|
308
|
+
* expected shape EXACTLY — TypeScript's structural width subtyping
|
|
309
|
+
* (`{a: 1, b: 2}` where `{a: number}` is expected) would need a runtime
|
|
310
|
+
* shape coercion that doesn't exist yet. */
|
|
311
|
+
export function recordShapeMismatchDiag(expectedText, actualText, loc) {
|
|
312
|
+
return {
|
|
313
|
+
code: "SC2002",
|
|
314
|
+
message: `record shapes must match exactly: expected '${expectedText}', got '${actualText}' ` +
|
|
315
|
+
`(structural width subtyping needs a shape coercion that is not supported yet)`,
|
|
316
|
+
loc,
|
|
317
|
+
milestone: "later",
|
|
318
|
+
hint: "build a new literal with exactly the expected fields instead of passing a wider value",
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
/** Union values carry a runtime tag assigned per-union: a value of one
|
|
322
|
+
* union type flowing into a DIFFERENT union's slot re-tags at runtime when
|
|
323
|
+
* every source arm has a home in the destination (`A | B` into `A | B | C`
|
|
324
|
+
* — see unionRetagHelper). What this rejects is the remainder: a source arm
|
|
325
|
+
* with no identical destination arm, where the value could not be
|
|
326
|
+
* represented in the target union at all. */
|
|
327
|
+
export function unionMismatchDiag(expectedText, actualText, loc) {
|
|
328
|
+
return {
|
|
329
|
+
code: "SC2003",
|
|
330
|
+
message: `union types must match exactly: expected '${expectedText}', got '${actualText}' ` +
|
|
331
|
+
`(a union re-tags into another union only when every arm of the source has an identical arm in the destination, or is a record/array that width-coerces into exactly one destination arm)`,
|
|
332
|
+
loc,
|
|
333
|
+
milestone: "later",
|
|
334
|
+
hint: "narrow the value to a SINGLE arm first (a discriminant check, or '!== undefined'/'!== null' for unit arms); a plain arm value widens into any union that contains it, and a whole union widens into any union whose arms include the source's",
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
/** A use of a binding whose DECLARATION did not compile: the declaration
|
|
338
|
+
* site already carries the real diagnostic (a fenced type, a blocked
|
|
339
|
+
* signature, an unsupported binding form), and every later reference falls
|
|
340
|
+
* through the resolution steps because no local/global/function was ever
|
|
341
|
+
* registered under the symbol. This cascade marker names the binding and
|
|
342
|
+
* points back at the root cause instead of misreporting the reference as
|
|
343
|
+
* an unsupported construct of its own. */
|
|
344
|
+
export function blockedBindingUseDiag(name, loc) {
|
|
345
|
+
return {
|
|
346
|
+
code: "SC2004",
|
|
347
|
+
message: `uses of '${name}' inherit the blocker on its declaration`,
|
|
348
|
+
loc,
|
|
349
|
+
milestone: "later",
|
|
350
|
+
hint: `the declaration of '${name}' did not compile — fix the diagnostic reported there and these sites clear with it`,
|
|
351
|
+
};
|
|
352
|
+
}
|
|
353
|
+
/** An OPERATION on an `any`-typed value with no static lowering, in a
|
|
354
|
+
* static build. The honest static subset of `any` compiles (bindings ride
|
|
355
|
+
* the checked-dynamic DOM — declarations, assignments, reads, equality,
|
|
356
|
+
* typeof, truthiness, templates, calls through boxed functions), but the
|
|
357
|
+
* operations that need JS's full coercion/mutation semantics (operators,
|
|
358
|
+
* expando writes, computed member names, iteration) execute only in the
|
|
359
|
+
* engine. Same code as the `any` type fence (SC2011) so the coverage
|
|
360
|
+
* report and the two-tier retry treat both as one dynamic-capable family:
|
|
361
|
+
* the island lifts exactly these sites. */
|
|
362
|
+
export function anyOpRequiresDynamicDiag(feature, loc) {
|
|
363
|
+
return {
|
|
364
|
+
code: "SC2011",
|
|
365
|
+
message: `${feature} on 'any'-typed values runs in the embedded dynamic engine, which this build does not include`,
|
|
366
|
+
loc,
|
|
367
|
+
milestone: "M4",
|
|
368
|
+
hint: "build with --dynamic to run 'any'-typed code in the embedded engine (adds ~620KB to the binary), or stay static with 'unknown' and a checked cast ('x as T')",
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
/** A construct that needs the embedded dynamic-island engine was used in a
|
|
372
|
+
* static build. Static is the default and never silently embeds the engine
|
|
373
|
+
* (~620KB); the fix is spelled out in the hint, not applied implicitly.
|
|
374
|
+
* "Requires" (vs SC2011/SC2012's "runs in"): the construct is engine-only
|
|
375
|
+
* — it has no static form to stay with, so the hint offers no alternative. */
|
|
376
|
+
export function requiresDynamicDiag(feature, loc) {
|
|
377
|
+
return {
|
|
378
|
+
code: "SC2010",
|
|
379
|
+
message: `${feature} requires the embedded dynamic engine, which this build does not include`,
|
|
380
|
+
loc,
|
|
381
|
+
milestone: "M4",
|
|
382
|
+
hint: "build with --dynamic to embed the engine (adds ~620KB to the binary); static builds never include it",
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
/** An ambient API with an island-backed lowering (Math.*, number/string
|
|
386
|
+
* methods beyond the static set, parseFloat, ...) was used in a static
|
|
387
|
+
* build. Same contract as SC2010, its own code so the coverage report can
|
|
388
|
+
* name the construct: the call RUNS under --dynamic (the engine executes
|
|
389
|
+
* it with JS-exact semantics); without the flag each use site reports the
|
|
390
|
+
* choice instead of ICEing or failing at link time. */
|
|
391
|
+
export function requiresDynamicApiDiag(feature, loc) {
|
|
392
|
+
return {
|
|
393
|
+
code: "SC2012",
|
|
394
|
+
message: `${feature} runs in the embedded dynamic engine, which this build does not include`,
|
|
395
|
+
loc,
|
|
396
|
+
milestone: "M4",
|
|
397
|
+
hint: "build with --dynamic to run this call in the embedded engine (adds ~620KB to the binary); static builds never include it",
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
/** An npm package import in a static build. The package's shipped JS has
|
|
401
|
+
* exactly one execution home — the embedded engine — so the import itself
|
|
402
|
+
* "requires" (SC2010's voice); its own code so the coverage report can
|
|
403
|
+
* attribute sites per package. */
|
|
404
|
+
export function requiresDynamicImportDiag(pkg, loc) {
|
|
405
|
+
return {
|
|
406
|
+
code: "SC2013",
|
|
407
|
+
message: `importing '${pkg}' requires the embedded dynamic engine, which this build does not include — the package's implementation runs there`,
|
|
408
|
+
loc,
|
|
409
|
+
milestone: "M4",
|
|
410
|
+
hint: "build with --dynamic to run npm package code in the embedded engine (adds ~620KB to the binary); static builds never include it",
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
/** A USE SITE of a value whose type the package's .d.ts declares, in a
|
|
414
|
+
* static build. Message names ONLY the package (never the type) so the
|
|
415
|
+
* coverage report groups all of a package's sites into one line. */
|
|
416
|
+
export function requiresDynamicPackageDiag(pkg, loc) {
|
|
417
|
+
return {
|
|
418
|
+
code: "SC2013",
|
|
419
|
+
message: `values from the '${pkg}' package run in the embedded dynamic engine, which this build does not include`,
|
|
420
|
+
loc,
|
|
421
|
+
milestone: "M4",
|
|
422
|
+
hint: "build with --dynamic to run npm package code in the embedded engine (adds ~620KB to the binary); static builds never include it",
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
/** Building the embedded npm runtime graph failed — the package's entry
|
|
426
|
+
* or one of its internal modules can't resolve, or it needs a Node builtin
|
|
427
|
+
* the island doesn't shim. Named per problem, at the import site. */
|
|
428
|
+
export function npmEmbedFailedDiag(detail, loc) {
|
|
429
|
+
return {
|
|
430
|
+
code: "SC2030",
|
|
431
|
+
message: `cannot embed npm package code: ${detail}`,
|
|
432
|
+
loc,
|
|
433
|
+
milestone: "later",
|
|
434
|
+
hint: "the package's runtime JS is embedded at build time and executed in the island; packages that reach outside the shimmed builtins (events, path, fs, os, process, util, buffer, stream, crypto, zlib, url, assert, and the rest of `scriptc coverage`'s shimmed table — http/https clients and net/tls load too; http2 and worker_threads are the notable absences) do not run yet",
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
/** comptime went wrong at evaluation time. The callback runs in an isolated
|
|
438
|
+
* `node:vm` context inside the compiler's own Node process and its RESULT is
|
|
439
|
+
* baked into the binary as a literal — everything that can fail at that
|
|
440
|
+
* stage lands here with a specific detail: the callback threw, evaluation
|
|
441
|
+
* exceeded the compile-time budget, or the returned value cannot be written
|
|
442
|
+
* as a literal of the expected type (NaN/Infinity, undefined/null/functions,
|
|
443
|
+
* shape mismatches — the detail names the offending path, dynCheck-style). */
|
|
444
|
+
export function comptimeFailedDiag(detail, loc) {
|
|
445
|
+
return {
|
|
446
|
+
code: "SC1110",
|
|
447
|
+
message: `comptime evaluation failed: ${detail}`,
|
|
448
|
+
loc,
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
export function iceDiag(message, loc) {
|
|
452
|
+
return {
|
|
453
|
+
code: "SC9001",
|
|
454
|
+
message: `internal compiler error: ${message} — please report this`,
|
|
455
|
+
loc,
|
|
456
|
+
};
|
|
457
|
+
}
|
|
458
|
+
//# sourceMappingURL=diagnostic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostic.js","sourceRoot":"","sources":["../../src/diagnostics/diagnostic.ts"],"names":[],"mappings":"AAuCA,MAAM,CAAC,MAAM,WAAW,GAAqC;IAC3D,MAAM,EAAE;QACN,OAAO,EAAE,iBAAiB;QAC1B,SAAS,EAAE,IAAI;QACf,IAAI,EACF,wEAAwE;YACxE,kEAAkE;YAClE,sEAAsE;YACtE,iEAAiE;YACjE,iEAAiE;YACjE,gEAAgE;YAChE,oEAAoE;YACpE,sEAAsE;YACtE,wCAAwC;KAC3C;IACD,yEAAyE;IACzE,0EAA0E;IAC1E,yEAAyE;IACzE,yEAAyE;IACzE,oEAAoE;IACpE,uEAAuE;IACvE,oEAAoE;IACpE,2BAA2B;IAC3B,MAAM,EAAE;QACN,OAAO,EAAE,yBAAyB;QAClC,SAAS,EAAE,OAAO;QAClB,IAAI,EAAE,uEAAuE;KAC9E;IACD,kEAAkE;IAClE,wEAAwE;IACxE,qEAAqE;IACrE,uEAAuE;IACvE,qEAAqE;IACrE,6BAA6B;IAC7B,MAAM,E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} from "./diagnostic.js";
|
|
2
|
+
export interface RenderOptions {
|
|
3
|
+
color?: boolean;
|
|
4
|
+
}
|
|
5
|
+
interface SourceLookup {
|
|
6
|
+
/** Full text of the file the diagnostic points into. */
|
|
7
|
+
text: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function renderDiagnostic(diag: ScrDiagnostic, source: SourceLookup | undefined, opts?: RenderOptions): string;
|
|
10
|
+
export declare function renderAll(diags: ScrDiagnostic[], sourceTextByFile: Map<string, string>, opts?: RenderOptions): string;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
const RED = "\x1b[31m";
|
|
2
|
+
const CYAN = "\x1b[36m";
|
|
3
|
+
const DIM = "\x1b[2m";
|
|
4
|
+
const BOLD = "\x1b[1m";
|
|
5
|
+
const RESET = "\x1b[0m";
|
|
6
|
+
export function renderDiagnostic(diag, source, opts = {}) {
|
|
7
|
+
const c = (code, s) => (opts.color ? code + s + RESET : s);
|
|
8
|
+
const out = [];
|
|
9
|
+
let lineNum = 1;
|
|
10
|
+
let colNum = 1;
|
|
11
|
+
const frame = [];
|
|
12
|
+
if (source) {
|
|
13
|
+
const lineStarts = [0];
|
|
14
|
+
for (let i = 0; i < source.text.length; i++) {
|
|
15
|
+
if (source.text[i] === "\n")
|
|
16
|
+
lineStarts.push(i + 1);
|
|
17
|
+
}
|
|
18
|
+
let lo = 0;
|
|
19
|
+
while (lo + 1 < lineStarts.length && lineStarts[lo + 1] <= diag.loc.start)
|
|
20
|
+
lo++;
|
|
21
|
+
lineNum = lo + 1;
|
|
22
|
+
colNum = diag.loc.start - lineStarts[lo] + 1;
|
|
23
|
+
const lines = source.text.split("\n");
|
|
24
|
+
const gutterWidth = String(Math.min(lineNum + 1, lines.length)).length;
|
|
25
|
+
const emitLine = (n) => {
|
|
26
|
+
const text = lines[n - 1];
|
|
27
|
+
if (text === undefined)
|
|
28
|
+
return;
|
|
29
|
+
frame.push(c(DIM, ` ${String(n).padStart(gutterWidth)} | `) + text);
|
|
30
|
+
};
|
|
31
|
+
emitLine(lineNum - 1);
|
|
32
|
+
emitLine(lineNum);
|
|
33
|
+
const lineText = lines[lineNum - 1] ?? "";
|
|
34
|
+
const spanOnLine = Math.max(1, Math.min(diag.loc.end - diag.loc.start, lineText.length - (colNum - 1)));
|
|
35
|
+
frame.push(c(DIM, ` ${" ".repeat(gutterWidth)} | `) +
|
|
36
|
+
" ".repeat(colNum - 1) +
|
|
37
|
+
c(RED, "^" + "~".repeat(spanOnLine - 1)));
|
|
38
|
+
emitLine(lineNum + 1);
|
|
39
|
+
}
|
|
40
|
+
out.push(`${c(BOLD, `${diag.loc.file}:${lineNum}:${colNum}`)} - ${c(RED, "error")} ${c(BOLD, diag.code)}: ${diag.message}`);
|
|
41
|
+
if (frame.length) {
|
|
42
|
+
out.push("", ...frame);
|
|
43
|
+
}
|
|
44
|
+
if (diag.hint) {
|
|
45
|
+
out.push("", ` ${c(CYAN, "hint:")} ${diag.hint}`);
|
|
46
|
+
}
|
|
47
|
+
return out.join("\n");
|
|
48
|
+
}
|
|
49
|
+
export function renderAll(diags, sourceTextByFile, opts = {}) {
|
|
50
|
+
const sorted = [...diags].sort((a, b) => a.loc.file.localeCompare(b.loc.file) || a.loc.start - b.loc.start);
|
|
51
|
+
return sorted
|
|
52
|
+
.map((d) => {
|
|
53
|
+
const text = sourceTextByFile.get(d.loc.file);
|
|
54
|
+
return renderDiagnostic(d, text === undefined ? undefined : { text }, opts);
|
|
55
|
+
})
|
|
56
|
+
.join("\n\n");
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=render.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render.js","sourceRoot":"","sources":["../../src/diagnostics/render.ts"],"names":[],"mappings":"AAcA,MAAM,GAAG,GAAG,UAAU,CAAC;AACvB,MAAM,IAAI,GAAG,UAAU,CAAC;AACxB,MAAM,GAAG,GAAG,SAAS,CAAC;AACtB,MAAM,IAAI,GAAG,SAAS,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}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface CjsLexedExports {
|
|
2
|
+
/** Names Node's lexer detects in THIS file (no reexport resolution). */
|
|
3
|
+
exports: Set<string>;
|
|
4
|
+
/** Reexport specifiers surviving the last `module.exports =` clearing,
|
|
5
|
+
* in source order: the assignment's own require forms plus every later
|
|
6
|
+
* (or unclear-ed) star-pattern / Babel-loop match. */
|
|
7
|
+
reexports: string[];
|
|
8
|
+
}
|
|
9
|
+
/** The single-file lex over SOURCE TEXT: every detection site, position-
|
|
10
|
+
* blind like the real lexer for the assignment forms (nested functions and
|
|
11
|
+
* dead branches count), brace-depth-0 for the star patterns. */
|
|
12
|
+
export declare function cjsLexedExportsOf(source: string, fileName?: string): CjsLexedExports;
|
|
13
|
+
/** The full Node-visible named-export set of a CommonJS module: its own
|
|
14
|
+
* lexed names plus, recursively, the names of every reexport target that
|
|
15
|
+
* itself resolves to a CommonJS module (Node's cjsPreparseModuleExports —
|
|
16
|
+
* ESM / JSON / builtin / unresolved targets contribute nothing). Generic
|
|
17
|
+
* over the caller's module HANDLE so both typescript worlds can drive it
|
|
18
|
+
* with their own file objects — only strings cross this boundary.
|
|
19
|
+
* Cycle-safe. */
|
|
20
|
+
export declare function cjsLexerVisibleNames<H>(mod: H, sourceOf: (mod: H) => string, resolveCjsDep: (from: H, spec: string) => H | null, memo?: Map<H, Set<string>>): Set<string>;
|