@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,99 @@
|
|
|
1
|
+
import type { CompilerOptions, Diagnostic, Project, Snapshot } from "typescript/unstable/sync";
|
|
2
|
+
import type { SourceFile } from "typescript/unstable/ast";
|
|
3
|
+
import { CheckerFacade } from "./checker.js";
|
|
4
|
+
/** The compiler options our createProgram accepts: TS7's CompilerOptions
|
|
5
|
+
* shape (numeric enums for target/module/moduleResolution — the enums module
|
|
6
|
+
* re-exports them symbolically) with the 5.9.3 "lib.es2025.d.ts" lib
|
|
7
|
+
* spelling also accepted. */
|
|
8
|
+
export type Ts7CompilerOptions = CompilerOptions;
|
|
9
|
+
/** One spawned tsgo server plus the virtual-FS overlay serving synthesized
|
|
10
|
+
* tsconfigs. Share a host across programs to pay the spawn once; the overlay
|
|
11
|
+
* is a live map, so each createProgram call adds its config before taking
|
|
12
|
+
* the snapshot. */
|
|
13
|
+
export declare class Ts7Host {
|
|
14
|
+
private readonly virtualFiles;
|
|
15
|
+
private readonly api;
|
|
16
|
+
private closed;
|
|
17
|
+
constructor(options?: {
|
|
18
|
+
cwd?: string;
|
|
19
|
+
collectTiming?: boolean;
|
|
20
|
+
/** Optional real-path shadow (the --npm-static resolution lever):
|
|
21
|
+
* `readFile` may answer REPLACEMENT content for a real file (a
|
|
22
|
+
* types-stripped package.json) and `hideFile` may shadow a real file
|
|
23
|
+
* out of existence (an opted-in package's shipped .d.ts). Virtual
|
|
24
|
+
* files always win; unshadowed paths fall through to the real FS. */
|
|
25
|
+
fsShadow?: {
|
|
26
|
+
readFile: (path: string) => string | undefined;
|
|
27
|
+
hideFile: (path: string) => boolean;
|
|
28
|
+
} | null;
|
|
29
|
+
});
|
|
30
|
+
/** Registers an in-memory file served to tsgo by the virtual-FS hooks. */
|
|
31
|
+
addVirtualFile(path: string, content: string): void;
|
|
32
|
+
/** tsgo's own tsconfig parser (extends chains resolved server-side) — the
|
|
33
|
+
* 7-world replacement for ts.readConfigFile + ts.parseJsonConfigFileContent.
|
|
34
|
+
* Returns raw option values (strings for enum-ish knobs) and the resolved
|
|
35
|
+
* file list. */
|
|
36
|
+
parseConfigFile(configPath: string): {
|
|
37
|
+
options: Record<string, unknown>;
|
|
38
|
+
fileNames: string[];
|
|
39
|
+
};
|
|
40
|
+
createProgram(rootNames: readonly string[], options: Ts7CompilerOptions,
|
|
41
|
+
/** Internal: true when the program owns this host and dispose() closes it. */
|
|
42
|
+
programOwnsHost?: boolean): Ts7Program;
|
|
43
|
+
getTimingInfo(): unknown;
|
|
44
|
+
close(): void;
|
|
45
|
+
}
|
|
46
|
+
/** ts.Program-shaped facade over a TS7 Project: same-name query surface plus
|
|
47
|
+
* getTypeChecker() returning the memoizing/batching CheckerFacade. dispose()
|
|
48
|
+
* releases the snapshot (and the host, when this program spawned it). */
|
|
49
|
+
export declare class Ts7Program {
|
|
50
|
+
/** The underlying TS7 project (program + checker + emitter). */
|
|
51
|
+
readonly project: Project;
|
|
52
|
+
private readonly snapshot;
|
|
53
|
+
private readonly host;
|
|
54
|
+
private readonly sharedHost;
|
|
55
|
+
private sourceFilesCache;
|
|
56
|
+
private checkerFacade;
|
|
57
|
+
constructor(
|
|
58
|
+
/** The underlying TS7 project (program + checker + emitter). */
|
|
59
|
+
project: Project, snapshot: Snapshot, host: Ts7Host, sharedHost: boolean);
|
|
60
|
+
getCompilerOptions(): CompilerOptions;
|
|
61
|
+
getSourceFile(fileName: string): SourceFile | undefined;
|
|
62
|
+
getSourceFileNames(): readonly string[];
|
|
63
|
+
/** Materializes every file of the program (5.9.3's getSourceFiles shape).
|
|
64
|
+
* 7.0.2 serves files one by one; the result is cached, so the full-program
|
|
65
|
+
* sweeps (preflight's user-file scan) pay the transfer once. */
|
|
66
|
+
getSourceFiles(): readonly SourceFile[];
|
|
67
|
+
getTypeChecker(): CheckerFacade;
|
|
68
|
+
getSyntacticDiagnostics(sourceFile?: SourceFile): readonly Diagnostic[];
|
|
69
|
+
getSemanticDiagnostics(sourceFile?: SourceFile): readonly Diagnostic[];
|
|
70
|
+
getGlobalDiagnostics(): readonly Diagnostic[];
|
|
71
|
+
getProgramDiagnostics(): readonly Diagnostic[];
|
|
72
|
+
getConfigFileParsingDiagnostics(): readonly Diagnostic[];
|
|
73
|
+
isSourceFileDefaultLibrary(file: SourceFile): boolean;
|
|
74
|
+
isSourceFileFromExternalLibrary(file: SourceFile): boolean;
|
|
75
|
+
dispose(): void;
|
|
76
|
+
}
|
|
77
|
+
/** The ts.createProgram-shaped entry: roots + options, tsconfig synthesized
|
|
78
|
+
* behind the scenes. Without a shared host each call spawns (and owns) its
|
|
79
|
+
* own tsgo server — pass one Ts7Host when building several programs (the
|
|
80
|
+
* lowering world and preflight's project world). */
|
|
81
|
+
export declare function createProgram(rootNames: readonly string[], options: Ts7CompilerOptions, host?: Ts7Host): Ts7Program;
|
|
82
|
+
/** 5.9.3's getPreEmitDiagnostics, composed from 7.0.2's split surface (the
|
|
83
|
+
* package dropped the aggregate). Order mirrors 5.9.3: config, options/
|
|
84
|
+
* program, global, syntactic, semantic. */
|
|
85
|
+
export declare function getPreEmitDiagnostics(program: Ts7Program): readonly Diagnostic[];
|
|
86
|
+
/** ts.findConfigFile: nearest configName walking up from searchPath. */
|
|
87
|
+
export declare function findConfigFile(searchPath: string, fileExists?: (fileName: string) => boolean, configName?: string): string | undefined;
|
|
88
|
+
/** The ts.sys subset the census uses (program.ts, npm.ts — 8 call sites),
|
|
89
|
+
* over node:fs. 7.0.2 ships no ts.sys; the compiler runs on Node, so these
|
|
90
|
+
* are the direct implementations. */
|
|
91
|
+
export declare const sys: {
|
|
92
|
+
fileExists(path: string): boolean;
|
|
93
|
+
readFile(path: string): string | undefined;
|
|
94
|
+
writeFile(path: string, data: string): void;
|
|
95
|
+
directoryExists(path: string): boolean;
|
|
96
|
+
getCurrentDirectory(): string;
|
|
97
|
+
useCaseSensitiveFileNames: boolean;
|
|
98
|
+
newLine: string;
|
|
99
|
+
};
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
/* Program lifecycle over typescript@7.0.2's unstable sync API — the
|
|
2
|
+
* ts.createProgram-shaped entry the survey's probe7b proved out.
|
|
3
|
+
*
|
|
4
|
+
* 7.0.2 has no createProgram(roots, options): the model is
|
|
5
|
+
* new API({cwd, fs}) -> updateSnapshot({openProjects: [tsconfig]}) ->
|
|
6
|
+
* snapshot.getProject(...), strictly tsconfig-driven. scriptc's no-tsconfig /
|
|
7
|
+
* extra-roots story (entry + ambient dts + fallback/overrides dts, forced
|
|
8
|
+
* options) maps onto that through a SYNTHESIZED IN-MEMORY tsconfig: the
|
|
9
|
+
* virtual-FS hooks serve one nonexistent tsconfig path whose "files" lists
|
|
10
|
+
* exactly our roots (absolute paths) and whose compilerOptions serialize our
|
|
11
|
+
* options; every other path falls through to the real filesystem, so real
|
|
12
|
+
* entries, ambient .d.ts files, and node_modules resolve exactly as on disk.
|
|
13
|
+
*
|
|
14
|
+
* One Ts7Host owns one spawned tsgo server (54 ms warm spawn per the survey;
|
|
15
|
+
* 387 cold). createProgram() takes an optional shared host — the default
|
|
16
|
+
* spawns a private one that dispose() closes. */
|
|
17
|
+
import { existsSync, readFileSync, statSync, writeFileSync } from "node:fs";
|
|
18
|
+
import { dirname, join, resolve } from "node:path";
|
|
19
|
+
import { API } from "typescript/unstable/sync";
|
|
20
|
+
import { CheckerFacade } from "./checker.js";
|
|
21
|
+
import { enumKeyOf, ModuleKind, ModuleResolutionKind, ScriptTarget } from "./enums.js";
|
|
22
|
+
/* tsconfig JSON wants enum NAMES; the options object carries TS7's numeric
|
|
23
|
+
* enum values. The names come from the enum objects' own reverse mappings —
|
|
24
|
+
* nothing here knows a number. */
|
|
25
|
+
function serializeOptions(options) {
|
|
26
|
+
const out = {};
|
|
27
|
+
for (const [key, value] of Object.entries(options)) {
|
|
28
|
+
if (value === undefined)
|
|
29
|
+
continue;
|
|
30
|
+
switch (key) {
|
|
31
|
+
// tsgo's tsconfig parser is case-sensitive about enum-option spellings
|
|
32
|
+
// (5.9.3's was not): the enum KEY names lowercase to the accepted forms
|
|
33
|
+
// ("ESNext" -> "esnext", "Bundler" -> "bundler", "NodeNext" ->
|
|
34
|
+
// "nodenext").
|
|
35
|
+
case "target":
|
|
36
|
+
// ScriptTarget.ESNext and .Latest share a value; the reverse map
|
|
37
|
+
// answers "Latest", which the option parser does not accept.
|
|
38
|
+
out[key] =
|
|
39
|
+
value === ScriptTarget.ESNext
|
|
40
|
+
? "esnext"
|
|
41
|
+
: (enumKeyOf(ScriptTarget, value)?.toLowerCase() ?? value);
|
|
42
|
+
break;
|
|
43
|
+
case "module":
|
|
44
|
+
out[key] = enumKeyOf(ModuleKind, value)?.toLowerCase() ?? value;
|
|
45
|
+
break;
|
|
46
|
+
case "moduleResolution":
|
|
47
|
+
out[key] = enumKeyOf(ModuleResolutionKind, value)?.toLowerCase() ?? value;
|
|
48
|
+
break;
|
|
49
|
+
case "lib":
|
|
50
|
+
// 5.9.3 spells lib entries "lib.es2025.d.ts"; tsconfig wants "es2025".
|
|
51
|
+
out[key] = value.map((lib) => lib.startsWith("lib.") && lib.endsWith(".d.ts") ? lib.slice(4, -5) : lib);
|
|
52
|
+
break;
|
|
53
|
+
default: {
|
|
54
|
+
if (typeof value === "number" && key !== "maxNodeModuleJsDepth") {
|
|
55
|
+
throw new Error(`ts7 createProgram: unhandled enum-valued compiler option '${key}'`);
|
|
56
|
+
}
|
|
57
|
+
out[key] = value;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return out;
|
|
62
|
+
}
|
|
63
|
+
let nextConfigId = 0;
|
|
64
|
+
/** One spawned tsgo server plus the virtual-FS overlay serving synthesized
|
|
65
|
+
* tsconfigs. Share a host across programs to pay the spawn once; the overlay
|
|
66
|
+
* is a live map, so each createProgram call adds its config before taking
|
|
67
|
+
* the snapshot. */
|
|
68
|
+
export class Ts7Host {
|
|
69
|
+
virtualFiles = new Map();
|
|
70
|
+
api;
|
|
71
|
+
closed = false;
|
|
72
|
+
constructor(options) {
|
|
73
|
+
const virtualFiles = this.virtualFiles;
|
|
74
|
+
const shadow = options?.fsShadow ?? null;
|
|
75
|
+
this.api = new API({
|
|
76
|
+
cwd: options?.cwd ?? process.cwd(),
|
|
77
|
+
...(options?.collectTiming !== undefined ? { collectTiming: options.collectTiming } : {}),
|
|
78
|
+
fs: {
|
|
79
|
+
// string => virtual (or shadowed) hit; null => shadowed out of
|
|
80
|
+
// existence; undefined => real-FS fallthrough.
|
|
81
|
+
readFile: (fileName) => {
|
|
82
|
+
const virtual = virtualFiles.get(fileName);
|
|
83
|
+
if (virtual !== undefined)
|
|
84
|
+
return virtual;
|
|
85
|
+
if (shadow === null)
|
|
86
|
+
return undefined;
|
|
87
|
+
if (shadow.hideFile(fileName))
|
|
88
|
+
return null;
|
|
89
|
+
return shadow.readFile(fileName);
|
|
90
|
+
},
|
|
91
|
+
fileExists: (fileName) => {
|
|
92
|
+
if (virtualFiles.has(fileName))
|
|
93
|
+
return true;
|
|
94
|
+
if (shadow !== null && shadow.hideFile(fileName))
|
|
95
|
+
return false;
|
|
96
|
+
return undefined;
|
|
97
|
+
},
|
|
98
|
+
directoryExists: () => undefined,
|
|
99
|
+
realpath: (path) => (virtualFiles.has(path) ? path : undefined),
|
|
100
|
+
getAccessibleEntries: () => undefined,
|
|
101
|
+
},
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
/** Registers an in-memory file served to tsgo by the virtual-FS hooks. */
|
|
105
|
+
addVirtualFile(path, content) {
|
|
106
|
+
this.virtualFiles.set(path, content);
|
|
107
|
+
}
|
|
108
|
+
/** tsgo's own tsconfig parser (extends chains resolved server-side) — the
|
|
109
|
+
* 7-world replacement for ts.readConfigFile + ts.parseJsonConfigFileContent.
|
|
110
|
+
* Returns raw option values (strings for enum-ish knobs) and the resolved
|
|
111
|
+
* file list. */
|
|
112
|
+
parseConfigFile(configPath) {
|
|
113
|
+
return this.api.parseConfigFile(resolve(configPath));
|
|
114
|
+
}
|
|
115
|
+
createProgram(rootNames, options,
|
|
116
|
+
/** Internal: true when the program owns this host and dispose() closes it. */
|
|
117
|
+
programOwnsHost = false) {
|
|
118
|
+
if (this.closed)
|
|
119
|
+
throw new Error("Ts7Host is closed");
|
|
120
|
+
const roots = rootNames.map((r) => resolve(r));
|
|
121
|
+
const first = roots[0];
|
|
122
|
+
if (first === undefined)
|
|
123
|
+
throw new Error("ts7 createProgram: no root files");
|
|
124
|
+
const configPath = join(dirname(first), `__scriptc-ts7-${nextConfigId++}.tsconfig.json`);
|
|
125
|
+
this.addVirtualFile(configPath, JSON.stringify({ compilerOptions: serializeOptions(options), files: roots, include: [] }));
|
|
126
|
+
const snapshot = this.api.updateSnapshot({ openProjects: [configPath] });
|
|
127
|
+
const project = snapshot.getProject(configPath);
|
|
128
|
+
if (!project) {
|
|
129
|
+
snapshot.dispose();
|
|
130
|
+
throw new Error(`ts7 createProgram: project failed to open for ${first}`);
|
|
131
|
+
}
|
|
132
|
+
return new Ts7Program(project, snapshot, this, !programOwnsHost);
|
|
133
|
+
}
|
|
134
|
+
getTimingInfo() {
|
|
135
|
+
return this.api.getTimingInfo();
|
|
136
|
+
}
|
|
137
|
+
close() {
|
|
138
|
+
if (this.closed)
|
|
139
|
+
return;
|
|
140
|
+
this.closed = true;
|
|
141
|
+
this.api.close();
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
/** ts.Program-shaped facade over a TS7 Project: same-name query surface plus
|
|
145
|
+
* getTypeChecker() returning the memoizing/batching CheckerFacade. dispose()
|
|
146
|
+
* releases the snapshot (and the host, when this program spawned it). */
|
|
147
|
+
export class Ts7Program {
|
|
148
|
+
project;
|
|
149
|
+
snapshot;
|
|
150
|
+
host;
|
|
151
|
+
sharedHost;
|
|
152
|
+
sourceFilesCache = null;
|
|
153
|
+
checkerFacade = null;
|
|
154
|
+
constructor(
|
|
155
|
+
/** The underlying TS7 project (program + checker + emitter). */
|
|
156
|
+
project, snapshot, host, sharedHost) {
|
|
157
|
+
this.project = project;
|
|
158
|
+
this.snapshot = snapshot;
|
|
159
|
+
this.host = host;
|
|
160
|
+
this.sharedHost = sharedHost;
|
|
161
|
+
}
|
|
162
|
+
getCompilerOptions() {
|
|
163
|
+
return this.project.program.getCompilerOptions();
|
|
164
|
+
}
|
|
165
|
+
getSourceFile(fileName) {
|
|
166
|
+
return this.project.program.getSourceFile(resolve(fileName));
|
|
167
|
+
}
|
|
168
|
+
getSourceFileNames() {
|
|
169
|
+
return this.project.program.getSourceFileNames();
|
|
170
|
+
}
|
|
171
|
+
/** Materializes every file of the program (5.9.3's getSourceFiles shape).
|
|
172
|
+
* 7.0.2 serves files one by one; the result is cached, so the full-program
|
|
173
|
+
* sweeps (preflight's user-file scan) pay the transfer once. */
|
|
174
|
+
getSourceFiles() {
|
|
175
|
+
if (this.sourceFilesCache === null) {
|
|
176
|
+
const program = this.project.program;
|
|
177
|
+
this.sourceFilesCache = program
|
|
178
|
+
.getSourceFileNames()
|
|
179
|
+
.map((name) => program.getSourceFile(name))
|
|
180
|
+
.filter((sf) => sf !== undefined);
|
|
181
|
+
}
|
|
182
|
+
return this.sourceFilesCache;
|
|
183
|
+
}
|
|
184
|
+
getTypeChecker() {
|
|
185
|
+
this.checkerFacade ??= new CheckerFacade(this.project.checker, { project: this.project });
|
|
186
|
+
return this.checkerFacade;
|
|
187
|
+
}
|
|
188
|
+
getSyntacticDiagnostics(sourceFile) {
|
|
189
|
+
return this.project.program.getSyntacticDiagnostics(sourceFile?.fileName);
|
|
190
|
+
}
|
|
191
|
+
getSemanticDiagnostics(sourceFile) {
|
|
192
|
+
return this.project.program.getSemanticDiagnostics(sourceFile?.fileName);
|
|
193
|
+
}
|
|
194
|
+
getGlobalDiagnostics() {
|
|
195
|
+
return this.project.program.getGlobalDiagnostics();
|
|
196
|
+
}
|
|
197
|
+
getProgramDiagnostics() {
|
|
198
|
+
return this.project.program.getProgramDiagnostics();
|
|
199
|
+
}
|
|
200
|
+
getConfigFileParsingDiagnostics() {
|
|
201
|
+
return this.project.program.getConfigFileParsingDiagnostics();
|
|
202
|
+
}
|
|
203
|
+
isSourceFileDefaultLibrary(file) {
|
|
204
|
+
return this.project.program.isSourceFileDefaultLibrary(file);
|
|
205
|
+
}
|
|
206
|
+
isSourceFileFromExternalLibrary(file) {
|
|
207
|
+
return this.project.program.isSourceFileFromExternalLibrary(file);
|
|
208
|
+
}
|
|
209
|
+
dispose() {
|
|
210
|
+
this.snapshot.dispose();
|
|
211
|
+
if (!this.sharedHost)
|
|
212
|
+
this.host.close();
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
/** The ts.createProgram-shaped entry: roots + options, tsconfig synthesized
|
|
216
|
+
* behind the scenes. Without a shared host each call spawns (and owns) its
|
|
217
|
+
* own tsgo server — pass one Ts7Host when building several programs (the
|
|
218
|
+
* lowering world and preflight's project world). */
|
|
219
|
+
export function createProgram(rootNames, options, host) {
|
|
220
|
+
if (host)
|
|
221
|
+
return host.createProgram(rootNames, options);
|
|
222
|
+
const first = rootNames[0];
|
|
223
|
+
const owned = new Ts7Host({ cwd: first !== undefined ? dirname(resolve(first)) : process.cwd() });
|
|
224
|
+
return owned.createProgram(rootNames, options, /* programOwnsHost */ true);
|
|
225
|
+
}
|
|
226
|
+
/** 5.9.3's getPreEmitDiagnostics, composed from 7.0.2's split surface (the
|
|
227
|
+
* package dropped the aggregate). Order mirrors 5.9.3: config, options/
|
|
228
|
+
* program, global, syntactic, semantic. */
|
|
229
|
+
export function getPreEmitDiagnostics(program) {
|
|
230
|
+
return [
|
|
231
|
+
...program.getConfigFileParsingDiagnostics(),
|
|
232
|
+
...program.getProgramDiagnostics(),
|
|
233
|
+
...program.getGlobalDiagnostics(),
|
|
234
|
+
...program.getSyntacticDiagnostics(),
|
|
235
|
+
...program.getSemanticDiagnostics(),
|
|
236
|
+
];
|
|
237
|
+
}
|
|
238
|
+
/** ts.findConfigFile: nearest configName walking up from searchPath. */
|
|
239
|
+
export function findConfigFile(searchPath, fileExists = sys.fileExists, configName = "tsconfig.json") {
|
|
240
|
+
let dir = resolve(searchPath);
|
|
241
|
+
for (;;) {
|
|
242
|
+
const candidate = join(dir, configName);
|
|
243
|
+
if (fileExists(candidate))
|
|
244
|
+
return candidate;
|
|
245
|
+
const parent = dirname(dir);
|
|
246
|
+
if (parent === dir)
|
|
247
|
+
return undefined;
|
|
248
|
+
dir = parent;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
/** The ts.sys subset the census uses (program.ts, npm.ts — 8 call sites),
|
|
252
|
+
* over node:fs. 7.0.2 ships no ts.sys; the compiler runs on Node, so these
|
|
253
|
+
* are the direct implementations. */
|
|
254
|
+
export const sys = {
|
|
255
|
+
fileExists(path) {
|
|
256
|
+
return existsSync(path) && statSync(path).isFile();
|
|
257
|
+
},
|
|
258
|
+
readFile(path) {
|
|
259
|
+
try {
|
|
260
|
+
return readFileSync(path, "utf8");
|
|
261
|
+
}
|
|
262
|
+
catch {
|
|
263
|
+
return undefined;
|
|
264
|
+
}
|
|
265
|
+
},
|
|
266
|
+
writeFile(path, data) {
|
|
267
|
+
writeFileSync(path, data);
|
|
268
|
+
},
|
|
269
|
+
directoryExists(path) {
|
|
270
|
+
return existsSync(path) && statSync(path).isDirectory();
|
|
271
|
+
},
|
|
272
|
+
getCurrentDirectory() {
|
|
273
|
+
return process.cwd();
|
|
274
|
+
},
|
|
275
|
+
useCaseSensitiveFileNames: true,
|
|
276
|
+
newLine: "\n",
|
|
277
|
+
};
|
|
278
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ACrC,GAAG,GAAG,MAAM,CAAC;IACf,CAAC;AACH,CAAC;AAED;;qCAEqC;AACrC,MAAM,CAAC,MAAM,GAAG,GAAG;IACjB,UAAU,CAAC,IAAY;QACrB,OAAO,UAAU,CAAC,IAAI,CAAC,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;IACrD,CAAC;IACD,QAAQ,CAAC,IAAY;QACnB,IAAI,CAAC;YACH,OAAO,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACpC,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;IACD,SAAS,CAAC,IAAY,EAAE,IAAY;QAClC,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC5B,CAAC;IACD,eAAe,CAAC,IAAY;QAC1B,OAAO,UAAU,CAAC,IAAI,CAAC,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;IAC1D,CAAC;IACD,mBAAmB;QACjB,OAAO,OAAO,CAAC,GAAG,EAAE,CAAC;IACvB,CAAC;IACD,yBAAyB,EAAE,IAAI;IAC/B,OAAO,EAAE,IAAI;CACd,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/* Two-world separation, enforced at build time. The 5.9.3 world (the
|
|
2
|
+
* "typescript5" aliased import — parser/transpile islands only) and the
|
|
3
|
+
* 7.0.2 world (this adapter, over the real "typescript" dependency) must
|
|
4
|
+
* never exchange AST or checker objects: the enums
|
|
5
|
+
* renumbered between worlds, so a node that crosses carries kinds and flags
|
|
6
|
+
* that MEAN something else on the other side, silently.
|
|
7
|
+
*
|
|
8
|
+
* The fence is nominal enum typing: every node interface carries a
|
|
9
|
+
* `kind`/`flags` member typed by its own package's enum declaration, and
|
|
10
|
+
* TypeScript never treats two distinct enum declarations as assignable. The
|
|
11
|
+
* assertions below pin that this actually holds in both directions for the
|
|
12
|
+
* shapes that travel (nodes, source files, enum values) — if a future
|
|
13
|
+
* package update ever made the worlds structurally compatible, pnpm build
|
|
14
|
+
* fails HERE instead of letting objects drift across.
|
|
15
|
+
*
|
|
16
|
+
* Type-level only: the "typescript5" import is type-position, so no 5.9.3
|
|
17
|
+
* runtime joins the adapter's module graph, and the assertion function is
|
|
18
|
+
* never called. */
|
|
19
|
+
export function assertWorldsAreDisjoint(node5, node7, file5, file7, kind5, kind7) {
|
|
20
|
+
// @ts-expect-error a 5.9.3 node must not flow into the 7 world
|
|
21
|
+
const _a = node5;
|
|
22
|
+
// @ts-expect-error a 7 node must not flow into the 5.9.3 world
|
|
23
|
+
const _b = node7;
|
|
24
|
+
// @ts-expect-error a 5.9.3 source file must not flow into the 7 world
|
|
25
|
+
const _c = file5;
|
|
26
|
+
// @ts-expect-error a 7 source file must not flow into the 5.9.3 world
|
|
27
|
+
const _d = file7;
|
|
28
|
+
// @ts-expect-error 5.9.3 SyntaxKind values are not 7 SyntaxKind values (renumbered)
|
|
29
|
+
const _e = kind5;
|
|
30
|
+
// @ts-expect-error 7 SyntaxKind values are not 5.9.3 SyntaxKind values (renumbered)
|
|
31
|
+
const _f = kind7;
|
|
32
|
+
void [_a, _b, _c, _d, _e, _f];
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=world-check.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"world-check.js","sourceRoot":"","sources":["../../../src/frontend/ts7/world-check.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;mBAiBmB;AAKnB,MAAM,UAAU,uBAAuB,CACrC,KAAe,EACf,KAAe,EACf,KAAqB,EACrB,KAAqB,EACrB,KAAqB,EACrB,KAAqB;IAErB,+DAA+D;IAC/D,MAAM,EAAE,GAAa,KAAK,CAAC;IAC3B,+DAA+D;IAC/D,MAAM,EAAE,GAAa,KAAK,CAAC;IAC3B,sEAAsE;IACtE,MAAM,EAAE,GAAmB,KAAK,CAAC;IACjC,sEAAsE;IACtE,MAAM,EAAE,GAAmB,KAAK,CAAC;IACjC,oFAAoF;IACpF,MAAM,EAAE,GAAmB,KAAK,CAAC;IACjC,oFAAoF;IACpF,MAAM,EAAE,GAAmB,KAAK,CAAC;IACjC,KAAK,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;AAChC,CAAC"}
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import * as ts from "./ts7/adapter.js";
|
|
2
|
+
import type { IrRecordShape, IrType, IrUnionDef } from "../ir/nodes.js";
|
|
3
|
+
import { typeKey } from "../ir/nodes.js";
|
|
4
|
+
export { typeKey };
|
|
5
|
+
/** The island-backed ambient TYPE names of the fetch slice: standard-
|
|
6
|
+
* library interfaces whose VALUES live in the embedded engine (the
|
|
7
|
+
* engine's fetch mints the Response; AbortSignal.timeout mints the
|
|
8
|
+
* signal), so under --dynamic they map to island handles (jsval) exactly
|
|
9
|
+
* like npm-declared types. Checked with declaration provenance in mapType;
|
|
10
|
+
* consumed by the lowerer's badType for the static-build wording. */
|
|
11
|
+
export declare const ISLAND_AMBIENT_TYPES: readonly ["Response", "RequestInit", "AbortSignal"];
|
|
12
|
+
/** The frontend's record-shape interner. Records are monomorphic structural
|
|
13
|
+
* shapes: fields sorted by name form the canonical identity, and two types
|
|
14
|
+
* with the same canonical field list share one shapeId (and later one C
|
|
15
|
+
* struct). Owned by the Lowerer; `mapType` needs it to intern the object
|
|
16
|
+
* types it encounters, which is why it is threaded through as a parameter. */
|
|
17
|
+
export declare class ShapeRegistry {
|
|
18
|
+
private readonly byKey;
|
|
19
|
+
private readonly byId;
|
|
20
|
+
/** All interned shapes in first-seen (`r0`, `r1`, ...) order. */
|
|
21
|
+
readonly shapes: IrRecordShape[];
|
|
22
|
+
/** ts.Types currently being mapped — breaks recursive shape types
|
|
23
|
+
* (`type T = { next: T }`), which mapType rejects by returning null. */
|
|
24
|
+
readonly inProgress: Set<ts.Type>;
|
|
25
|
+
/** Interns a canonical (name-sorted) field list, returning its shapeId.
|
|
26
|
+
* `tuple` shapes (fields "0".."n-1" from a tuple type) intern SEPARATELY
|
|
27
|
+
* from structurally identical numeric-keyed object records: the flag is
|
|
28
|
+
* part of the identity because the two serialize differently (a tuple is
|
|
29
|
+
* a JSON array, an object a JSON object). A string index signature's
|
|
30
|
+
* value type (`indexValue`) is part of the identity too: the same
|
|
31
|
+
* declared fields with and without an overflow portion — or with
|
|
32
|
+
* differently-typed ones — are different structs. */
|
|
33
|
+
intern(fields: {
|
|
34
|
+
name: string;
|
|
35
|
+
type: IrType;
|
|
36
|
+
}[], tuple?: boolean, indexValue?: IrType, declaredOrder?: string[]): string;
|
|
37
|
+
get(shapeId: string): IrRecordShape | undefined;
|
|
38
|
+
}
|
|
39
|
+
/** The frontend's union interner — mirrors ShapeRegistry. A union's
|
|
40
|
+
* canonical identity is its typeKey-sorted arm list; two ts unions whose
|
|
41
|
+
* arms map to the same IR types share one unionId (and later one runtime
|
|
42
|
+
* tag numbering: an arm's index in the canonical list IS its tag). Owned by
|
|
43
|
+
* the Lowerer; threaded through mapType exactly like ShapeRegistry. */
|
|
44
|
+
export declare class UnionRegistry {
|
|
45
|
+
private readonly byKey;
|
|
46
|
+
private readonly byId;
|
|
47
|
+
/** All interned unions in first-seen (`u0`, `u1`, ...) order. */
|
|
48
|
+
readonly unions: IrUnionDef[];
|
|
49
|
+
/** ts.Types currently being mapped — breaks recursive union types
|
|
50
|
+
* (`type T = A | { next: T }`), which mapType rejects by returning null. */
|
|
51
|
+
readonly inProgress: Set<ts.Type>;
|
|
52
|
+
/** Interns a canonical (typeKey-sorted, deduplicated) arm list, returning
|
|
53
|
+
* its unionId. */
|
|
54
|
+
intern(arms: IrType[]): string;
|
|
55
|
+
get(unionId: string): IrUnionDef | undefined;
|
|
56
|
+
}
|
|
57
|
+
/** Human-readable rendering of an IrType for diagnostics (records expand to
|
|
58
|
+
* their canonical field list, unions to their arms; `checker.typeToString`
|
|
59
|
+
* can't — it never sees IR types). */
|
|
60
|
+
export declare function formatIrType(t: IrType, shapes: ShapeRegistry, unions: UnionRegistry): string;
|
|
61
|
+
/** True when the declaration sits inside `declare module "<name>"` (or
|
|
62
|
+
* its node:-prefixed twin) — the disambiguator for builtin-module type
|
|
63
|
+
* names that repeat across modules (net.Server vs http.Server). Both
|
|
64
|
+
* @types/node and the shipped fallback declare builtins this way. */
|
|
65
|
+
/** ES OrdinaryOwnPropertyKeys order over string keys: canonical array
|
|
66
|
+
* indices (the exact string spelling of an integer in [0, 2^32-1)) come
|
|
67
|
+
* first in ascending numeric order, everything else follows in the given
|
|
68
|
+
* (insertion/declaration) order. This is JS's enumeration order for the
|
|
69
|
+
* objects records model — Object.keys, JSON.stringify, spread, inspect. */
|
|
70
|
+
export declare function esOwnKeyOrder(names: string[]): string[];
|
|
71
|
+
/** True when a type contains a record anywhere (the trigger for the
|
|
72
|
+
* shape-mismatch diagnostic SC2002 — non-record mismatches are tsc's or
|
|
73
|
+
* the validator's business). */
|
|
74
|
+
export declare function containsRecord(t: IrType): boolean;
|
|
75
|
+
/** True when a type contains a union anywhere reachable without a registry
|
|
76
|
+
* (the trigger for the union-mismatch diagnostic SC2003 — e.g. a value
|
|
77
|
+
* narrowed to a SUB-union flowing into the full union's slot, which would
|
|
78
|
+
* need a runtime re-tag). */
|
|
79
|
+
export declare function containsUnion(t: IrType): boolean;
|
|
80
|
+
/** ts.Type → IrType. Returns null for anything outside the supported
|
|
81
|
+
* surface; the caller turns that into a SC2001 diagnostic with
|
|
82
|
+
* checker.typeToString.
|
|
83
|
+
*
|
|
84
|
+
* Literal types are widened FIRST (`const x = 1` has type `1`, `true` has
|
|
85
|
+
* type `true`; internally `boolean` is the union `true | false`) — mapping
|
|
86
|
+
* without widening is the classic bug this function exists to centralize.
|
|
87
|
+
*
|
|
88
|
+
* `ctx.shapes` is the Lowerer's shape registry: object types over data
|
|
89
|
+
* properties intern their canonical shape there and map to
|
|
90
|
+
* `{ kind: "record", shapeId }`.
|
|
91
|
+
*/
|
|
92
|
+
/** Computes the program-wide IR name for a class declaration. Injected by
|
|
93
|
+
* the Lowerer so type mapping and lowering agree on qualified names in
|
|
94
|
+
* multi-file programs (two files may each declare `class Point`). */
|
|
95
|
+
export type ClassNamer = (decl: ts.ClassLikeDeclaration) => string;
|
|
96
|
+
/** Resolves a type-parameter ts.Type to a concrete IR type, or null when it
|
|
97
|
+
* isn't one / isn't bound. Injected by the Lowerer while it instantiates a
|
|
98
|
+
* generic function body (monomorphization): inside the body the checker
|
|
99
|
+
* reports the UNSUBSTITUTED types (`T`, `T[]`, `{ v: T }`), so the
|
|
100
|
+
* substitution has to happen inside mapType's recursion — carried by the
|
|
101
|
+
* TypeMapperCtx exactly like ClassNamer. */
|
|
102
|
+
export type TypeParamResolver = (t: ts.Type) => IrType | null;
|
|
103
|
+
/** Everything mapType needs besides the type itself: the checker, the two
|
|
104
|
+
* interners (owned by the Lowerer), and the Lowerer-injected hooks. Built
|
|
105
|
+
* once per Lowerer and threaded through the recursion — adding a hook means
|
|
106
|
+
* one new field here, not a new parameter at every call site. */
|
|
107
|
+
export interface TypeMapperCtx {
|
|
108
|
+
checker: ts.TypeChecker;
|
|
109
|
+
shapes: ShapeRegistry;
|
|
110
|
+
unions: UnionRegistry;
|
|
111
|
+
classNamer: ClassNamer;
|
|
112
|
+
resolveTypeParam?: TypeParamResolver;
|
|
113
|
+
/** GENERIC program classes (monomorphization by flow): the mapping of a
|
|
114
|
+
* concrete instantiation reference (`Box<number>`) — the Lowerer
|
|
115
|
+
* registers/reuses the instantiation (`Box%0`) and answers its object
|
|
116
|
+
* type; null when a type argument doesn't map, the cap tripped, or the
|
|
117
|
+
* family never collected. Absent in checkers with no lowering attached
|
|
118
|
+
* (generic instance types stay unmapped there). */
|
|
119
|
+
genericClassInstance?: (decl: ts.ClassLikeDeclaration, typeRef: ts.Type) => IrType | null;
|
|
120
|
+
/** MIXIN class nodes (the class inside a mixin function): one shared
|
|
121
|
+
* AST node, one instantiation per call site — the node's instance type
|
|
122
|
+
* resolves to the instantiation CURRENTLY collecting/lowering (`this`
|
|
123
|
+
* inside members, self-referential member types), null outside any
|
|
124
|
+
* mixin context (the type alone cannot name a call site). */
|
|
125
|
+
mixinClassInstance?: (decl: ts.ClassLikeDeclaration) => IrType | null;
|
|
126
|
+
/** MIXIN instance INTERSECTIONS (`Tagged.C & Derived` — values built
|
|
127
|
+
* through a mixin result): resolved by chain structure to the unique
|
|
128
|
+
* pinned instantiation they describe; null when ambiguous or when no
|
|
129
|
+
* part names a mixin class node (lower-mixins.ts). */
|
|
130
|
+
mixinIntersectionInstance?: (widened: ts.Type) => IrType | null;
|
|
131
|
+
/** True for the STANDARD LIBRARY's files — the shipped ambient .d.ts or a
|
|
132
|
+
* lib.*.d.ts bundled with typescript (program.isSourceFileDefaultLibrary).
|
|
133
|
+
* Map/RegExp/Promise recognition needs declaration provenance: the name
|
|
134
|
+
* alone proves nothing (a user's own `interface Map` maps as a record). */
|
|
135
|
+
isStdlibFile: (sf: ts.SourceFile) => boolean;
|
|
136
|
+
/** True for an npm package's shipped .d.ts — a declaration file under
|
|
137
|
+
* node_modules that is NOT the standard library (typescript's own lib
|
|
138
|
+
* files live under node_modules too). Types declared there map to jsval
|
|
139
|
+
* under --dynamic: the package's implementation runs in the embedded
|
|
140
|
+
* engine, so its values are island handles. */
|
|
141
|
+
isNpmFile: (sf: ts.SourceFile) => boolean;
|
|
142
|
+
/** --dynamic: `any` maps to the island handle type (jsval). Off, `any`
|
|
143
|
+
* stays unmapped and the requires-dynamic diagnostic fires per site. */
|
|
144
|
+
dynamic: boolean;
|
|
145
|
+
/** True for files the Lowerer actually compiles (its module order). A
|
|
146
|
+
* class type can reach the entry through the TYPE world alone — a jsdoc
|
|
147
|
+
* `typeof import('./mod')` over a module never imported at value level
|
|
148
|
+
* pulls the file into the ts.Program without ever entering the lowered
|
|
149
|
+
* program, so its classes never register and an object type naming one
|
|
150
|
+
* would ICE the validator. Such instance types stay unmapped (null):
|
|
151
|
+
* callers fence them like any other unsupported type. */
|
|
152
|
+
isProgramFile: (sf: ts.SourceFile) => boolean;
|
|
153
|
+
}
|
|
154
|
+
export declare function mapType(type: ts.Type, ctx: TypeMapperCtx): IrType | null;
|
|
155
|
+
/** The UNIT-ONLY slot type: the interned `null | undefined` union, the one
|
|
156
|
+
* representation the IR already has for values that are nothing but units.
|
|
157
|
+
* Bindings and fields whose CHECKER type is a bare unit (`null`,
|
|
158
|
+
* `undefined`, `void` in value position, or unions of only those) ride it:
|
|
159
|
+
* the runtime value is always one of the two interned unit instances, the
|
|
160
|
+
* tag is the narrowing test (`x === null`, `typeof x === "undefined"`),
|
|
161
|
+
* and JSON keeps Node's split (null serializes, undefined omits). The type
|
|
162
|
+
* admits an arm the checker may not spell (a `null`-typed slot gets an
|
|
163
|
+
* undefined arm too) — the representation is coarser than the TS type,
|
|
164
|
+
* exactly like literal widening, and tsc has already rejected every write
|
|
165
|
+
* that could inhabit the extra arm. */
|
|
166
|
+
export declare function unitOnlyUnion(unions: UnionRegistry): IrType;
|
|
167
|
+
/** The IteratorResult record of a generator's value channels: `{ done:
|
|
168
|
+
* boolean, value: V }` where V is dyn (an any/unknown channel) or the
|
|
169
|
+
* canonical union of the yield arms, the return arms (when the return
|
|
170
|
+
* channel carries a value), and `undefined` (an exhausted `.next()`
|
|
171
|
+
* answers undefined). ONE shape per channel pair — `g.next()`'s lowering,
|
|
172
|
+
* `.return()`, `.throw()`, the for-of desugar, and mapType's
|
|
173
|
+
* IteratorResult alias mapping all intern through here, so reads agree.
|
|
174
|
+
* Null when the combined union would be illegal (a func/set arm beside
|
|
175
|
+
* data arms, a map/regex arm — kinds with no narrowing test): such
|
|
176
|
+
* generators stay unmapped. */
|
|
177
|
+
export declare function genResultRecord(yieldT: IrType, retT: IrType, shapes: ShapeRegistry, unions: UnionRegistry): (IrType & {
|
|
178
|
+
kind: "record";
|
|
179
|
+
}) | null;
|
|
180
|
+
/** True when a checker type is inhabited ONLY by the unit values —
|
|
181
|
+
* undefined (or `void`, whose runtime inhabitant is undefined) and null,
|
|
182
|
+
* or a union of just those. The positions that today fence VOID (record
|
|
183
|
+
* fields, tuple/array elements, variable slots) substitute unitOnlyUnion
|
|
184
|
+
* for these; RETURN positions keep the VOID mapping (a void return is not
|
|
185
|
+
* a value). */
|
|
186
|
+
export declare function isUnitOnlyTsType(t: ts.Type): boolean;
|
|
187
|
+
/** IR-level `t | undefined`, canonicalized and fenced exactly like the
|
|
188
|
+
* ts-union branch of mapType (typeKey-sorted arms, deduplicated; map/
|
|
189
|
+
* regex/dyn/void arms unrepresentable; a func arm IS representable — the
|
|
190
|
+
* result is exactly the nullable-callback shape mapType's union branch
|
|
191
|
+
* admits, `(() => void) | undefined`) so the interned union is IDENTICAL
|
|
192
|
+
* to what mapping the checker's own `T | undefined` produces. */
|
|
193
|
+
export declare function withUndefinedArm(t: IrType, unions: UnionRegistry): IrType | null;
|
|
194
|
+
/** A GENERIC-callable member type (`m<T>(x: T): T` / `f: <T>(x: T) => T` in
|
|
195
|
+
* an object type): pure function-shaped — call signatures only, every one
|
|
196
|
+
* carrying its own type parameters — with no data properties, no construct
|
|
197
|
+
* signatures, no index signatures. Such members are EXCLUDED from record
|
|
198
|
+
* shapes instead of failing them: no single closure slot can hold a generic
|
|
199
|
+
* function, so the shape keeps its data fields and calls of the member
|
|
200
|
+
* monomorphize per call site against the defining declaration (see
|
|
201
|
+
* lower-calls.ts, lowerObjLitGenericMethodCall). Node's JSON.stringify drops
|
|
202
|
+
* function-valued properties, so serialization of the shape stays exact;
|
|
203
|
+
* Object.keys over such a shape omits the member (a pin — every excluded
|
|
204
|
+
* member is a function the key walk would name). */
|
|
205
|
+
export declare function isGenericCallableMemberType(t: ts.Type, checker: ts.TypeChecker): boolean;
|