@esportsplus/typescript 0.29.5 → 0.31.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 (69) hide show
  1. package/README.md +11 -3
  2. package/bin/tsc-alias +1 -1
  3. package/build/cli/diagnostics.d.ts +4 -0
  4. package/build/cli/diagnostics.js +90 -0
  5. package/build/cli/tsc.d.ts +10 -2
  6. package/build/cli/tsc.js +352 -51
  7. package/build/compiler/ast.d.ts +7 -5
  8. package/build/compiler/ast.js +6 -6
  9. package/build/compiler/code.d.ts +5 -4
  10. package/build/compiler/code.js +12 -1
  11. package/build/compiler/coordinator.d.ts +17 -7
  12. package/build/compiler/coordinator.js +56 -32
  13. package/build/compiler/imports.d.ts +7 -3
  14. package/build/compiler/imports.js +30 -24
  15. package/build/compiler/index.d.ts +3 -0
  16. package/build/compiler/index.js +1 -0
  17. package/build/compiler/language-service.d.ts +24 -5
  18. package/build/compiler/language-service.js +215 -53
  19. package/build/compiler/plugins/index.d.ts +4 -2
  20. package/build/compiler/plugins/tsc.d.ts +1 -1
  21. package/build/compiler/plugins/vite.d.ts +6 -3
  22. package/build/compiler/plugins/vite.js +12 -7
  23. package/build/compiler/sourcemap.d.ts +50 -0
  24. package/build/compiler/sourcemap.js +247 -0
  25. package/build/compiler/types.d.ts +7 -6
  26. package/build/compiler/uid.d.ts +5 -2
  27. package/build/compiler/uid.js +33 -4
  28. package/build/index.d.ts +1 -1
  29. package/build/index.js +1 -1
  30. package/build/ts.d.ts +3 -0
  31. package/build/ts.js +3 -0
  32. package/package.json +22 -8
  33. package/tsconfig.dev.json +13 -0
  34. package/tsconfig.package.json +4 -1
  35. package/.claude/skills/code-audit/registry-typescript.json +0 -326
  36. package/.editorconfig +0 -9
  37. package/.gitattributes +0 -2
  38. package/.github/dependabot.yml +0 -25
  39. package/.github/workflows/bump.yml +0 -27
  40. package/.github/workflows/dependabot.yml +0 -58
  41. package/.github/workflows/publish.yml +0 -42
  42. package/.github/workflows/templates/bump.yml +0 -9
  43. package/.github/workflows/templates/dependabot.yml +0 -12
  44. package/.github/workflows/templates/publish.yml +0 -16
  45. package/src/cli/tsc.ts +0 -235
  46. package/src/compiler/ast.ts +0 -60
  47. package/src/compiler/code.ts +0 -27
  48. package/src/compiler/coordinator.ts +0 -279
  49. package/src/compiler/imports.ts +0 -175
  50. package/src/compiler/index.ts +0 -7
  51. package/src/compiler/language-service.ts +0 -121
  52. package/src/compiler/plugins/index.ts +0 -5
  53. package/src/compiler/plugins/tsc.ts +0 -6
  54. package/src/compiler/plugins/vite.ts +0 -91
  55. package/src/compiler/types.ts +0 -83
  56. package/src/compiler/uid.ts +0 -10
  57. package/src/constants.ts +0 -4
  58. package/src/index.ts +0 -1
  59. package/tests/cli/tsc.test.ts +0 -155
  60. package/tests/compiler/ast.test.ts +0 -131
  61. package/tests/compiler/code.test.ts +0 -73
  62. package/tests/compiler/coordinator.bench.ts +0 -101
  63. package/tests/compiler/coordinator.test.ts +0 -855
  64. package/tests/compiler/imports.test.ts +0 -167
  65. package/tests/compiler/language-service.test.ts +0 -90
  66. package/tests/compiler/plugins.test.ts +0 -172
  67. package/tests/compiler/uid.test.ts +0 -70
  68. package/tsconfig.json +0 -3
  69. package/vitest.config.ts +0 -14
