@loopdive/js2 0.57.0

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.
Files changed (233) hide show
  1. package/CHANGELOG.md +1425 -0
  2. package/LICENSE +189 -0
  3. package/README.md +451 -0
  4. package/dist/checker/index.d.ts +117 -0
  5. package/dist/checker/language-service.d.ts +39 -0
  6. package/dist/checker/node-capability-map.d.ts +63 -0
  7. package/dist/checker/type-mapper.d.ts +84 -0
  8. package/dist/cjs-rewrite.d.ts +19 -0
  9. package/dist/cli.d.ts +2 -0
  10. package/dist/cli.js +363 -0
  11. package/dist/codegen/accessor-driver.d.ts +97 -0
  12. package/dist/codegen/any-helpers.d.ts +72 -0
  13. package/dist/codegen/array-element-typing.d.ts +46 -0
  14. package/dist/codegen/array-holes.d.ts +69 -0
  15. package/dist/codegen/array-methods.d.ts +68 -0
  16. package/dist/codegen/array-object-proto.d.ts +64 -0
  17. package/dist/codegen/array-reduce-fusion.d.ts +31 -0
  18. package/dist/codegen/array-to-primitive.d.ts +28 -0
  19. package/dist/codegen/async-cps.d.ts +239 -0
  20. package/dist/codegen/async-scheduler.d.ts +349 -0
  21. package/dist/codegen/binary-ops.d.ts +78 -0
  22. package/dist/codegen/binding-info.d.ts +31 -0
  23. package/dist/codegen/builtin-scaffold.d.ts +98 -0
  24. package/dist/codegen/builtin-static-globals.d.ts +8 -0
  25. package/dist/codegen/builtin-tags.d.ts +189 -0
  26. package/dist/codegen/case-convert-native.d.ts +12 -0
  27. package/dist/codegen/case-tables.d.ts +4 -0
  28. package/dist/codegen/class-bodies.d.ts +41 -0
  29. package/dist/codegen/class-member-keys.d.ts +33 -0
  30. package/dist/codegen/class-to-primitive.d.ts +39 -0
  31. package/dist/codegen/closed-method-dispatch.d.ts +42 -0
  32. package/dist/codegen/closures.d.ts +285 -0
  33. package/dist/codegen/coercion-engine.d.ts +154 -0
  34. package/dist/codegen/coercion-plan.d.ts +29 -0
  35. package/dist/codegen/context/bodies.d.ts +4 -0
  36. package/dist/codegen/context/create-context.d.ts +4 -0
  37. package/dist/codegen/context/errors.d.ts +39 -0
  38. package/dist/codegen/context/locals.d.ts +69 -0
  39. package/dist/codegen/context/source-pos.d.ts +5 -0
  40. package/dist/codegen/context/speculative.d.ts +95 -0
  41. package/dist/codegen/context/types.d.ts +1936 -0
  42. package/dist/codegen/custom-iterable.d.ts +34 -0
  43. package/dist/codegen/dataview-native.d.ts +51 -0
  44. package/dist/codegen/date-parse-native.d.ts +13 -0
  45. package/dist/codegen/dead-elimination.d.ts +26 -0
  46. package/dist/codegen/declarations.d.ts +147 -0
  47. package/dist/codegen/deno-api.d.ts +11 -0
  48. package/dist/codegen/destructuring-params.d.ts +102 -0
  49. package/dist/codegen/dyn-read.d.ts +26 -0
  50. package/dist/codegen/eval-tiering.d.ts +19 -0
  51. package/dist/codegen/expressions/assignment.d.ts +61 -0
  52. package/dist/codegen/expressions/builtins.d.ts +26 -0
  53. package/dist/codegen/expressions/calls-closures.d.ts +54 -0
  54. package/dist/codegen/expressions/calls-guards.d.ts +49 -0
  55. package/dist/codegen/expressions/calls-optional.d.ts +4 -0
  56. package/dist/codegen/expressions/calls.d.ts +83 -0
  57. package/dist/codegen/expressions/eval-inline.d.ts +24 -0
  58. package/dist/codegen/expressions/extern.d.ts +67 -0
  59. package/dist/codegen/expressions/fnctor-prototype.d.ts +52 -0
  60. package/dist/codegen/expressions/helpers.d.ts +212 -0
  61. package/dist/codegen/expressions/identifiers.d.ts +57 -0
  62. package/dist/codegen/expressions/late-imports.d.ts +81 -0
  63. package/dist/codegen/expressions/logical-ops.d.ts +18 -0
  64. package/dist/codegen/expressions/misc.d.ts +27 -0
  65. package/dist/codegen/expressions/new-super.d.ts +25 -0
  66. package/dist/codegen/expressions/promise-subclass.d.ts +38 -0
  67. package/dist/codegen/expressions/proto-override.d.ts +63 -0
  68. package/dist/codegen/expressions/unary-updates.d.ts +21 -0
  69. package/dist/codegen/expressions/unary.d.ts +6 -0
  70. package/dist/codegen/expressions.d.ts +31 -0
  71. package/dist/codegen/fallback-telemetry.d.ts +53 -0
  72. package/dist/codegen/fixups.d.ts +80 -0
  73. package/dist/codegen/fmod.d.ts +10 -0
  74. package/dist/codegen/fnctor-escape-gate.d.ts +92 -0
  75. package/dist/codegen/function-body.d.ts +52 -0
  76. package/dist/codegen/generators-native.d.ts +92 -0
  77. package/dist/codegen/helpers/body-references-own-this.d.ts +22 -0
  78. package/dist/codegen/helpers/body-uses-arguments.d.ts +12 -0
  79. package/dist/codegen/helpers/is-strict-function.d.ts +52 -0
  80. package/dist/codegen/host-import-allowlist.d.ts +140 -0
  81. package/dist/codegen/index.d.ts +500 -0
  82. package/dist/codegen/ir-tail-call.d.ts +8 -0
  83. package/dist/codegen/iterator-native.d.ts +44 -0
  84. package/dist/codegen/json-codec-native.d.ts +78 -0
  85. package/dist/codegen/json-runtime.d.ts +35 -0
  86. package/dist/codegen/json-standalone.d.ts +25 -0
  87. package/dist/codegen/linear-uint8-analysis.d.ts +46 -0
  88. package/dist/codegen/linear-uint8-arena.d.ts +7 -0
  89. package/dist/codegen/linear-uint8-codegen.d.ts +103 -0
  90. package/dist/codegen/linear-uint8-signatures.d.ts +26 -0
  91. package/dist/codegen/literals.d.ts +115 -0
  92. package/dist/codegen/map-runtime.d.ts +142 -0
  93. package/dist/codegen/math-helpers.d.ts +7 -0
  94. package/dist/codegen/member-get-dispatch.d.ts +42 -0
  95. package/dist/codegen/member-set-dispatch.d.ts +28 -0
  96. package/dist/codegen/native-proto.d.ts +98 -0
  97. package/dist/codegen/native-regex.d.ts +158 -0
  98. package/dist/codegen/native-strings.d.ts +146 -0
  99. package/dist/codegen/new-target.d.ts +30 -0
  100. package/dist/codegen/node-fs-api.d.ts +47 -0
  101. package/dist/codegen/number-format-native.d.ts +9 -0
  102. package/dist/codegen/number-ryu.d.ts +27 -0
  103. package/dist/codegen/object-ops.d.ts +94 -0
  104. package/dist/codegen/object-runtime.d.ts +171 -0
  105. package/dist/codegen/parse-number-native.d.ts +10 -0
  106. package/dist/codegen/peephole.d.ts +6 -0
  107. package/dist/codegen/property-access.d.ts +294 -0
  108. package/dist/codegen/raw-wasi-api.d.ts +13 -0
  109. package/dist/codegen/regex/bytecode.d.ts +140 -0
  110. package/dist/codegen/regex/casefold.d.ts +41 -0
  111. package/dist/codegen/regex/compile.d.ts +51 -0
  112. package/dist/codegen/regex/parse.d.ts +76 -0
  113. package/dist/codegen/regex/unicode.d.ts +42 -0
  114. package/dist/codegen/regex/vm.d.ts +24 -0
  115. package/dist/codegen/regexp-standalone.d.ts +350 -0
  116. package/dist/codegen/registry/error-types.d.ts +38 -0
  117. package/dist/codegen/registry/imports.d.ts +46 -0
  118. package/dist/codegen/registry/types.d.ts +59 -0
  119. package/dist/codegen/set-algebra.d.ts +17 -0
  120. package/dist/codegen/set-runtime.d.ts +74 -0
  121. package/dist/codegen/shared.d.ts +111 -0
  122. package/dist/codegen/stack-balance.d.ts +43 -0
  123. package/dist/codegen/statements/control-flow.d.ts +25 -0
  124. package/dist/codegen/statements/destructuring.d.ts +177 -0
  125. package/dist/codegen/statements/exceptions.d.ts +11 -0
  126. package/dist/codegen/statements/functions.d.ts +1 -0
  127. package/dist/codegen/statements/index.d.ts +1 -0
  128. package/dist/codegen/statements/loops.d.ts +7 -0
  129. package/dist/codegen/statements/nested-declarations.d.ts +78 -0
  130. package/dist/codegen/statements/shared.d.ts +38 -0
  131. package/dist/codegen/statements/tdz.d.ts +43 -0
  132. package/dist/codegen/statements/variables.d.ts +3 -0
  133. package/dist/codegen/statements.d.ts +9 -0
  134. package/dist/codegen/string-builder.d.ts +131 -0
  135. package/dist/codegen/string-ops.d.ts +87 -0
  136. package/dist/codegen/struct-accessor-closure.d.ts +36 -0
  137. package/dist/codegen/symbol-native.d.ts +55 -0
  138. package/dist/codegen/temporal-native.d.ts +8 -0
  139. package/dist/codegen/timsort.d.ts +2 -0
  140. package/dist/codegen/type-coercion.d.ts +123 -0
  141. package/dist/codegen/typeof-delete.d.ts +38 -0
  142. package/dist/codegen/uri-encoding-native.d.ts +33 -0
  143. package/dist/codegen/value-tags.d.ts +74 -0
  144. package/dist/codegen/walk-instructions.d.ts +20 -0
  145. package/dist/codegen/weak-collections-runtime.d.ts +16 -0
  146. package/dist/codegen/with-scope.d.ts +106 -0
  147. package/dist/codegen-linear/c-abi.d.ts +74 -0
  148. package/dist/codegen-linear/context.d.ts +86 -0
  149. package/dist/codegen-linear/index.d.ts +28 -0
  150. package/dist/codegen-linear/layout.d.ts +39 -0
  151. package/dist/codegen-linear/runtime.d.ts +161 -0
  152. package/dist/codegen-linear/simd.d.ts +7 -0
  153. package/dist/compiler/define-substitution.d.ts +27 -0
  154. package/dist/compiler/early-errors/assignment.d.ts +26 -0
  155. package/dist/compiler/early-errors/context.d.ts +17 -0
  156. package/dist/compiler/early-errors/duplicates.d.ts +20 -0
  157. package/dist/compiler/early-errors/index.d.ts +11 -0
  158. package/dist/compiler/early-errors/labels.d.ts +13 -0
  159. package/dist/compiler/early-errors/module-rules.d.ts +36 -0
  160. package/dist/compiler/early-errors/node-checks.d.ts +7 -0
  161. package/dist/compiler/early-errors/predicates.d.ts +140 -0
  162. package/dist/compiler/early-errors/tdz.d.ts +17 -0
  163. package/dist/compiler/import-manifest.d.ts +18 -0
  164. package/dist/compiler/output.d.ts +46 -0
  165. package/dist/compiler/validation.d.ts +45 -0
  166. package/dist/compiler.d.ts +48 -0
  167. package/dist/define-substitution-BcUeKC2A.js +109 -0
  168. package/dist/emit/binary.d.ts +50 -0
  169. package/dist/emit/c-header.d.ts +23 -0
  170. package/dist/emit/canonical-recgroup.d.ts +86 -0
  171. package/dist/emit/encoder.d.ts +28 -0
  172. package/dist/emit/object.d.ts +14 -0
  173. package/dist/emit/opcodes.d.ts +464 -0
  174. package/dist/emit/sourcemap.d.ts +33 -0
  175. package/dist/emit/wat.d.ts +6 -0
  176. package/dist/env.d.ts +46 -0
  177. package/dist/import-resolver.d.ts +68 -0
  178. package/dist/index.d.ts +486 -0
  179. package/dist/index.js +755 -0
  180. package/dist/ir/alloc-registry.d.ts +75 -0
  181. package/dist/ir/analysis/encoding.d.ts +38 -0
  182. package/dist/ir/analysis/escape.d.ts +32 -0
  183. package/dist/ir/analysis/lattice.d.ts +72 -0
  184. package/dist/ir/analysis/ownership.d.ts +31 -0
  185. package/dist/ir/analysis/stack-alloc.d.ts +20 -0
  186. package/dist/ir/backend/bytecode-emitter.d.ts +237 -0
  187. package/dist/ir/backend/bytecode-vm.d.ts +74 -0
  188. package/dist/ir/backend/emitter.d.ts +121 -0
  189. package/dist/ir/backend/handles.d.ts +133 -0
  190. package/dist/ir/backend/legality.d.ts +9 -0
  191. package/dist/ir/backend/linear-emitter.d.ts +41 -0
  192. package/dist/ir/backend/wasmgc-emitter.d.ts +43 -0
  193. package/dist/ir/builder.d.ts +401 -0
  194. package/dist/ir/from-ast.d.ts +192 -0
  195. package/dist/ir/index.d.ts +16 -0
  196. package/dist/ir/integration.d.ts +27 -0
  197. package/dist/ir/lower.d.ts +203 -0
  198. package/dist/ir/nodes.d.ts +1452 -0
  199. package/dist/ir/passes/alloc-discipline.d.ts +19 -0
  200. package/dist/ir/passes/constant-fold.d.ts +7 -0
  201. package/dist/ir/passes/dead-code.d.ts +18 -0
  202. package/dist/ir/passes/inline-small.d.ts +7 -0
  203. package/dist/ir/passes/monomorphize.d.ts +21 -0
  204. package/dist/ir/passes/simplify-cfg.d.ts +19 -0
  205. package/dist/ir/passes/tagged-union-types.d.ts +45 -0
  206. package/dist/ir/passes/tagged-unions.d.ts +22 -0
  207. package/dist/ir/propagate.d.ts +135 -0
  208. package/dist/ir/select.d.ts +81 -0
  209. package/dist/ir/types.d.ts +832 -0
  210. package/dist/ir/verify-alloc.d.ts +18 -0
  211. package/dist/ir/verify.d.ts +7 -0
  212. package/dist/link/index.d.ts +11 -0
  213. package/dist/link/isolation.d.ts +24 -0
  214. package/dist/link/linker.d.ts +37 -0
  215. package/dist/link/reader.d.ts +158 -0
  216. package/dist/link/resolver.d.ts +19 -0
  217. package/dist/optimize.d.ts +54 -0
  218. package/dist/optimize.js +262 -0
  219. package/dist/position-map.d.ts +64 -0
  220. package/dist/process-stdin-prelude.d.ts +16 -0
  221. package/dist/resolve.d.ts +82 -0
  222. package/dist/runtime/builtins.d.ts +1 -0
  223. package/dist/runtime-C-4q_KwU.js +164438 -0
  224. package/dist/runtime-containment.d.ts +6 -0
  225. package/dist/runtime-eval.d.ts +132 -0
  226. package/dist/runtime-instantiate.d.ts +16 -0
  227. package/dist/runtime.d.ts +128 -0
  228. package/dist/runtime.js +12 -0
  229. package/dist/shape-inference.d.ts +20 -0
  230. package/dist/treeshake.d.ts +17 -0
  231. package/dist/ts-api.d.ts +30 -0
  232. package/dist/wit-generator.d.ts +18 -0
  233. package/package.json +187 -0
