@esportsplus/typescript 0.29.6 → 0.31.1

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 (129) hide show
  1. package/README.md +97 -3
  2. package/bin/tsc-alias +1 -1
  3. package/bin/tsc-lsp +3 -0
  4. package/build/cli/diagnostics.d.ts +8 -0
  5. package/build/cli/diagnostics.js +95 -0
  6. package/build/cli/tsc.d.ts +12 -2
  7. package/build/cli/tsc.js +343 -52
  8. package/build/compiler/ast.d.ts +7 -5
  9. package/build/compiler/ast.js +6 -6
  10. package/build/compiler/code.d.ts +5 -4
  11. package/build/compiler/code.js +12 -1
  12. package/build/compiler/coordinator.d.ts +16 -7
  13. package/build/compiler/coordinator.js +75 -41
  14. package/build/compiler/imports.d.ts +8 -3
  15. package/build/compiler/imports.js +34 -24
  16. package/build/compiler/index.d.ts +3 -0
  17. package/build/compiler/index.js +1 -0
  18. package/build/compiler/language-service.d.ts +36 -6
  19. package/build/compiler/language-service.js +252 -58
  20. package/build/compiler/plugins/index.d.ts +4 -2
  21. package/build/compiler/plugins/tsc.d.ts +1 -1
  22. package/build/compiler/plugins/vite.d.ts +6 -3
  23. package/build/compiler/plugins/vite.js +15 -8
  24. package/build/compiler/sourcemap.d.ts +52 -0
  25. package/build/compiler/sourcemap.js +265 -0
  26. package/build/compiler/types.d.ts +7 -6
  27. package/build/compiler/uid.d.ts +5 -2
  28. package/build/compiler/uid.js +33 -4
  29. package/build/index.d.ts +1 -1
  30. package/build/index.js +1 -1
  31. package/build/jsonc.d.ts +2 -0
  32. package/build/jsonc.js +85 -0
  33. package/build/lsp/bin.d.ts +1 -0
  34. package/build/lsp/bin.js +2 -0
  35. package/build/lsp/diagnostics.d.ts +10 -0
  36. package/build/lsp/diagnostics.js +69 -0
  37. package/build/lsp/index.d.ts +2 -0
  38. package/build/lsp/index.js +2 -0
  39. package/build/lsp/server.d.ts +4 -0
  40. package/build/lsp/server.js +130 -0
  41. package/build/lsp/workspace.d.ts +14 -0
  42. package/build/lsp/workspace.js +46 -0
  43. package/build/probe/adapter.d.ts +14 -0
  44. package/build/probe/adapter.js +42 -0
  45. package/build/probe/async/channel.d.ts +4 -0
  46. package/build/probe/async/channel.js +560 -0
  47. package/build/probe/async/value.d.ts +9 -0
  48. package/build/probe/async/value.js +16 -0
  49. package/build/probe/channels.d.ts +4 -0
  50. package/build/probe/channels.js +16 -0
  51. package/build/probe/exceptions/channel.d.ts +5 -0
  52. package/build/probe/exceptions/channel.js +657 -0
  53. package/build/probe/exceptions/jsdoc.d.ts +8 -0
  54. package/build/probe/exceptions/jsdoc.js +34 -0
  55. package/build/probe/exceptions/value.d.ts +39 -0
  56. package/build/probe/exceptions/value.js +158 -0
  57. package/build/probe/kernel/analyze.d.ts +8 -0
  58. package/build/probe/kernel/analyze.js +68 -0
  59. package/build/probe/kernel/ast.d.ts +11 -0
  60. package/build/probe/kernel/ast.js +49 -0
  61. package/build/probe/kernel/config.d.ts +5 -0
  62. package/build/probe/kernel/config.js +209 -0
  63. package/build/probe/kernel/fixpoint.d.ts +6 -0
  64. package/build/probe/kernel/fixpoint.js +206 -0
  65. package/build/probe/kernel/format.d.ts +4 -0
  66. package/build/probe/kernel/format.js +32 -0
  67. package/build/probe/kernel/graph.d.ts +4 -0
  68. package/build/probe/kernel/graph.js +507 -0
  69. package/build/probe/kernel/ids.d.ts +8 -0
  70. package/build/probe/kernel/ids.js +66 -0
  71. package/build/probe/kernel/program.d.ts +8 -0
  72. package/build/probe/kernel/program.js +13 -0
  73. package/build/probe/kernel/types.d.ts +134 -0
  74. package/build/probe/kernel/types.js +1 -0
  75. package/build/probe/overlay/base/async.jsonc +13 -0
  76. package/build/probe/overlay/base/exceptions.jsonc +54 -0
  77. package/build/probe/overlay/base/resources.jsonc +57 -0
  78. package/build/probe/overlay/load.d.ts +18 -0
  79. package/build/probe/overlay/load.js +302 -0
  80. package/build/probe/overlay/presets/express.jsonc +25 -0
  81. package/build/probe/overlay/presets/node.jsonc +17 -0
  82. package/build/probe/resources/channel.d.ts +4 -0
  83. package/build/probe/resources/channel.js +798 -0
  84. package/build/probe/resources/value.d.ts +9 -0
  85. package/build/probe/resources/value.js +36 -0
  86. package/build/ts.d.ts +3 -0
  87. package/build/ts.js +3 -0
  88. package/build/tsconfig.d.ts +2 -0
  89. package/build/tsconfig.js +150 -0
  90. package/package.json +29 -9
  91. package/tsconfig.base.json +19 -0
  92. package/tsconfig.dev.json +13 -0
  93. package/tsconfig.package.json +4 -1
  94. package/.claude/skills/code-audit/registry-typescript.json +0 -326
  95. package/.editorconfig +0 -9
  96. package/.gitattributes +0 -2
  97. package/.github/dependabot.yml +0 -25
  98. package/.github/workflows/bump.yml +0 -27
  99. package/.github/workflows/dependabot.yml +0 -58
  100. package/.github/workflows/publish.yml +0 -42
  101. package/.github/workflows/templates/bump.yml +0 -9
  102. package/.github/workflows/templates/dependabot.yml +0 -12
  103. package/.github/workflows/templates/publish.yml +0 -16
  104. package/pnpm-workspace.yaml +0 -6
  105. package/src/cli/tsc.ts +0 -235
  106. package/src/compiler/ast.ts +0 -60
  107. package/src/compiler/code.ts +0 -27
  108. package/src/compiler/coordinator.ts +0 -284
  109. package/src/compiler/imports.ts +0 -185
  110. package/src/compiler/index.ts +0 -7
  111. package/src/compiler/language-service.ts +0 -121
  112. package/src/compiler/plugins/index.ts +0 -5
  113. package/src/compiler/plugins/tsc.ts +0 -6
  114. package/src/compiler/plugins/vite.ts +0 -91
  115. package/src/compiler/types.ts +0 -83
  116. package/src/compiler/uid.ts +0 -10
  117. package/src/constants.ts +0 -4
  118. package/src/index.ts +0 -1
  119. package/tests/cli/tsc.test.ts +0 -155
  120. package/tests/compiler/ast.test.ts +0 -131
  121. package/tests/compiler/code.test.ts +0 -73
  122. package/tests/compiler/coordinator.bench.ts +0 -101
  123. package/tests/compiler/coordinator.test.ts +0 -872
  124. package/tests/compiler/imports.test.ts +0 -167
  125. package/tests/compiler/language-service.test.ts +0 -90
  126. package/tests/compiler/plugins.test.ts +0 -172
  127. package/tests/compiler/uid.test.ts +0 -70
  128. package/tsconfig.json +0 -3
  129. package/vitest.config.ts +0 -14