@@ -1,10 +1,10 @@
1
- import { ts } from '../index.js';
1
+ import { isIdentifier, isPropertyAccessExpression } from 'typescript/unstable/ast/is';
2
2
  const expression = {
3
3
  name: (node) => {
4
- if (ts.isIdentifier(node)) {
4
+ if (isIdentifier(node)) {
5
5
  return node.text;
6
6
  }
7
- if (ts.isPropertyAccessExpression(node)) {
7
+ if (isPropertyAccessExpression(node)) {
8
8
  return property.path(node);
9
9
  }
10
10
  return null;
@@ -22,11 +22,11 @@ const inRange = (ranges, start, end) => {
22
22
  const property = {
23
23
  path: (node) => {
24
24
  let current = node, parts = [];
25
- while (ts.isPropertyAccessExpression(current)) {
25
+ while (isPropertyAccessExpression(current)) {
26
26
  parts.push(current.name.text);
27
27
  current = current.expression;
28
28
  }
29
- if (ts.isIdentifier(current)) {
29
+ if (isIdentifier(current)) {
30
30
  parts.push(current.text);
31
31
  return parts.reverse().join('.');
32
32
  }
@@ -37,6 +37,6 @@ const test = (node, fn) => {
37
37
  if (fn(node)) {
38
38
  return true;
39
39
  }
40
- return !!ts.forEachChild(node, child => test(child, fn) || undefined);
40
+ return !!node.forEachChild(child => test(child, fn) || undefined);
41
41
  };
42
42
  export default { expression, inRange, property, test };
@@ -1,5 +1,6 @@
1
- declare const code: {
2
- (literals: TemplateStringsArray, ...values: unknown[]): string;
3
- escape(str: string): string;
4
- };
1
+ declare function code(literals: TemplateStringsArray, ...values: unknown[]): string;
2
+ declare namespace code {
3
+ var _a: (str: string) => string;
4
+ export { _a as escape };
5
+ }
5
6
  export default code;
@@ -1,3 +1,8 @@
1
+ const BACKSLASH_REGEX = /\\/g;
2
+ const CR_REGEX = /\r/g;
3
+ const LINE_SEPARATOR_REGEX = /\u2028/g;
4
+ const NEWLINE_REGEX = /\n/g;
5
+ const PARAGRAPH_SEPARATOR_REGEX = /\u2029/g;
1
6
  const SINGLE_QUOTE_REGEX = /'/g;
2
7
  const code = (literals, ...values) => {
3
8
  let buffer = '';
@@ -12,6 +17,12 @@ const code = (literals, ...values) => {
12
17
  return buffer;
13
18
  };
14
19
  code.escape = (str) => {
15
- return str.replace(SINGLE_QUOTE_REGEX, "\\'");
20
+ return str
21
+ .replace(BACKSLASH_REGEX, '\\\\')
22
+ .replace(SINGLE_QUOTE_REGEX, "\\'")
23
+ .replace(NEWLINE_REGEX, '\\n')
24
+ .replace(CR_REGEX, '\\r')
25
+ .replace(LINE_SEPARATOR_REGEX, '\\u2028')
26
+ .replace(PARAGRAPH_SEPARATOR_REGEX, '\\u2029');
16
27
  };
17
28
  export default code;
@@ -1,16 +1,26 @@
1
+ import type { SourceFile } from 'typescript/unstable/ast';
2
+ import type { Checker, Program } from 'typescript/unstable/sync';
1
3
  import type { Plugin, SharedContext } from './types.js';
2
- import { ts } from '../index.js';
4
+ import type { OffsetAnchor, PositionMapping } from './sourcemap.js';
3
5
  type CoordinatorResult = {
4
6
  changed: boolean;
5
7
  code: string;
6
- sourceFile: ts.SourceFile;
8
+ map: PositionMapping;
9
+ sourceFile: SourceFile;
7
10
  };
8
- declare const _default: {
9
- transform: (plugins: Plugin[], code: string, file: ts.SourceFile, program: ts.Program, root: string, shared: SharedContext) => {
10
- changed: boolean;
11
- code: string;
12
- sourceFile: ts.SourceFile;
11
+ declare const transform: (plugins: Plugin[], code: string, file: SourceFile, project: {
12
+ checker: Checker;
13
+ program: Program;
14
+ }, root: string, shared: SharedContext) => {
15
+ changed: boolean;
16
+ code: string;
17
+ map: {
18
+ generations: OffsetAnchor[][];
13
19
  };
20
+ sourceFile: SourceFile;
21
+ };
22
+ declare const _default: {
23
+ transform: typeof transform;
14
24
  };
15
25
  export default _default;
16
26
  export type { CoordinatorResult };
@@ -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,38 @@ function applyImports(code, file, intents) {
24
26
  });
25
27
  }
26
28
  }
27
- let keys = [...merged.keys()];
29
+ let batches = [], 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]));
31
+ let before = code, result = modify(code, file, keys[i], merged.get(keys[i]));
32
+ code = result.code;
33
+ if (result.edits.length > 0) {
34
+ batches.push({ before, edits: result.edits });
35
+ }
30
36
  if (i < n - 1) {
31
- file = ts.createSourceFile(file.fileName, code, file.languageVersion, true);
37
+ file = languageService.parse(file.fileName, code);
32
38
  }
33
39
  }
34
- return code;
40
+ return { batches, code };
35
41
  }
36
42
  function applyIntents(code, file, intents) {
37
43
  if (intents.length === 0) {
38
- return code;
44
+ return { code, edits: [] };
39
45
  }
40
- return replaceReverse(code, intents.map(intent => ({
46
+ let edits = intents.map(intent => ({
41
47
  end: intent.node.end,
42
48
  newText: intent.generate(file),
43
49
  start: intent.node.getStart(file)
44
- })));
50
+ }));
51
+ return { code: replaceReverse(code, edits), edits };
45
52
  }
46
53
  function applyPrepend(code, file, prepend) {
47
54
  if (prepend.length === 0) {
48
- return code;
55
+ return { code, edits: [] };
49
56
  }
50
57
  let position = 0;
51
58
  for (let i = 0, n = file.statements.length; i < n; i++) {
52
59
  let stmt = file.statements[i];
53
- if (ts.isImportDeclaration(stmt)) {
60
+ if (isImportDeclaration(stmt)) {
54
61
  position = stmt.end;
55
62
  }
56
63
  else {
@@ -58,9 +65,11 @@ function applyPrepend(code, file, prepend) {
58
65
  }
59
66
  }
60
67
  if (position === 0) {
61
- return prepend.join('\n') + '\n' + code;
68
+ let newText = prepend.join('\n') + '\n';
69
+ return { code: newText + code, edits: [{ end: 0, newText, start: 0 }] };
62
70
  }
63
- return code.slice(0, position) + '\n' + prepend.join('\n') + '\n' + code.slice(position);
71
+ let newText = '\n' + prepend.join('\n') + '\n';
72
+ return { code: code.slice(0, position) + newText + code.slice(position), edits: [{ end: position, newText, start: position }] };
64
73
  }
65
74
  function hasPattern(code, patterns) {
66
75
  for (let i = 0, n = patterns.length; i < n; i++) {
@@ -72,7 +81,7 @@ function hasPattern(code, patterns) {
72
81
  }
73
82
  function modify(code, file, pkg, options) {
74
83
  if (!options.add && !options.namespace && !options.remove) {
75
- return code;
84
+ return { code, edits: [] };
76
85
  }
77
86
  let { namespace } = options, add = options.add ? new Set(options.add) : null, found = imports.all(file, pkg);
78
87
  if (found.length === 0) {
@@ -84,15 +93,17 @@ 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
101
  let remove = options.remove ? new Set(options.remove) : null, specifiers = new Set();
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))) {
95
- specifiers.add(name === alias ? name : `${name} as ${alias}`);
105
+ let base = name === alias ? name : `${name} as ${alias}`;
106
+ specifiers.add(found[i].typeOnly.has(name) ? `type ${base}` : base);
96
107
  }
97
108
  }
98
109
  }
@@ -116,7 +127,7 @@ function modify(code, file, pkg, options) {
116
127
  start: found[i].start
117
128
  });
118
129
  }
119
- return replaceReverse(code, replacements);
130
+ return { code: replaceReverse(code, replacements), edits: replacements };
120
131
  }
121
132
  function replaceReverse(code, replacements) {
122
133
  if (replacements.length === 0) {
@@ -137,53 +148,66 @@ function replaceReverse(code, replacements) {
137
148
  }
138
149
  return parts.reverse().join('');
139
150
  }
140
- const transform = (plugins, code, file, program, root, shared) => {
151
+ const transform = (plugins, code, file, project, root, shared) => {
141
152
  if (plugins.length === 0) {
142
- return { changed: false, code, sourceFile: file };
153
+ return { changed: false, code, map: { generations: [] }, sourceFile: file };
143
154
  }
144
- let changed = false, currentCode = code, currentFile = file, currentProgram = program, fileName = file.fileName, last = plugins.length - 1;
155
+ uid.scope(root, file.fileName, code);
156
+ let changed = false, currentCode = code, currentFile = file, currentProject = project, fileName = file.fileName, generations = [], last = plugins.length - 1;
145
157
  for (let i = 0, n = plugins.length; i < n; i++) {
146
158
  let plugin = plugins[i];
147
159
  if (plugin.patterns && !hasPattern(currentCode, plugin.patterns)) {
148
160
  continue;
149
161
  }
150
162
  let { imports, prepend, replacements } = plugin.transform({
151
- checker: currentProgram.getTypeChecker(),
163
+ checker: currentProject.checker,
152
164
  code: currentCode,
153
- program: currentProgram,
165
+ program: currentProject.program,
154
166
  shared,
155
167
  sourceFile: currentFile
156
168
  }), pluginChanged = false;
157
169
  if (replacements?.length) {
158
- currentCode = applyIntents(currentCode, currentFile, replacements);
170
+ let before = currentCode, result = applyIntents(currentCode, currentFile, replacements);
171
+ if (result.edits.length > 0) {
172
+ generations.push(sourcemap.buildGeneration(before, result.edits));
173
+ }
174
+ currentCode = result.code;
159
175
  pluginChanged = true;
160
176
  }
161
177
  if (prepend?.length) {
162
178
  if (pluginChanged) {
163
- currentFile = ts.createSourceFile(fileName, currentCode, file.languageVersion, true);
179
+ currentFile = languageService.parse(fileName, currentCode);
180
+ }
181
+ let before = currentCode, result = applyPrepend(currentCode, currentFile, prepend);
182
+ if (result.edits.length > 0) {
183
+ generations.push(sourcemap.buildGeneration(before, result.edits));
164
184
  }
165
- currentCode = applyPrepend(currentCode, currentFile, prepend);
185
+ currentCode = result.code;
166
186
  pluginChanged = true;
167
187
  }
168
188
  if (imports?.length) {
169
189
  if (pluginChanged) {
170
- currentFile = ts.createSourceFile(fileName, currentCode, file.languageVersion, true);
190
+ currentFile = languageService.parse(fileName, currentCode);
191
+ }
192
+ let result = applyImports(currentCode, currentFile, imports);
193
+ for (let j = 0, m = result.batches.length; j < m; j++) {
194
+ generations.push(sourcemap.buildGeneration(result.batches[j].before, result.batches[j].edits));
171
195
  }
172
- currentCode = applyImports(currentCode, currentFile, imports);
196
+ currentCode = result.code;
173
197
  pluginChanged = true;
174
198
  }
175
199
  if (pluginChanged) {
176
200
  changed = true;
177
201
  if (i < last) {
178
- currentProgram = languageService.update(root, fileName, currentCode);
179
- currentFile = currentProgram.getSourceFile(fileName) ||
180
- ts.createSourceFile(fileName, currentCode, file.languageVersion, true);
202
+ currentProject = languageService.update(root, fileName, currentCode);
203
+ currentFile = currentProject.program.getSourceFile(fileName) ??
204
+ languageService.parse(fileName, currentCode);
181
205
  }
182
206
  else {
183
- currentFile = ts.createSourceFile(fileName, currentCode, file.languageVersion, true);
207
+ currentFile = languageService.parse(fileName, currentCode);
184
208
  }
185
209
  }
186
210
  }
187
- return { changed, code: currentCode, sourceFile: currentFile };
211
+ return { changed, code: currentCode, map: { generations }, sourceFile: currentFile };
188
212
  };
189
213
  export default { transform };
@@ -1,7 +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 = {
3
4
  end: number;
4
5
  specifiers: Map<string, string>;
6
+ typeOnly: Set<string>;
5
7
  start: number;
6
8
  };
7
9
  type ModifyOptions = {
@@ -9,9 +11,11 @@ type ModifyOptions = {
9
11
  namespace?: string;
10
12
  remove?: Iterable<string>;
11
13
  };
14
+ declare const all: (file: SourceFile, pkg: string) => ImportInfo[];
15
+ declare const includes: (checker: Checker, node: Node, pkg: string, symbolName?: string) => boolean;
12
16
  declare const _default: {
13
- all: (file: ts.SourceFile, pkg: string) => ImportInfo[];
14
- includes: (checker: ts.TypeChecker, node: ts.Node, pkg: string, symbolName?: string) => boolean;
17
+ all: typeof all;
18
+ includes: typeof includes;
15
19
  };
16
20
  export default _default;
17
21
  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, 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,26 +10,29 @@ 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, specifiers = new Map();
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
+ if (declTypeOnly || element.isTypeOnly) {
26
+ typeOnly.add(propertyName);
27
+ }
23
28
  }
24
29
  }
25
- imports.push({ end: stmt.end, specifiers, start: stmt.getStart(file) });
30
+ imports.push({ end: stmt.end, specifiers, start: stmt.getStart(file), typeOnly });
26
31
  }
27
32
  return imports;
28
33
  };
29
34
  const includes = (checker, node, pkg, symbolName) => {
30
- if (!ts.isIdentifier(node)) {
35
+ if (!isIdentifier(node)) {
31
36
  return false;
32
37
  }
33
38
  if (symbolName && node.text !== symbolName) {
@@ -52,54 +57,55 @@ const includes = (checker, node, pkg, symbolName) => {
52
57
  if (names.has(node.text)) {
53
58
  let symbol = checker.getSymbolAtLocation(node);
54
59
  if (symbol) {
55
- let declarations = symbol.getDeclarations();
60
+ let declarations = symbol.declarations;
56
61
  if (declarations && declarations.length > 0) {
57
62
  for (let i = 0, n = declarations.length; i < n; i++) {
58
- let decl = declarations[i];
59
- if (ts.isImportSpecifier(decl)) {
60
- let importDecl = decl.parent?.parent?.parent;
61
- if (importDecl && ts.isImportDeclaration(importDecl) && ts.isStringLiteral(importDecl.moduleSpecifier)) {
62
- if (importDecl.moduleSpecifier.text === pkg) {
63
- return true;
63
+ let handle = declarations[i];
64
+ if (handle.kind === SyntaxKind.ImportSpecifier) {
65
+ let decl = handle.resolve();
66
+ if (decl) {
67
+ let importDecl = decl.parent?.parent?.parent;
68
+ if (importDecl && isImportDeclaration(importDecl) && isStringLiteral(importDecl.moduleSpecifier)) {
69
+ if (importDecl.moduleSpecifier.text === pkg) {
70
+ return true;
71
+ }
64
72
  }
65
73
  }
66
74
  }
67
- if (fileNameMatchesPackage(decl.getSourceFile().fileName, pkg)) {
75
+ if (fileNameMatchesPackage(handle.path, pkg)) {
68
76
  return true;
69
77
  }
70
78
  }
71
79
  }
72
80
  }
73
- return true;
81
+ return false;
74
82
  }
75
83
  let symbol = checker.getSymbolAtLocation(node);
76
84
  if (!symbol) {
77
85
  return false;
78
86
  }
79
- let declarations = symbol.getDeclarations();
87
+ let declarations = symbol.declarations;
80
88
  if (declarations && declarations.length > 0) {
81
89
  for (let i = 0, n = declarations.length; i < n; i++) {
82
- let decl = declarations[i];
83
- if (fileNameMatchesPackage(decl.getSourceFile().fileName, pkg)) {
90
+ let handle = declarations[i];
91
+ if (fileNameMatchesPackage(handle.path, pkg)) {
84
92
  return true;
85
93
  }
86
94
  }
87
95
  }
88
- try {
96
+ if ((symbol.flags & SymbolFlags.Alias) !== 0) {
89
97
  let aliased = checker.getAliasedSymbol(symbol);
90
98
  if (aliased && aliased !== symbol) {
91
- let aliasedDecls = aliased.getDeclarations();
99
+ let aliasedDecls = aliased.declarations;
92
100
  if (aliasedDecls) {
93
101
  for (let i = 0, n = aliasedDecls.length; i < n; i++) {
94
- if (fileNameMatchesPackage(aliasedDecls[i].getSourceFile().fileName, pkg)) {
102
+ if (fileNameMatchesPackage(aliasedDecls[i].path, pkg)) {
95
103
  return true;
96
104
  }
97
105
  }
98
106
  }
99
107
  }
100
108
  }
101
- catch {
102
- }
103
109
  return false;
104
110
  };
105
111
  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,28 @@
1
- import { ts } from '../index.js';
1
+ import type { SourceFile } from 'typescript/unstable/ast';
2
+ import { type Checker, type Program } from 'typescript/unstable/sync';
3
+ type ScratchResult = {
4
+ checker: Checker;
5
+ program: Program;
6
+ sourceFile: SourceFile;
7
+ };
8
+ type UpdateResult = {
9
+ checker: Checker;
10
+ program: Program;
11
+ };
12
+ declare const dispose: (root?: string) => void;
13
+ declare const findConfig: (startDir: string) => string | null;
2
14
  declare const invalidate: (root: string, fileName: string) => void;
3
- declare const update: (root: string, fileName: string, content: string) => ts.Program;
15
+ declare const parse: (fileName: string, content: string) => SourceFile;
16
+ declare const scratch: (fileName: string, content: string) => ScratchResult;
17
+ declare const update: (root: string, fileName: string, content: string) => UpdateResult;
4
18
  declare const _default: {
5
- invalidate: (root: string, fileName: string) => void;
6
- update: (root: string, fileName: string, content: string) => ts.Program;
19
+ dispose: typeof dispose;
20
+ findConfig: typeof findConfig;
21
+ invalidate: typeof invalidate;
22
+ parse: typeof parse;
23
+ scratch: typeof scratch;
24
+ update: typeof update;
7
25
  };
8
26
  export default _default;
9
- export { invalidate, update };
27
+ export { dispose, findConfig, invalidate, parse, scratch, update };
28
+ export type { ScratchResult, UpdateResult };