@@ -0,0 +1,117 @@
1
+ import { ts } from '../ts-api.js';
2
+ export declare function preloadLibFiles(files: Record<string, string>): void;
3
+ export interface TypedAST {
4
+ sourceFile: ts.SourceFile;
5
+ checker: ts.TypeChecker;
6
+ program: ts.Program;
7
+ diagnostics: ts.Diagnostic[];
8
+ syntacticDiagnostics: readonly ts.Diagnostic[];
9
+ }
10
+ /** Check if a file name is a known lib file */
11
+ export declare function isKnownLibName(name: string): boolean;
12
+ export declare function getLibSourceFile(name: string, languageVersion: ts.ScriptTarget | ts.CreateSourceFileOptions): ts.SourceFile | undefined;
13
+ export interface AnalyzeOptions {
14
+ /** Allow JavaScript source files (enables allowJs + checkJs in TS compiler) */
15
+ allowJs?: boolean;
16
+ /** Skip semantic diagnostics collection (faster — checker still available for type queries) */
17
+ skipSemanticDiagnostics?: boolean;
18
+ /**
19
+ * Node API emulation (#2603), opt-in via `--emulate node`. Serves a synthetic
20
+ * ambient `process` declaration so the checker resolves the Node globals
21
+ * js2wasm lowers (process.std{in,out,err}, argv, env, exit) without the user
22
+ * installing @types/node — eliminating the repeated TS2580 "Cannot find name
23
+ * 'process'" warnings. Type-level only; does not change emitted wasm (codegen
24
+ * lowers `process.*` syntactically regardless). Falls back to no injection if
25
+ * the user already declares `process`, so it never creates a dup-identifier error.
26
+ */
27
+ emulateNode?: boolean;
28
+ /**
29
+ * Host environment scoping the AMBIENT global surface (#2528/#2645), unified
30
+ * under `--target {web,node,deno}` (#2736; `--platform` is a deprecated
31
+ * alias). Orthogonal to the backend `target` (`gc`/`wasi`/…): this selects
32
+ * which globals are in scope at type-check time.
33
+ *
34
+ * - `"web"` → the DOM ambient surface (`window`, `document`, DOM
35
+ * types). Byte-identical to the historical default.
36
+ * - `"node"`/`"deno"` → the DOM-free ambient surface (DOM-only globals are
37
+ * NOT in scope, so `window.stop` is a clear type error)
38
+ * AND implies the Node-emulation injection path
39
+ * (`emulateNode`), so `process` & friends type-check
40
+ * without @types/node. (Real `@types/node`/Deno-lib
41
+ * loading is a later #2698 slice; `deno` currently routes
42
+ * through the same node-emulation/no-DOM surface.)
43
+ *
44
+ * `undefined` (unset) preserves today's behaviour exactly: the DOM composite
45
+ * is loaded and `emulateNode` is driven solely by its own option. This keeps
46
+ * the common (web/test262) path byte-neutral. See `buildNodeEnvDtsForSource`
47
+ * + the `emulateNode ||= platform ∈ {node,deno}` composition in #2645/#2736.
48
+ */
49
+ platform?: "web" | "node" | "deno";
50
+ /**
51
+ * Force TypeScript GRAMMAR for the parse even when the input file is named
52
+ * `.js`/`.mjs`/`.cjs` (#2752). When the compiler prepends an injected source
53
+ * prelude that is written in TypeScript — currently the `process.stdin`
54
+ * Readable prelude (`src/process-stdin-prelude.ts`), which carries the
55
+ * nullable/union types codegen relies on (`read(size?): string | null`) — the
56
+ * combined unit must be parsed under the TS grammar, or the loose-JS grammar
57
+ * checker hard-rejects the prelude's TS syntax with TS8009/8010/8017 ("X can
58
+ * only be used in TypeScript files") and compilation fails before codegen.
59
+ * This flag flips ONLY the `ScriptKind` (TS vs JS) for the parse; the
60
+ * `isJs`-derived semantics (`strict: false`, `allowJs`+`checkJs`) stay
61
+ * derived from the filename, so the user's `.js` code keeps its lenient
62
+ * checking while the prelude's TS syntax is accepted and its types stay
63
+ * load-bearing. Scoped to the prelude-injection path only — byte-neutral for
64
+ * every program that does not trigger a TS prelude injection.
65
+ */
66
+ forceTsGrammar?: boolean;
67
+ }
68
+ /**
69
+ * #2624 — compose `scanNodeEmuUsage` + `buildNodeEnvDts` for a source. Exported
70
+ * so tests can assert the EXACT import-scoped surface that emulation injects
71
+ * (e.g. that a `node:fs`-only program does not declare the `process` global).
72
+ * Returns `undefined` when the program touches no Node surface.
73
+ */
74
+ export declare function buildNodeEnvDtsForSource(source: string, scriptKind?: ts.ScriptKind): string | undefined;
75
+ /**
76
+ * #2684 — build the import-scoped ambient `Deno` `.d.ts` for `source`, or
77
+ * `undefined` when the program does not reference `Deno`. The reference is
78
+ * approximated by a word-boundary regex, exactly like the bare-`process`
79
+ * detection in `scanNodeEmuUsage`; a user that declares its own `Deno` triggers
80
+ * the dup-identifier rebuild-without-injection fallback.
81
+ */
82
+ export declare function buildDenoEnvDtsForSource(source: string): string | undefined;
83
+ /**
84
+ * Parse and type-check a TS or JS source file.
85
+ * In-memory CompilerHost – no filesystem needed.
86
+ */
87
+ export declare function analyzeSource(source: string, fileName?: string, analyzeOptions?: AnalyzeOptions): TypedAST;
88
+ /** Result of multi-file analysis */
89
+ export interface MultiTypedAST {
90
+ /** All user source files (in dependency order, entry file last) */
91
+ sourceFiles: ts.SourceFile[];
92
+ /** The entry source file */
93
+ entryFile: ts.SourceFile;
94
+ checker: ts.TypeChecker;
95
+ program: ts.Program;
96
+ diagnostics: ts.Diagnostic[];
97
+ syntacticDiagnostics: readonly ts.Diagnostic[];
98
+ }
99
+ /**
100
+ * Parse and type-check multiple TS source files.
101
+ * In-memory CompilerHost — no filesystem needed.
102
+ * The TypeScript compiler handles cross-file imports natively.
103
+ */
104
+ export declare function analyzeMultiSource(files: Record<string, string>, entryFile: string,
105
+ /** Optional mapping from bare specifiers to file keys (e.g. { "lodash": "lodash/index.ts" }) */
106
+ specifierMap?: Record<string, string>,
107
+ /** Compiler options (allowJs, skipSemanticDiagnostics, ...) */
108
+ analyzeOptions?: AnalyzeOptions): MultiTypedAST;
109
+ /**
110
+ * Analyze a TypeScript project from an entry file on disk.
111
+ * Uses ts.createProgram with real filesystem access -- TypeScript resolves
112
+ * all imports automatically via its standard module resolution.
113
+ *
114
+ * Returns a MultiTypedAST suitable for generateMultiModule().
115
+ */
116
+ export declare function analyzeFiles(entryPath: string, analyzeOptions?: AnalyzeOptions): MultiTypedAST;
117
+ export { IncrementalLanguageService } from './language-service.js';
@@ -0,0 +1,39 @@
1
+ import { AnalyzeOptions, TypedAST } from './index.js';
2
+ /**
3
+ * Incremental compiler that reuses parsed lib SourceFiles across compilations.
4
+ *
5
+ * Uses the module-level LIB_SOURCE_FILES cache from checker/index.ts to return
6
+ * the SAME SourceFile objects for lib files. Each compilation creates a fresh
7
+ * Program and checker — no type state leaks between compilations. (#973)
8
+ *
9
+ * Performance: lib SourceFile caching avoids re-parsing ~10MB of .d.ts files
10
+ * per compilation, which is the dominant cost. We intentionally do NOT pass
11
+ * oldProgram to ts.createProgram — TypeScript's structure reuse carries forward
12
+ * internal symbol tables and type caches that leak stale type info between
13
+ * unrelated test compilations, causing ~400 false compile errors in the fork
14
+ * worker pool.
15
+ */
16
+ export declare class IncrementalLanguageService {
17
+ private currentSource;
18
+ private currentSourceFile;
19
+ private fileName;
20
+ private compilerOptions;
21
+ private host;
22
+ private defaultLibName;
23
+ constructor(fileName?: string);
24
+ /**
25
+ * Update the source for the next compilation.
26
+ *
27
+ * #2752 — `forceTsGrammar` forces `ScriptKind.TS` for the parsed SourceFile
28
+ * even when `fileName` ends in `.js` (otherwise `ts.createSourceFile` infers
29
+ * `ScriptKind.JS` from the extension and the loose-JS grammar checker rejects
30
+ * an injected TS prelude with TS8009/8010/8017). Mirrors the
31
+ * `forceTsGrammar` override in the non-incremental `analyzeSource`.
32
+ */
33
+ updateSource(source: string, fileName?: string, forceTsGrammar?: boolean): void;
34
+ /**
35
+ * Analyze — fresh Program + fresh checker, cached lib SourceFiles.
36
+ */
37
+ analyze(analyzeOptions?: AnalyzeOptions): TypedAST;
38
+ dispose(): void;
39
+ }
@@ -0,0 +1,63 @@
1
+ /**
2
+ * A provider that can satisfy a member at link time. Informational today
3
+ * (drives the deliberate-error message + future link wiring); the active set is
4
+ * target-dependent (`providersFor`).
5
+ */
6
+ export type NodeProvider = "wasi-fd" | "wasi-fs" | "js-host-fs" | "edge-adapter";
7
+ /** The compilation target surface a capability decision depends on. */
8
+ export interface CapabilityTarget {
9
+ /** `--target wasi` (standalone WASI: fd IO yes, filesystem no). */
10
+ wasi: boolean;
11
+ /** `--allow-fs` — JS-host filesystem access is permitted. */
12
+ allowFs: boolean;
13
+ }
14
+ export interface NodeMemberCapability {
15
+ /** The exported member name (e.g. `readSync`). */
16
+ name: string;
17
+ /**
18
+ * Faithful `.d.ts` declaration body for this member — one or more bodiless
19
+ * `export function` overloads, mirroring `@types/node`. Injected verbatim into
20
+ * the synthetic `node:<mod>` declaration module. Types reference only globals
21
+ * available in the checker's loaded lib surface plus the `__NodeFs*` aliases
22
+ * emitted by the module's `supportDecls`.
23
+ */
24
+ decls: string;
25
+ /**
26
+ * Providers that can satisfy this member, as a function of the active target.
27
+ * A member is *satisfiable* under a target iff `providersFor(target)` is
28
+ * non-empty. Empty ⇒ deliberate "no provider" compile error.
29
+ */
30
+ providersFor: (target: CapabilityTarget) => NodeProvider[];
31
+ }
32
+ export interface NodeModuleCapability {
33
+ /** The bare module specifier, e.g. `node:fs`. */
34
+ module: string;
35
+ /**
36
+ * Shared declaration preamble (interfaces / type aliases) emitted ONCE before
37
+ * the member decls when at least one member of this module is imported.
38
+ */
39
+ supportDecls: string;
40
+ /** Capability entry per exported member. */
41
+ members: Map<string, NodeMemberCapability>;
42
+ }
43
+ export declare const FS_PATH_BASED_MEMBERS: readonly ["readFileSync", "readFile", "writeFile", "appendFileSync", "appendFile", "openSync", "open", "unlinkSync", "unlink", "mkdirSync", "mkdir", "readdirSync", "readdir", "statSync", "stat", "existsSync"];
44
+ /** Look up the capability entry for a `node:<mod>` specifier, if mapped. */
45
+ export declare function getModuleCapability(module: string): NodeModuleCapability | undefined;
46
+ /** Is `member` a known (mapped) member of `module`? */
47
+ export declare function isKnownMember(module: string, member: string): boolean;
48
+ /**
49
+ * Is `member` of `module` satisfiable under `target`? `false` for a member that
50
+ * is typed in `@types/node` but has no provider under the active target (the
51
+ * deliberate-error case). Returns `undefined` for an unknown member (caller
52
+ * decides — usually permissive).
53
+ */
54
+ export declare function isMemberSatisfiable(module: string, member: string, target: CapabilityTarget): boolean | undefined;
55
+ /**
56
+ * Build the `.d.ts` body lines for a `node:<mod>` module, scoped to the
57
+ * `imported` member names. Emits the module's support decls once, then a
58
+ * faithful (overloaded) declaration per imported member that the map knows,
59
+ * falling back to permissive `any` for members outside the map. Returns
60
+ * `undefined` if the module is not in the capability map (caller falls back to
61
+ * the permissive generic module shape).
62
+ */
63
+ export declare function buildModuleDecls(module: string, imported: Iterable<string>): string[] | undefined;
@@ -0,0 +1,84 @@
1
+ import { ts } from '../ts-api.js';
2
+ import { ValType } from '../ir/types.js';
3
+ export declare function mapTsTypeToWasm(type: ts.Type, checker: ts.TypeChecker, fast?: boolean): ValType;
4
+ /** Check if a type is an externally declared class (declare class / declare var with constructor) */
5
+ export declare function isExternalDeclaredClass(type: ts.Type, checker?: ts.TypeChecker): boolean;
6
+ /** Check if a ts.Type represents void */
7
+ export declare function isVoidType(type: ts.Type): boolean;
8
+ /**
9
+ * Resolve the Wasm type of a destructuring binding element's local (#821).
10
+ *
11
+ * For `{ s: t = counter() }` where `counter()` returns `void`, TS infers `t`'s
12
+ * type as `void` (or `void | undefined`) — its only evidence is the default
13
+ * initializer. `resolveWasmType` then maps that to `i32`, so the *actual*
14
+ * property value (`null`/`0`/`false`/`''`, an externref) gets coerced into an
15
+ * i32 local and is destroyed — the spec requires the present, non-`undefined`
16
+ * value to be preserved and the default skipped (§13.3.3.6/§13.3.3.7).
17
+ *
18
+ * When an element has a default initializer AND the resolved type is the
19
+ * void/undefined sentinel, the local must be `externref` so it can faithfully
20
+ * hold whatever real value flows in. `resolve` is the caller's
21
+ * `resolveWasmType(ctx, tsType)` (passed in to avoid a circular import).
22
+ */
23
+ export declare function resolveBindingElementType(element: ts.BindingElement, tsType: ts.Type, resolve: (t: ts.Type) => ValType): ValType;
24
+ /** Check if a ts.Type represents bigint */
25
+ export declare function isBigIntType(type: ts.Type): boolean;
26
+ /** Check if a ts.Type represents number */
27
+ export declare function isNumberType(type: ts.Type): boolean;
28
+ export type NullablePrimitiveKind = "number" | "boolean" | "string" | "bigint";
29
+ export interface NullablePrimitiveInfo {
30
+ primitiveKind: NullablePrimitiveKind;
31
+ hasNull: boolean;
32
+ hasUndefined: boolean;
33
+ }
34
+ /** Check if a type is a nullable primitive sentinel, e.g. number | null or boolean | undefined. */
35
+ export declare function getNullablePrimitiveInfo(type: ts.Type): NullablePrimitiveInfo | null;
36
+ export declare function isNullablePrimitiveType(type: ts.Type): boolean;
37
+ /** Check if a type is a nullable numeric sentinel, e.g. number | null or number | undefined. */
38
+ export declare function isNullableNumberType(type: ts.Type): boolean;
39
+ /** Check if a ts.Type represents boolean */
40
+ export declare function isBooleanType(type: ts.Type): boolean;
41
+ /** Check if a ts.Type represents string (including String wrapper object) */
42
+ export declare function isStringType(type: ts.Type): boolean;
43
+ /** Check if a ts.Type represents the Number wrapper object (e.g. `new Number(1)`) */
44
+ export declare function isNumberWrapperType(type: ts.Type): boolean;
45
+ /** Check if a ts.Type represents the String wrapper object (e.g. `new String("x")`) */
46
+ export declare function isStringWrapperType(type: ts.Type): boolean;
47
+ /** Check if a ts.Type represents the Boolean wrapper object (e.g. `new Boolean(false)`) */
48
+ export declare function isBooleanWrapperType(type: ts.Type): boolean;
49
+ /**
50
+ * Check if a ts.Type is any of Number/String/Boolean wrapper object types (#1111).
51
+ * These are JS objects (typeof x === "object") even though they wrap primitives.
52
+ * Used to route equality through JS host == / === with no numeric fallback,
53
+ * since wrappers have object identity semantics, not value semantics.
54
+ */
55
+ export declare function isWrapperObjectType(type: ts.Type): boolean;
56
+ /**
57
+ * Check if a ts.Type is a Symbol type.
58
+ */
59
+ export declare function isSymbolType(type: ts.Type): boolean;
60
+ /**
61
+ * Check if a ts.Type is Promise<T>.
62
+ * Returns true for the built-in Promise generic type.
63
+ */
64
+ export declare function isPromiseType(type: ts.Type): boolean;
65
+ /**
66
+ * Check if a ts.Type is Generator<T>, Iterator<T>, or IterableIterator<T>.
67
+ * Returns true for any of the built-in generator/iterator types.
68
+ */
69
+ export declare function isGeneratorType(type: ts.Type): boolean;
70
+ /**
71
+ * Check if a ts.Type is IteratorResult<T> (the return type of .next()).
72
+ */
73
+ export declare function isIteratorResultType(type: ts.Type): boolean;
74
+ /**
75
+ * Unwrap Promise<T> to T. If the type is not a Promise, returns the type unchanged.
76
+ * Used to extract the inner type of async function return types.
77
+ */
78
+ export declare function unwrapPromiseType(type: ts.Type, checker: ts.TypeChecker): ts.Type;
79
+ /**
80
+ * Check if a ts.Type is a heterogeneous union (e.g. number | string)
81
+ * that requires externref boxing. Returns false for T | null/undefined unions
82
+ * where the non-nullish types all map to the same Wasm kind.
83
+ */
84
+ export declare function isHeterogeneousUnion(type: ts.Type, checker: ts.TypeChecker, fast?: boolean): boolean;
@@ -0,0 +1,19 @@
1
+ import { PositionMap } from './position-map.js';
2
+ /**
3
+ * Rewrite top-level `const X = require('Y')` and `const { ... } = require('Y')` patterns
4
+ * to ESM `import` declarations.
5
+ *
6
+ * Returns the original source unchanged if no top-level require() calls are present.
7
+ */
8
+ export declare function rewriteCjsRequire(source: string): string;
9
+ /**
10
+ * #1928 — like {@link rewriteCjsRequire} but also returns a `PositionMap` from
11
+ * the rewritten output back to the input, so diagnostics computed against the
12
+ * rewritten source can report the user's original line numbers. `import`
13
+ * declarations can be longer (and multi-line) than the `const … = require(…)`
14
+ * they replace, shifting everything below.
15
+ */
16
+ export declare function rewriteCjsRequireWithMap(source: string): {
17
+ source: string;
18
+ positionMap: PositionMap;
19
+ };
package/dist/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};