@@ -1,6 +1,8 @@
1
- import { ts } from '../index.js';
1
+ import { isImportDeclaration } from 'typescript/unstable/ast/is';
2
2
  import imports from './imports.js';
3
3
  import languageService from './language-service.js';
4
+ import sourcemap from './sourcemap.js';
5
+ import uid from './uid.js';
4
6
  function applyImports(code, file, intents) {
5
7
  let merged = new Map();
6
8
  for (let i = 0, n = intents.length; i < n; i++) {
@@ -24,33 +26,35 @@ function applyImports(code, file, intents) {
24
26
  });
25
27
  }
26
28
  }
27
- let keys = [...merged.keys()];
29
+ let edits = [], keys = [...merged.keys()];
28
30
  for (let i = 0, n = keys.length; i < n; i++) {
29
- code = modify(code, file, keys[i], merged.get(keys[i]));
30
- if (i < n - 1) {
31
- file = ts.createSourceFile(file.fileName, code, file.languageVersion, true);
32
- }
31
+ let result = modify(code, file, keys[i], merged.get(keys[i]));
32
+ edits.push(...result.edits);
33
+ }
34
+ if (edits.length === 0) {
35
+ return { batches: [], code };
33
36
  }
34
- return code;
37
+ return { batches: [{ before: code, edits }], code: replaceReverse(code, edits) };
35
38
  }
36
39
  function applyIntents(code, file, intents) {
37
40
  if (intents.length === 0) {
38
- return code;
41
+ return { code, edits: [] };
39
42
  }
40
- return replaceReverse(code, intents.map(intent => ({
43
+ let edits = intents.map(intent => ({
41
44
  end: intent.node.end,
42
45
  newText: intent.generate(file),
43
46
  start: intent.node.getStart(file)
44
- })));
47
+ }));
48
+ return { code: replaceReverse(code, edits), edits };
45
49
  }
46
50
  function applyPrepend(code, file, prepend) {
47
51
  if (prepend.length === 0) {
48
- return code;
52
+ return { code, edits: [] };
49
53
  }
50
54
  let position = 0;
51
55
  for (let i = 0, n = file.statements.length; i < n; i++) {
52
56
  let stmt = file.statements[i];
53
- if (ts.isImportDeclaration(stmt)) {
57
+ if (isImportDeclaration(stmt)) {
54
58
  position = stmt.end;
55
59
  }
56
60
  else {
@@ -58,9 +62,11 @@ function applyPrepend(code, file, prepend) {
58
62
  }
59
63
  }
60
64
  if (position === 0) {
61
- return prepend.join('\n') + '\n' + code;
65
+ let newText = prepend.join('\n') + '\n';
66
+ return { code: newText + code, edits: [{ end: 0, newText, start: 0 }] };
62
67
  }
63
- return code.slice(0, position) + '\n' + prepend.join('\n') + '\n' + code.slice(position);
68
+ let newText = '\n' + prepend.join('\n') + '\n';
69
+ return { code: code.slice(0, position) + newText + code.slice(position), edits: [{ end: position, newText, start: position }] };
64
70
  }
65
71
  function hasPattern(code, patterns) {
66
72
  for (let i = 0, n = patterns.length; i < n; i++) {
@@ -72,9 +78,12 @@ function hasPattern(code, patterns) {
72
78
  }
73
79
  function modify(code, file, pkg, options) {
74
80
  if (!options.add && !options.namespace && !options.remove) {
75
- return code;
81
+ return { code, edits: [] };
76
82
  }
77
83
  let { namespace } = options, add = options.add ? new Set(options.add) : null, found = imports.all(file, pkg);
84
+ if (namespace && !add && !options.remove && found.some(info => info.namespace === namespace)) {
85
+ return { code, edits: [] };
86
+ }
78
87
  if (found.length === 0) {
79
88
  let statements = [];
80
89
  if (namespace) {
@@ -84,11 +93,12 @@ function modify(code, file, pkg, options) {
84
93
  statements.push(`import { ${[...add].sort().join(', ')} } from '${pkg}';`);
85
94
  }
86
95
  if (statements.length === 0) {
87
- return code;
96
+ return { code, edits: [] };
88
97
  }
89
- return statements.join('\n') + '\n' + code;
98
+ let newText = statements.join('\n') + '\n';
99
+ return { code: newText + code, edits: [{ end: 0, newText, start: 0 }] };
90
100
  }
91
- let remove = options.remove ? new Set(options.remove) : null, specifiers = new Set();
101
+ let remove = options.remove ? new Set(options.remove) : null, specifiers = new Set(), nonNamespace = found.filter(info => !info.namespace), existingNamespace = found.some(info => info.namespace === namespace), defaultImport = nonNamespace.find(info => info.defaultName), target = defaultImport ?? nonNamespace[0];
92
102
  for (let i = 0, n = found.length; i < n; i++) {
93
103
  for (let [name, alias] of found[i].specifiers) {
94
104
  if (!remove || (!remove.has(name) && !remove.has(alias))) {
@@ -103,21 +113,35 @@ function modify(code, file, pkg, options) {
103
113
  }
104
114
  }
105
115
  let statements = [];
106
- if (namespace) {
116
+ if (namespace && !existingNamespace) {
107
117
  statements.push(`import * as ${namespace} from '${pkg}';`);
108
118
  }
109
- if (specifiers.size > 0) {
119
+ if (target) {
120
+ let named = specifiers.size > 0 ? `{ ${[...specifiers].sort().join(', ')} }` : '', defaultName = target.defaultName, clause = defaultName && named ? `${defaultName}, ${named}` : defaultName ?? named;
121
+ if (clause) {
122
+ statements.push(`import ${clause} from '${pkg}';`);
123
+ }
124
+ }
125
+ else if (specifiers.size > 0) {
110
126
  statements.push(`import { ${[...specifiers].sort().join(', ')} } from '${pkg}';`);
111
127
  }
112
128
  let replacements = [];
113
129
  for (let i = 0, n = found.length; i < n; i++) {
130
+ let info = found[i];
131
+ if (info.namespace) {
132
+ continue;
133
+ }
114
134
  replacements.push({
115
- end: found[i].end,
116
- newText: i === 0 ? statements.join('\n') : '',
117
- start: found[i].start
135
+ end: info.end,
136
+ newText: info === target ? statements.join('\n') : info.defaultName ? `import ${info.defaultName} from '${pkg}';` : '',
137
+ start: info.start
118
138
  });
119
139
  }
120
- return replaceReverse(code, replacements);
140
+ if (!target && statements.length > 0) {
141
+ let first = found[0];
142
+ replacements.push({ end: first.start, newText: statements.join('\n') + '\n', start: first.start });
143
+ }
144
+ return { code: replaceReverse(code, replacements), edits: replacements };
121
145
  }
122
146
  function replaceReverse(code, replacements) {
123
147
  if (replacements.length === 0) {
@@ -138,53 +162,63 @@ function replaceReverse(code, replacements) {
138
162
  }
139
163
  return parts.reverse().join('');
140
164
  }
141
- const transform = (plugins, code, file, program, root, shared) => {
165
+ const transform = (plugins, code, file, project, root, shared) => {
142
166
  if (plugins.length === 0) {
143
- return { changed: false, code, sourceFile: file };
167
+ return { changed: false, code, map: { generations: [] } };
144
168
  }
145
- let changed = false, currentCode = code, currentFile = file, currentProgram = program, fileName = file.fileName, last = plugins.length - 1;
169
+ uid.scope(root, file.fileName, code);
170
+ let changed = false, currentCode = code, currentFile = file, currentProject = project, fileName = file.fileName, generations = [], last = plugins.length - 1;
146
171
  for (let i = 0, n = plugins.length; i < n; i++) {
147
172
  let plugin = plugins[i];
148
173
  if (plugin.patterns && !hasPattern(currentCode, plugin.patterns)) {
149
174
  continue;
150
175
  }
151
176
  let { imports, prepend, replacements } = plugin.transform({
152
- checker: currentProgram.getTypeChecker(),
177
+ checker: currentProject.checker,
153
178
  code: currentCode,
154
- program: currentProgram,
179
+ program: currentProject.program,
155
180
  shared,
156
181
  sourceFile: currentFile
157
182
  }), pluginChanged = false;
158
183
  if (replacements?.length) {
159
- currentCode = applyIntents(currentCode, currentFile, replacements);
184
+ let before = currentCode, result = applyIntents(currentCode, currentFile, replacements);
185
+ if (result.edits.length > 0) {
186
+ generations.push(sourcemap.buildGeneration(before, result.edits));
187
+ }
188
+ currentCode = result.code;
160
189
  pluginChanged = true;
161
190
  }
162
191
  if (prepend?.length) {
163
192
  if (pluginChanged) {
164
- currentFile = ts.createSourceFile(fileName, currentCode, file.languageVersion, true);
193
+ currentFile = languageService.parse(fileName, currentCode);
165
194
  }
166
- currentCode = applyPrepend(currentCode, currentFile, prepend);
195
+ let before = currentCode, result = applyPrepend(currentCode, currentFile, prepend);
196
+ if (result.edits.length > 0) {
197
+ generations.push(sourcemap.buildGeneration(before, result.edits));
198
+ }
199
+ currentCode = result.code;
167
200
  pluginChanged = true;
168
201
  }
169
202
  if (imports?.length) {
170
203
  if (pluginChanged) {
171
- currentFile = ts.createSourceFile(fileName, currentCode, file.languageVersion, true);
204
+ currentFile = languageService.parse(fileName, currentCode);
205
+ }
206
+ let result = applyImports(currentCode, currentFile, imports);
207
+ for (let j = 0, m = result.batches.length; j < m; j++) {
208
+ generations.push(sourcemap.buildGeneration(result.batches[j].before, result.batches[j].edits));
172
209
  }
173
- currentCode = applyImports(currentCode, currentFile, imports);
210
+ currentCode = result.code;
174
211
  pluginChanged = true;
175
212
  }
176
213
  if (pluginChanged) {
177
214
  changed = true;
178
215
  if (i < last) {
179
- currentProgram = languageService.update(root, fileName, currentCode);
180
- currentFile = currentProgram.getSourceFile(fileName) ||
181
- ts.createSourceFile(fileName, currentCode, file.languageVersion, true);
182
- }
183
- else {
184
- currentFile = ts.createSourceFile(fileName, currentCode, file.languageVersion, true);
216
+ currentProject = languageService.update(project.configPath ?? languageService.findConfig(root) ?? root, fileName, currentCode);
217
+ currentFile = currentProject.program.getSourceFile(fileName) ??
218
+ languageService.parse(fileName, currentCode);
185
219
  }
186
220
  }
187
221
  }
188
- return { changed, code: currentCode, sourceFile: currentFile };
222
+ return { changed, code: currentCode, map: { generations } };
189
223
  };
190
224
  export default { transform };
@@ -1,6 +1,9 @@
1
- import { ts } from '../index.js';
1
+ import type { Node, SourceFile } from 'typescript/unstable/ast';
2
+ import type { Checker } from 'typescript/unstable/sync';
2
3
  type ImportInfo = {
4
+ defaultName?: string;
3
5
  end: number;
6
+ namespace?: string;
4
7
  specifiers: Map<string, string>;
5
8
  typeOnly: Set<string>;
6
9
  start: number;
@@ -10,9 +13,11 @@ type ModifyOptions = {
10
13
  namespace?: string;
11
14
  remove?: Iterable<string>;
12
15
  };
16
+ declare const all: (file: SourceFile, pkg: string) => ImportInfo[];
17
+ declare const includes: (checker: Checker, node: Node, pkg: string, symbolName?: string) => boolean;
13
18
  declare const _default: {
14
- all: (file: ts.SourceFile, pkg: string) => ImportInfo[];
15
- includes: (checker: ts.TypeChecker, node: ts.Node, pkg: string, symbolName?: string) => boolean;
19
+ all: typeof all;
20
+ includes: typeof includes;
16
21
  };
17
22
  export default _default;
18
23
  export type { ImportInfo, ModifyOptions };
@@ -1,4 +1,6 @@
1
- import { ts } from '../index.js';
1
+ import { SyntaxKind } from 'typescript/unstable/ast';
2
+ import { isIdentifier, isImportDeclaration, isNamedImports, isNamespaceImport, isStringLiteral } from 'typescript/unstable/ast/is';
3
+ import { SymbolFlags } from 'typescript/unstable/sync';
2
4
  let cache = new WeakMap();
3
5
  function fileNameMatchesPackage(fileName, pkg) {
4
6
  let normalized = fileName.replace(/\\/g, '/'), marker = `/node_modules/${pkg}/`;
@@ -8,15 +10,15 @@ const all = (file, pkg) => {
8
10
  let imports = [];
9
11
  for (let i = 0, n = file.statements.length; i < n; i++) {
10
12
  let stmt = file.statements[i];
11
- if (!ts.isImportDeclaration(stmt)) {
13
+ if (!isImportDeclaration(stmt)) {
12
14
  continue;
13
15
  }
14
16
  let moduleSpecifier = stmt.moduleSpecifier;
15
- if (!ts.isStringLiteral(moduleSpecifier) || moduleSpecifier.text !== pkg) {
17
+ if (!isStringLiteral(moduleSpecifier) || moduleSpecifier.text !== pkg) {
16
18
  continue;
17
19
  }
18
- let bindings = stmt.importClause?.namedBindings, declTypeOnly = stmt.importClause?.isTypeOnly ?? false, specifiers = new Map(), typeOnly = new Set();
19
- if (bindings && ts.isNamedImports(bindings)) {
20
+ let bindings = stmt.importClause?.namedBindings, declTypeOnly = stmt.importClause?.phaseModifier === SyntaxKind.TypeKeyword, specifiers = new Map(), typeOnly = new Set();
21
+ if (bindings && isNamedImports(bindings)) {
20
22
  for (let j = 0, m = bindings.elements.length; j < m; j++) {
21
23
  let element = bindings.elements[j], name = element.name.text, propertyName = element.propertyName?.text || name;
22
24
  specifiers.set(propertyName, name);
@@ -25,12 +27,19 @@ const all = (file, pkg) => {
25
27
  }
26
28
  }
27
29
  }
28
- imports.push({ end: stmt.end, specifiers, start: stmt.getStart(file), typeOnly });
30
+ imports.push({
31
+ defaultName: stmt.importClause?.name?.text,
32
+ end: stmt.end,
33
+ namespace: bindings && isNamespaceImport(bindings) ? bindings.name.text : undefined,
34
+ specifiers,
35
+ start: stmt.getStart(file),
36
+ typeOnly
37
+ });
29
38
  }
30
39
  return imports;
31
40
  };
32
41
  const includes = (checker, node, pkg, symbolName) => {
33
- if (!ts.isIdentifier(node)) {
42
+ if (!isIdentifier(node)) {
34
43
  return false;
35
44
  }
36
45
  if (symbolName && node.text !== symbolName) {
@@ -55,54 +64,55 @@ const includes = (checker, node, pkg, symbolName) => {
55
64
  if (names.has(node.text)) {
56
65
  let symbol = checker.getSymbolAtLocation(node);
57
66
  if (symbol) {
58
- let declarations = symbol.getDeclarations();
67
+ let declarations = symbol.declarations;
59
68
  if (declarations && declarations.length > 0) {
60
69
  for (let i = 0, n = declarations.length; i < n; i++) {
61
- let decl = declarations[i];
62
- if (ts.isImportSpecifier(decl)) {
63
- let importDecl = decl.parent?.parent?.parent;
64
- if (importDecl && ts.isImportDeclaration(importDecl) && ts.isStringLiteral(importDecl.moduleSpecifier)) {
65
- if (importDecl.moduleSpecifier.text === pkg) {
66
- return true;
70
+ let handle = declarations[i];
71
+ if (handle.kind === SyntaxKind.ImportSpecifier) {
72
+ let decl = handle.resolve();
73
+ if (decl) {
74
+ let importDecl = decl.parent?.parent?.parent;
75
+ if (importDecl && isImportDeclaration(importDecl) && isStringLiteral(importDecl.moduleSpecifier)) {
76
+ if (importDecl.moduleSpecifier.text === pkg) {
77
+ return true;
78
+ }
67
79
  }
68
80
  }
69
81
  }
70
- if (fileNameMatchesPackage(decl.getSourceFile().fileName, pkg)) {
82
+ if (fileNameMatchesPackage(handle.path, pkg)) {
71
83
  return true;
72
84
  }
73
85
  }
74
86
  }
75
87
  }
76
- return true;
88
+ return false;
77
89
  }
78
90
  let symbol = checker.getSymbolAtLocation(node);
79
91
  if (!symbol) {
80
92
  return false;
81
93
  }
82
- let declarations = symbol.getDeclarations();
94
+ let declarations = symbol.declarations;
83
95
  if (declarations && declarations.length > 0) {
84
96
  for (let i = 0, n = declarations.length; i < n; i++) {
85
- let decl = declarations[i];
86
- if (fileNameMatchesPackage(decl.getSourceFile().fileName, pkg)) {
97
+ let handle = declarations[i];
98
+ if (fileNameMatchesPackage(handle.path, pkg)) {
87
99
  return true;
88
100
  }
89
101
  }
90
102
  }
91
- try {
103
+ if ((symbol.flags & SymbolFlags.Alias) !== 0) {
92
104
  let aliased = checker.getAliasedSymbol(symbol);
93
105
  if (aliased && aliased !== symbol) {
94
- let aliasedDecls = aliased.getDeclarations();
106
+ let aliasedDecls = aliased.declarations;
95
107
  if (aliasedDecls) {
96
108
  for (let i = 0, n = aliasedDecls.length; i < n; i++) {
97
- if (fileNameMatchesPackage(aliasedDecls[i].getSourceFile().fileName, pkg)) {
109
+ if (fileNameMatchesPackage(aliasedDecls[i].path, pkg)) {
98
110
  return true;
99
111
  }
100
112
  }
101
113
  }
102
114
  }
103
115
  }
104
- catch {
105
- }
106
116
  return false;
107
117
  };
108
118
  export default { all, includes };
@@ -2,6 +2,9 @@ export { default as ast } from './ast.js';
2
2
  export { default as code } from './code.js';
3
3
  export { default as coordinator } from './coordinator.js';
4
4
  export { default as imports } from './imports.js';
5
+ export { default as languageService } from './language-service.js';
5
6
  export { default as plugin } from './plugins/index.js';
6
7
  export { default as uid } from './uid.js';
8
+ export type { OffsetAnchor, PositionMapping, SourceMapV3 } from './sourcemap.js';
9
+ export type { ScratchResult, UpdateResult } from './language-service.js';
7
10
  export type * from './types.js';
@@ -2,5 +2,6 @@ export { default as ast } from './ast.js';
2
2
  export { default as code } from './code.js';
3
3
  export { default as coordinator } from './coordinator.js';
4
4
  export { default as imports } from './imports.js';
5
+ export { default as languageService } from './language-service.js';
5
6
  export { default as plugin } from './plugins/index.js';
6
7
  export { default as uid } from './uid.js';
@@ -1,9 +1,39 @@
1
- import { ts } from '../index.js';
2
- declare const invalidate: (root: string, fileName: string) => void;
3
- declare const update: (root: string, fileName: string, content: string) => ts.Program;
1
+ import type { SourceFile } from 'typescript/unstable/ast';
2
+ import type { FileSystem } from 'typescript/unstable/fs';
3
+ import { API, type Checker, type Program, type Project, type Snapshot } from 'typescript/unstable/sync';
4
+ type ScratchResult = {
5
+ checker: Checker;
6
+ program: Program;
7
+ sourceFile: SourceFile;
8
+ };
9
+ type UpdateResult = {
10
+ checker: Checker;
11
+ program: Program;
12
+ };
13
+ type OpenProject = {
14
+ api: API;
15
+ dispose: () => void;
16
+ project: Project;
17
+ snapshot: Snapshot;
18
+ };
19
+ declare function open(configPath: string, overlay?: FileSystem): OpenProject;
20
+ declare const dispose: (root?: string) => void;
21
+ declare const findConfig: (startDir: string) => string | null;
22
+ declare const invalidate: (configFileName: string, fileName: string) => void;
23
+ declare const parse: (fileName: string, content: string) => SourceFile;
24
+ declare const scratch: (fileName: string, content: string) => ScratchResult;
25
+ declare const update: (configFileName: string, fileName: string, content: string) => UpdateResult;
26
+ declare const updateMany: (configFileName: string, updates: Map<string, string>) => UpdateResult;
4
27
  declare const _default: {
5
- invalidate: (root: string, fileName: string) => void;
6
- update: (root: string, fileName: string, content: string) => ts.Program;
28
+ dispose: typeof dispose;
29
+ findConfig: typeof findConfig;
30
+ invalidate: typeof invalidate;
31
+ open: typeof open;
32
+ parse: typeof parse;
33
+ scratch: typeof scratch;
34
+ update: typeof update;
35
+ updateMany: typeof updateMany;
7
36
  };
8
37
  export default _default;
9
- export { invalidate, update };
38
+ export { dispose, findConfig, invalidate, open, parse, scratch, update, updateMany };
39
+ export type { ScratchResult, UpdateResult };