tsc-ts 0.0.5 → 0.0.6
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/README.md +1 -1
- package/dist/api/compiler/ast.d.ts +10 -9
- package/dist/api/compiler/ast.js +22 -16
- package/dist/api/compiler/binder-utilities.js +2 -1
- package/dist/api/compiler/binder.js +9 -8
- package/dist/api/compiler/checker-calls.js +3 -2
- package/dist/api/compiler/checker-declaration-order.js +2 -1
- package/dist/api/compiler/checker-declarations.js +14 -14
- package/dist/api/compiler/checker-declared-types.d.ts +1 -1
- package/dist/api/compiler/checker-declared-types.js +12 -11
- package/dist/api/compiler/checker-decorators.js +3 -3
- package/dist/api/compiler/checker-deprecation.js +17 -18
- package/dist/api/compiler/checker-destructuring.d.ts +1 -1
- package/dist/api/compiler/checker-destructuring.js +3 -3
- package/dist/api/compiler/checker-elaboration.js +8 -7
- package/dist/api/compiler/checker-emit-resolver.d.ts +1 -1
- package/dist/api/compiler/checker-emit-resolver.js +5 -4
- package/dist/api/compiler/checker-grammar.js +18 -4
- package/dist/api/compiler/checker-heritage.d.ts +1 -1
- package/dist/api/compiler/checker-heritage.js +14 -13
- package/dist/api/compiler/checker-inference.d.ts +1 -1
- package/dist/api/compiler/checker-inference.js +9 -9
- package/dist/api/compiler/checker-javascript.d.ts +1 -1
- package/dist/api/compiler/checker-javascript.js +5 -4
- package/dist/api/compiler/checker-jsx.d.ts +1 -1
- package/dist/api/compiler/checker-jsx.js +4 -4
- package/dist/api/compiler/checker-literals.js +2 -2
- package/dist/api/compiler/checker-members.d.ts +5 -3
- package/dist/api/compiler/checker-members.js +75 -53
- package/dist/api/compiler/checker-modules.d.ts +1 -1
- package/dist/api/compiler/checker-modules.js +13 -13
- package/dist/api/compiler/checker-object-literals.d.ts +1 -1
- package/dist/api/compiler/checker-object-literals.js +11 -7
- package/dist/api/compiler/checker-overloads.d.ts +1 -1
- package/dist/api/compiler/checker-overloads.js +4 -3
- package/dist/api/compiler/checker-property-access.d.ts +1 -1
- package/dist/api/compiler/checker-property-access.js +2 -2
- package/dist/api/compiler/checker-services.js +2 -2
- package/dist/api/compiler/checker-signatures.d.ts +1 -1
- package/dist/api/compiler/checker-signatures.js +9 -8
- package/dist/api/compiler/checker-symbol-types.d.ts +2 -18
- package/dist/api/compiler/checker-symbol-types.js +22 -952
- package/dist/api/compiler/checker-symbols.d.ts +2 -2
- package/dist/api/compiler/checker-symbols.js +29 -27
- package/dist/api/compiler/checker-type-factory.d.ts +2 -2
- package/dist/api/compiler/checker-type-factory.js +57 -16
- package/dist/api/compiler/checker-type-nodes.d.ts +1 -1
- package/dist/api/compiler/checker-type-nodes.js +2 -2
- package/dist/api/compiler/checker-type-operators.d.ts +1 -1
- package/dist/api/compiler/checker-type-operators.js +5 -5
- package/dist/api/compiler/checker-types.d.ts +73 -7
- package/dist/api/compiler/checker-types.js +220 -43
- package/dist/api/compiler/checker-unused.d.ts +1 -1
- package/dist/api/compiler/checker-unused.js +3 -3
- package/dist/api/compiler/checker.d.ts +29 -8
- package/dist/api/compiler/checker.js +29 -9
- package/dist/api/compiler/diagnostics.d.ts +2 -8
- package/dist/api/compiler/diagnostics.js +4 -40
- package/dist/api/compiler/file-include.d.ts +35 -8
- package/dist/api/compiler/file-include.js +81 -18
- package/dist/api/compiler/file-loader.d.ts +33 -4
- package/dist/api/compiler/file-loader.js +90 -24
- package/dist/api/compiler/instantiation.d.ts +1 -1
- package/dist/api/compiler/instantiation.js +86 -50
- package/dist/api/compiler/link-tables.d.ts +69 -0
- package/dist/api/compiler/link-tables.js +236 -0
- package/dist/api/compiler/name-resolver.js +3 -3
- package/dist/api/compiler/node-builder-names.d.ts +1 -1
- package/dist/api/compiler/node-builder-names.js +12 -12
- package/dist/api/compiler/node-builder-pseudo.d.ts +1 -1
- package/dist/api/compiler/node-builder-pseudo.js +2 -1
- package/dist/api/compiler/node-builder.d.ts +1 -1
- package/dist/api/compiler/node-builder.js +16 -16
- package/dist/api/compiler/parallel-parse.d.ts +2 -0
- package/dist/api/compiler/parallel-parse.js +4 -0
- package/dist/api/compiler/parser.d.ts +33 -16
- package/dist/api/compiler/parser.js +95 -76
- package/dist/api/compiler/printer/emit-context.d.ts +5 -2
- package/dist/api/compiler/printer/emit-context.js +19 -13
- package/dist/api/compiler/program-checker.js +3 -0
- package/dist/api/compiler/program.js +9 -1
- package/dist/api/compiler/relations.d.ts +1 -1
- package/dist/api/compiler/relations.js +10 -10
- package/dist/api/compiler/symbol-accessibility.d.ts +1 -1
- package/dist/api/compiler/symbol-accessibility.js +123 -26
- package/dist/api/compiler/symbol.d.ts +45 -3
- package/dist/api/compiler/symbol.js +121 -10
- package/dist/api/compiler/transformers/alias-references.d.ts +1 -1
- package/dist/api/compiler/transformers/alias-references.js +2 -1
- package/dist/api/compiler/transformers/declarations-diagnostics.js +2 -1
- package/dist/api/compiler/transformers/declarations-pseudo.js +4 -2
- package/dist/api/compiler/transformers/declarations-syntactic.d.ts +1 -1
- package/dist/api/compiler/transformers/declarations-syntactic.js +9 -9
- package/dist/api/compiler/transformers/declarations-tracker.d.ts +1 -1
- package/dist/api/compiler/transformers/declarations-tracker.js +3 -2
- package/dist/api/compiler/transformers/declarations.js +6 -5
- package/dist/api/compiler/transformers/reference-resolver.d.ts +2 -1
- package/dist/api/compiler/transformers/reference-resolver.js +26 -24
- package/dist/api/compiler/transformers/subtree-facts.d.ts +1 -0
- package/dist/api/compiler/transformers/subtree-facts.js +7 -5
- package/dist/api/compiler/transformers/syntax-facts.d.ts +1 -0
- package/dist/api/compiler/transformers/syntax-facts.js +9 -5
- package/dist/api/compiler/transformers/type-serialization.js +12 -12
- package/package.json +9 -9
- package/src/compiler/ast.ts +27 -19
- package/src/compiler/binder-utilities.ts +2 -2
- package/src/compiler/binder.ts +15 -11
- package/src/compiler/checker-calls.ts +3 -3
- package/src/compiler/checker-declaration-order.ts +2 -2
- package/src/compiler/checker-declarations.ts +21 -14
- package/src/compiler/checker-declared-types.ts +12 -12
- package/src/compiler/checker-decorators.ts +3 -3
- package/src/compiler/checker-deprecation.ts +17 -21
- package/src/compiler/checker-destructuring.ts +3 -3
- package/src/compiler/checker-elaboration.ts +8 -8
- package/src/compiler/checker-emit-resolver.ts +5 -5
- package/src/compiler/checker-grammar.ts +17 -5
- package/src/compiler/checker-heritage.ts +21 -14
- package/src/compiler/checker-inference.ts +17 -9
- package/src/compiler/checker-javascript.ts +5 -5
- package/src/compiler/checker-jsx.ts +12 -8
- package/src/compiler/checker-literals.ts +2 -2
- package/src/compiler/checker-members.ts +91 -47
- package/src/compiler/checker-modules.ts +23 -13
- package/src/compiler/checker-object-literals.ts +22 -6
- package/src/compiler/checker-overloads.ts +6 -6
- package/src/compiler/checker-property-access.ts +2 -2
- package/src/compiler/checker-services.ts +2 -2
- package/src/compiler/checker-signatures.ts +9 -9
- package/src/compiler/checker-symbol-types.ts +20 -940
- package/src/compiler/checker-symbols.ts +42 -35
- package/src/compiler/checker-type-factory.ts +53 -16
- package/src/compiler/checker-type-nodes.ts +2 -2
- package/src/compiler/checker-type-operators.ts +13 -5
- package/src/compiler/checker-types.ts +223 -43
- package/src/compiler/checker-unused.ts +3 -3
- package/src/compiler/checker.ts +31 -9
- package/src/compiler/diagnostics.ts +5 -44
- package/src/compiler/file-include.ts +85 -17
- package/src/compiler/file-loader.ts +104 -35
- package/src/compiler/incremental.ts +39 -5
- package/src/compiler/instantiation.ts +99 -55
- package/src/compiler/link-tables.ts +245 -0
- package/src/compiler/name-resolver.ts +3 -3
- package/src/compiler/node-builder-names.ts +21 -19
- package/src/compiler/node-builder-pseudo.ts +2 -2
- package/src/compiler/node-builder.ts +24 -16
- package/src/compiler/parallel-check.ts +11 -8
- package/src/compiler/parallel-parse.ts +5 -0
- package/src/compiler/parse-thread.ts +0 -4
- package/src/compiler/parser.ts +120 -70
- package/src/compiler/printer/emit-context.ts +20 -15
- package/src/compiler/program-checker.ts +2 -0
- package/src/compiler/program.ts +8 -1
- package/src/compiler/relations.ts +10 -10
- package/src/compiler/symbol-accessibility.ts +120 -25
- package/src/compiler/symbol.ts +127 -9
- package/src/compiler/transformers/alias-references.ts +2 -2
- package/src/compiler/transformers/declarations-diagnostics.ts +2 -1
- package/src/compiler/transformers/declarations-pseudo.ts +7 -4
- package/src/compiler/transformers/declarations-syntactic.ts +17 -9
- package/src/compiler/transformers/declarations-tracker.ts +3 -3
- package/src/compiler/transformers/declarations.ts +6 -6
- package/src/compiler/transformers/reference-resolver.ts +37 -25
- package/src/compiler/transformers/subtree-facts.ts +13 -5
- package/src/compiler/transformers/syntax-facts.ts +10 -5
- package/src/compiler/transformers/type-serialization.ts +12 -12
- package/src/compiler/tsc-build.ts +17 -13
- package/src/compiler/tsc-cli.ts +9 -6
- package/src/compiler/tsc-compile.ts +16 -7
- package/src/compiler/tsc-watch.ts +94 -26
|
@@ -89,7 +89,6 @@ import { combinePaths, getDirectoryPath, getNormalizedAbsolutePath, normalizePat
|
|
|
89
89
|
import type { EmitContext } from '../printer/emit-context.js';
|
|
90
90
|
import { EmitFlags } from '../printer/emit-flags.js';
|
|
91
91
|
import { isIdentifierText } from '../scanner.js';
|
|
92
|
-
import { Symbol, SymbolFlags, type SymbolTable, addDeclaration } from '../symbol.js';
|
|
93
92
|
import { SyntaxKind } from '../syntax-kind.js';
|
|
94
93
|
import { TokenFlags } from '../types.js';
|
|
95
94
|
import type { SyntacticEmitResolver } from './emit-resolver.js';
|
|
@@ -126,6 +125,15 @@ import {
|
|
|
126
125
|
typesOf,
|
|
127
126
|
undefinedType,
|
|
128
127
|
} from './declarations-pseudo.js';
|
|
128
|
+
import {
|
|
129
|
+
addDeclaration,
|
|
130
|
+
declarationCount,
|
|
131
|
+
getDeclarations,
|
|
132
|
+
setDeclarations,
|
|
133
|
+
Symbol,
|
|
134
|
+
SymbolFlags,
|
|
135
|
+
type SymbolTable,
|
|
136
|
+
} from '../symbol.js';
|
|
129
137
|
|
|
130
138
|
const emptyTable: SymbolTable = new Map<string, Symbol>();
|
|
131
139
|
|
|
@@ -275,7 +283,7 @@ export class SyntacticDeclarationEmitResolver extends DeclarationEmitResolver {
|
|
|
275
283
|
while (symbol !== undefined && !visited.has(symbol)) {
|
|
276
284
|
visited.add(symbol);
|
|
277
285
|
let next: Symbol | undefined = undefined;
|
|
278
|
-
for (const declaration of symbol
|
|
286
|
+
for (const declaration of getDeclarations(symbol)) {
|
|
279
287
|
this.visibility.set(declaration, true);
|
|
280
288
|
if (
|
|
281
289
|
declaration instanceof ImportEqualsDeclaration &&
|
|
@@ -420,7 +428,7 @@ export class SyntacticDeclarationEmitResolver extends DeclarationEmitResolver {
|
|
|
420
428
|
shouldComputeAliasesToMakeVisible: boolean,
|
|
421
429
|
): SymbolAccessibilityResult | undefined {
|
|
422
430
|
const aliases: Node[] = [];
|
|
423
|
-
for (const declaration of symbol
|
|
431
|
+
for (const declaration of getDeclarations(symbol)) {
|
|
424
432
|
if (declaration.kind === SyntaxKind.Identifier || this.isDeclarationVisible(declaration)) continue;
|
|
425
433
|
let statement: Node | undefined = undefined;
|
|
426
434
|
// Imports and unexported declarations can name types if their parent is visible.
|
|
@@ -505,7 +513,7 @@ export class SyntacticDeclarationEmitResolver extends DeclarationEmitResolver {
|
|
|
505
513
|
const symbol = this.getSymbolOfDeclaration(node);
|
|
506
514
|
if (symbol === undefined) return false;
|
|
507
515
|
const signatures: Node[] = [];
|
|
508
|
-
const declarations = symbol
|
|
516
|
+
const declarations = getDeclarations(symbol);
|
|
509
517
|
for (let i = 0; i < declarations.length; i++) {
|
|
510
518
|
const declaration = declarations[i]!;
|
|
511
519
|
if (!isFunctionLike(declaration)) continue;
|
|
@@ -544,7 +552,7 @@ export class SyntacticDeclarationEmitResolver extends DeclarationEmitResolver {
|
|
|
544
552
|
const symbol = this.resolveName(node, node.text, SymbolFlags.Value | SymbolFlags.ExportValue);
|
|
545
553
|
if (symbol === undefined) return undefined;
|
|
546
554
|
const resolved = symbol.exportSymbol ?? symbol;
|
|
547
|
-
return resolved.valueDeclaration ?? (resolved
|
|
555
|
+
return resolved.valueDeclaration ?? (declarationCount(resolved) > 0 ? resolved.declaration! : undefined);
|
|
548
556
|
}
|
|
549
557
|
if (!(node instanceof PropertyAccessExpression) || !(node.name instanceof Identifier)) return undefined;
|
|
550
558
|
const name = node.name.text;
|
|
@@ -799,7 +807,7 @@ export class SyntacticDeclarationEmitResolver extends DeclarationEmitResolver {
|
|
|
799
807
|
|
|
800
808
|
private hasMergedDeclarations(declaration: Node): boolean {
|
|
801
809
|
const symbol = getSymbol(declaration);
|
|
802
|
-
return symbol !== undefined && this.pseudo.getMergedSymbol(symbol)
|
|
810
|
+
return symbol !== undefined && declarationCount(this.pseudo.getMergedSymbol(symbol)) > declarationCount(symbol);
|
|
803
811
|
}
|
|
804
812
|
|
|
805
813
|
/** Whether a parameter's pseudo-type already has `undefined`, so none is added. */
|
|
@@ -1404,7 +1412,7 @@ class PseudoTypeWriter {
|
|
|
1404
1412
|
|
|
1405
1413
|
/** Parameters and type parameters are in scope where the signature's types are written. */
|
|
1406
1414
|
function isSignatureLocal(symbol: Symbol): boolean {
|
|
1407
|
-
const declaration = symbol.valueDeclaration ?? (symbol
|
|
1415
|
+
const declaration = symbol.valueDeclaration ?? (declarationCount(symbol) > 0 ? symbol.declaration : undefined);
|
|
1408
1416
|
return (
|
|
1409
1417
|
declaration !== undefined &&
|
|
1410
1418
|
(declaration.kind === SyntaxKind.Parameter || declaration.kind === SyntaxKind.TypeParameter)
|
|
@@ -1779,7 +1787,7 @@ function mergeInto(target: Map<string, Symbol>, source: SymbolTable, mergedSymbo
|
|
|
1779
1787
|
if (mergedSymbols.get(existing) !== existing) {
|
|
1780
1788
|
// The first merge replaces the first file's symbol with a copy.
|
|
1781
1789
|
merged = new Symbol(existing.flags, name);
|
|
1782
|
-
merged
|
|
1790
|
+
setDeclarations(merged, getDeclarations(existing).slice());
|
|
1783
1791
|
merged.valueDeclaration = existing.valueDeclaration;
|
|
1784
1792
|
merged.exports = copyTable(existing.exports);
|
|
1785
1793
|
merged.members = copyTable(existing.members);
|
|
@@ -1788,7 +1796,7 @@ function mergeInto(target: Map<string, Symbol>, source: SymbolTable, mergedSymbo
|
|
|
1788
1796
|
target.set(name, merged);
|
|
1789
1797
|
}
|
|
1790
1798
|
merged.flags |= symbol.flags;
|
|
1791
|
-
for (const declaration of symbol
|
|
1799
|
+
for (const declaration of getDeclarations(symbol)) addDeclaration(merged, declaration);
|
|
1792
1800
|
merged.valueDeclaration ??= symbol.valueDeclaration;
|
|
1793
1801
|
if (symbol.exports !== undefined) {
|
|
1794
1802
|
merged.exports ??= new Map<string, Symbol>();
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
import { BinaryExpression, ExportAssignment, Identifier, type Node, type SourceFile, getExpression } from '../ast.js';
|
|
4
4
|
import { getNameOfDeclaration, getSourceFileOfNode } from '../binder-utilities.js';
|
|
5
5
|
import { type Diagnostic, type DiagnosticMessage, Diagnostics } from '../diagnostics.js';
|
|
6
|
-
import { type Symbol, SymbolFlags } from '../symbol.js';
|
|
7
6
|
import { SyntaxKind } from '../syntax-kind.js';
|
|
8
7
|
import {
|
|
9
8
|
DiagnosticContext,
|
|
@@ -20,6 +19,7 @@ import {
|
|
|
20
19
|
type SymbolAccessibilityResult,
|
|
21
20
|
SymbolTracker,
|
|
22
21
|
} from './declarations-resolver.js';
|
|
22
|
+
import { getDeclarations, type Symbol, SymbolFlags } from '../symbol.js';
|
|
23
23
|
|
|
24
24
|
export class DeclarationTracker extends SymbolTracker {
|
|
25
25
|
readonly resolver: DeclarationEmitResolver;
|
|
@@ -160,13 +160,13 @@ export class DeclarationTracker extends SymbolTracker {
|
|
|
160
160
|
|
|
161
161
|
reportNonlocalAugmentation(containingFile: SourceFile, parentSymbol: Symbol, augmentingSymbol: Symbol): boolean {
|
|
162
162
|
let primary: Node | undefined = undefined;
|
|
163
|
-
for (const declaration of parentSymbol
|
|
163
|
+
for (const declaration of getDeclarations(parentSymbol))
|
|
164
164
|
if (getSourceFileOfNode(declaration) === containingFile) {
|
|
165
165
|
primary = declaration;
|
|
166
166
|
break;
|
|
167
167
|
}
|
|
168
168
|
if (primary === undefined) return false;
|
|
169
|
-
for (const augmentation of augmentingSymbol
|
|
169
|
+
for (const augmentation of getDeclarations(augmentingSymbol)) {
|
|
170
170
|
if (getSourceFileOfNode(augmentation) === containingFile) continue;
|
|
171
171
|
const diagnostic = createDiagnosticForNode(
|
|
172
172
|
augmentation,
|
|
@@ -143,7 +143,6 @@ import {
|
|
|
143
143
|
skipTrivia,
|
|
144
144
|
stringToToken,
|
|
145
145
|
} from '../scanner.js';
|
|
146
|
-
import { SymbolFlags } from '../symbol.js';
|
|
147
146
|
import type { CommentRange } from '../types.js';
|
|
148
147
|
import { getRelativePathToDirectoryOrUrl } from '../sourcemap.js';
|
|
149
148
|
import { SyntaxKind } from '../syntax-kind.js';
|
|
@@ -161,6 +160,7 @@ import { type DeclarationEmitResolver, NodeBuilderFlags } from './declarations-r
|
|
|
161
160
|
import { ConstantKind } from './reference-resolver.js';
|
|
162
161
|
import { DeclarationTracker } from './declarations-tracker.js';
|
|
163
162
|
import { Transformer } from './transformer.js';
|
|
163
|
+
import { declarationCount, getDeclarations, SymbolFlags } from '../symbol.js';
|
|
164
164
|
|
|
165
165
|
export class DeclarationTransformer extends Transformer {
|
|
166
166
|
readonly host: OutputPathsHost;
|
|
@@ -363,8 +363,8 @@ export class DeclarationTransformer extends Transformer {
|
|
|
363
363
|
const symbol = file.symbol;
|
|
364
364
|
const exportEquals =
|
|
365
365
|
symbol === undefined || symbol.exports === undefined ? undefined : symbol.exports.get('export=');
|
|
366
|
-
if (exportEquals === undefined || exportEquals
|
|
367
|
-
for (const declaration of exportEquals
|
|
366
|
+
if (exportEquals === undefined || declarationCount(exportEquals) <= 1) return false;
|
|
367
|
+
for (const declaration of getDeclarations(exportEquals))
|
|
368
368
|
this.tracker.addDiagnostic(
|
|
369
369
|
createDiagnosticForNode(
|
|
370
370
|
declaration,
|
|
@@ -1037,7 +1037,7 @@ export class DeclarationTransformer extends Transformer {
|
|
|
1037
1037
|
/** A private method is written as a property without a type. */
|
|
1038
1038
|
private omitPrivateMethodType(input: Node): Node | undefined {
|
|
1039
1039
|
const symbol = getSymbol(input);
|
|
1040
|
-
if (symbol !== undefined && symbol
|
|
1040
|
+
if (symbol !== undefined && declarationCount(symbol) > 0 && symbol.declaration !== input) return undefined;
|
|
1041
1041
|
const result = this.factory.created(
|
|
1042
1042
|
new PropertyDeclaration(this.ensureModifiers(input), getName(input)!, undefined, undefined, undefined),
|
|
1043
1043
|
);
|
|
@@ -3003,7 +3003,7 @@ function getFullSignature(node: Node): Node | undefined {
|
|
|
3003
3003
|
function isCommonJSAliasExport(node: Node): boolean {
|
|
3004
3004
|
if (!(node instanceof BinaryExpression) || !(node.right instanceof Identifier)) return false;
|
|
3005
3005
|
const symbol = node.symbol;
|
|
3006
|
-
return symbol !== undefined && symbol
|
|
3006
|
+
return symbol !== undefined && declarationCount(symbol) === 1;
|
|
3007
3007
|
}
|
|
3008
3008
|
|
|
3009
3009
|
function getLeftmostAccessExpression(node: Node): Node {
|
|
@@ -3018,7 +3018,7 @@ function shouldEmitFunctionProperties(fn: FunctionDeclaration): boolean {
|
|
|
3018
3018
|
if (fn.body !== undefined) return true;
|
|
3019
3019
|
const symbol = fn.symbol;
|
|
3020
3020
|
if (symbol === undefined) return false;
|
|
3021
|
-
for (const declaration of symbol
|
|
3021
|
+
for (const declaration of getDeclarations(symbol))
|
|
3022
3022
|
if (declaration instanceof FunctionDeclaration && declaration.body !== undefined) return true;
|
|
3023
3023
|
return false;
|
|
3024
3024
|
}
|
|
@@ -48,13 +48,24 @@ import {
|
|
|
48
48
|
isEnumConst,
|
|
49
49
|
isExternalOrCommonJSModule,
|
|
50
50
|
} from '../binder-utilities.js';
|
|
51
|
+
import { IntLinkTable, LinkTable } from '../link-tables.js';
|
|
51
52
|
import { NameResolver } from '../name-resolver.js';
|
|
52
53
|
import { isSameNode } from './utilities.js';
|
|
53
54
|
import { pathIsRelative } from '../path.js';
|
|
54
55
|
import { type CompilerOptions, shouldPreserveConstEnums } from '../options.js';
|
|
55
|
-
import { InternalSymbolName, Symbol, SymbolFlags, type SymbolTable, addDeclaration } from '../symbol.js';
|
|
56
56
|
import { SyntaxKind } from '../syntax-kind.js';
|
|
57
57
|
import { TokenFlags } from '../types.js';
|
|
58
|
+
import {
|
|
59
|
+
addDeclaration,
|
|
60
|
+
declarationAt,
|
|
61
|
+
declarationCount,
|
|
62
|
+
getDeclarations,
|
|
63
|
+
InternalSymbolName,
|
|
64
|
+
setDeclarations,
|
|
65
|
+
Symbol,
|
|
66
|
+
SymbolFlags,
|
|
67
|
+
type SymbolTable,
|
|
68
|
+
} from '../symbol.js';
|
|
58
69
|
|
|
59
70
|
export const enum ConstantKind {
|
|
60
71
|
None,
|
|
@@ -210,7 +221,7 @@ export class MergedGlobals {
|
|
|
210
221
|
)
|
|
211
222
|
return source;
|
|
212
223
|
result = new Symbol(resolved.flags | SymbolFlags.Transient, resolved.name);
|
|
213
|
-
result
|
|
224
|
+
setDeclarations(result, getDeclarations(resolved).slice());
|
|
214
225
|
result.parent = resolved.parent;
|
|
215
226
|
result.valueDeclaration = resolved.valueDeclaration;
|
|
216
227
|
result.members = resolved.members === undefined ? undefined : new Map<string, Symbol>(resolved.members);
|
|
@@ -228,7 +239,7 @@ export class MergedGlobals {
|
|
|
228
239
|
if ((result.flags & SymbolFlags.ConstEnumOnlyModule) === 0) sourceFlags &= ~SymbolFlags.ConstEnumOnlyModule;
|
|
229
240
|
result.flags |= sourceFlags;
|
|
230
241
|
if (source.valueDeclaration !== undefined) setValueDeclaration(result, source.valueDeclaration);
|
|
231
|
-
for (let i = 0; i < source
|
|
242
|
+
for (let i = 0; i < declarationCount(source); i++) addDeclaration(result, declarationAt(source, i));
|
|
232
243
|
if (source.members !== undefined) {
|
|
233
244
|
if (result.members === undefined) result.members = new Map<string, Symbol>();
|
|
234
245
|
this.mergeTable(result.members, source.members, undefined);
|
|
@@ -316,9 +327,10 @@ export class ReferenceResolver {
|
|
|
316
327
|
private readonly enumValues: Map<Node, Evaluation>;
|
|
317
328
|
private readonly computedEnums: Set<Node>;
|
|
318
329
|
private readonly aliasTargets: Map<Symbol, Symbol>;
|
|
319
|
-
/** Value symbols of identifiers resolved as expressions, as the checker caches them. */
|
|
320
|
-
private readonly resolvedSymbols:
|
|
321
|
-
|
|
330
|
+
/** Value symbols of identifiers resolved as expressions, as the checker caches them, by node id. */
|
|
331
|
+
private readonly resolvedSymbols: LinkTable<Symbol>;
|
|
332
|
+
/** 1 for each identifier, by node id, that resolved to no value symbol. */
|
|
333
|
+
private readonly unresolvedReferences: IntLinkTable;
|
|
322
334
|
private readonly unresolvedAliases: Set<Symbol>;
|
|
323
335
|
private readonly resolvingAliases: Set<Symbol>;
|
|
324
336
|
/** The module each module specifier names (`null` for none), by specifier. */
|
|
@@ -340,8 +352,8 @@ export class ReferenceResolver {
|
|
|
340
352
|
this.enumValues = new Map<Node, Evaluation>();
|
|
341
353
|
this.computedEnums = new Set<Node>();
|
|
342
354
|
this.aliasTargets = new Map<Symbol, Symbol>();
|
|
343
|
-
this.resolvedSymbols = new
|
|
344
|
-
this.unresolvedReferences = new
|
|
355
|
+
this.resolvedSymbols = new LinkTable<Symbol>();
|
|
356
|
+
this.unresolvedReferences = new IntLinkTable();
|
|
345
357
|
this.unresolvedAliases = new Set<Symbol>();
|
|
346
358
|
this.resolvingAliases = new Set<Symbol>();
|
|
347
359
|
this.specifierModules = new Map<Node, Symbol | null>();
|
|
@@ -364,20 +376,20 @@ export class ReferenceResolver {
|
|
|
364
376
|
|
|
365
377
|
/** The value an identifier in an expression refers to, cached for later queries of the identifier. */
|
|
366
378
|
getResolvedSymbol(node: Identifier): Symbol | undefined {
|
|
367
|
-
const cached = this.resolvedSymbols.get(node
|
|
379
|
+
const cached = this.resolvedSymbols.get(node.id);
|
|
368
380
|
if (cached !== undefined) return cached;
|
|
369
|
-
if (this.unresolvedReferences.
|
|
381
|
+
if (this.unresolvedReferences.get(node.id) !== 0) return undefined;
|
|
370
382
|
const symbol = this.resolveName(node, node.text, SymbolFlags.Value | SymbolFlags.ExportValue);
|
|
371
|
-
if (symbol === undefined) this.unresolvedReferences.
|
|
372
|
-
else this.resolvedSymbols.set(node
|
|
383
|
+
if (symbol === undefined) this.unresolvedReferences.set(node.id, 1);
|
|
384
|
+
else this.resolvedSymbols.set(node.id, symbol);
|
|
373
385
|
return symbol;
|
|
374
386
|
}
|
|
375
387
|
|
|
376
388
|
private getReferencedValueSymbol(reference: Identifier, startInDeclarationContainer: boolean): Symbol | undefined {
|
|
377
389
|
// An identifier resolved as an expression keeps that meaning, as with the checker's cache.
|
|
378
|
-
const cached = this.resolvedSymbols.get(reference
|
|
390
|
+
const cached = this.resolvedSymbols.get(reference.id);
|
|
379
391
|
if (cached !== undefined) return cached;
|
|
380
|
-
if (this.unresolvedReferences.
|
|
392
|
+
if (this.unresolvedReferences.get(reference.id) !== 0) return undefined;
|
|
381
393
|
let location: Node = reference;
|
|
382
394
|
const parent = reference.parent;
|
|
383
395
|
if (startInDeclarationContainer && parent !== undefined && isSameNode(getName(parent), reference)) {
|
|
@@ -443,7 +455,7 @@ export class ReferenceResolver {
|
|
|
443
455
|
getReferencedImportDeclaration(node: Identifier): Node | undefined {
|
|
444
456
|
// As the checker: an identifier that didn't resolve as a value may still name an alias.
|
|
445
457
|
const reference: Node = node;
|
|
446
|
-
let symbol = this.resolvedSymbols.get(reference);
|
|
458
|
+
let symbol = this.resolvedSymbols.get(reference.id);
|
|
447
459
|
if (symbol === undefined) symbol = this.resolveName(node, node.text, valueMeaning);
|
|
448
460
|
if (
|
|
449
461
|
symbol === undefined ||
|
|
@@ -477,7 +489,7 @@ export class ReferenceResolver {
|
|
|
477
489
|
if (resolved === undefined) return undefined;
|
|
478
490
|
const symbol = this.getExportSymbolOfValueSymbolIfExported(resolved);
|
|
479
491
|
const declarations: Node[] = [];
|
|
480
|
-
for (const declaration of symbol
|
|
492
|
+
for (const declaration of getDeclarations(symbol))
|
|
481
493
|
if (isValueDeclarationKind(declaration.kind)) declarations.push(declaration);
|
|
482
494
|
return declarations;
|
|
483
495
|
}
|
|
@@ -526,7 +538,7 @@ export class ReferenceResolver {
|
|
|
526
538
|
if (exports === undefined || exports.has(name) || name === InternalSymbolName.Default) return false;
|
|
527
539
|
const star = exports.get(InternalSymbolName.ExportStar);
|
|
528
540
|
if (star === undefined) return false;
|
|
529
|
-
for (const declaration of star
|
|
541
|
+
for (const declaration of getDeclarations(star)) {
|
|
530
542
|
if (!(declaration instanceof ExportDeclaration)) continue;
|
|
531
543
|
const target = this.resolveExternalModuleSymbol(
|
|
532
544
|
this.resolveModuleSpecifier(declaration, declaration.moduleSpecifier),
|
|
@@ -539,8 +551,8 @@ export class ReferenceResolver {
|
|
|
539
551
|
|
|
540
552
|
/** Whether a symbol is declared in the global scope. */
|
|
541
553
|
isGlobalSymbol(symbol: Symbol): boolean {
|
|
542
|
-
if (symbol
|
|
543
|
-
const container = getDeclarationContainer(symbol.
|
|
554
|
+
if (declarationCount(symbol) === 0) return false;
|
|
555
|
+
const container = getDeclarationContainer(symbol.declaration!);
|
|
544
556
|
return container instanceof SourceFile && !isExternalOrCommonJSModule(container as SourceFile);
|
|
545
557
|
}
|
|
546
558
|
|
|
@@ -746,7 +758,7 @@ export class ReferenceResolver {
|
|
|
746
758
|
if (name === InternalSymbolName.Default) return undefined;
|
|
747
759
|
const star = exports.get(InternalSymbolName.ExportStar);
|
|
748
760
|
if (star === undefined) return undefined;
|
|
749
|
-
for (const declaration of star
|
|
761
|
+
for (const declaration of getDeclarations(star)) {
|
|
750
762
|
if (!(declaration instanceof ExportDeclaration)) continue;
|
|
751
763
|
const target = this.resolveExternalModuleSymbol(
|
|
752
764
|
this.resolveModuleSpecifier(declaration, declaration.moduleSpecifier),
|
|
@@ -926,7 +938,7 @@ export class ReferenceResolver {
|
|
|
926
938
|
if (symbol === undefined) return noEvaluation;
|
|
927
939
|
if (expression instanceof Identifier && (expression.text === 'Infinity' || expression.text === 'NaN')) {
|
|
928
940
|
// A global `Infinity` or `NaN`; without lib files these don't resolve at all.
|
|
929
|
-
if (symbol
|
|
941
|
+
if (declarationCount(symbol) > 0 && isAmbientGlobal(symbol))
|
|
930
942
|
return numberEvaluation(expression.text === 'NaN' ? NaN : Infinity);
|
|
931
943
|
}
|
|
932
944
|
if ((symbol.flags & SymbolFlags.EnumMember) !== 0) return this.evaluateEnumMemberSymbol(symbol, location);
|
|
@@ -1029,8 +1041,8 @@ export function isEntityNameExpressionNode(node: Node): boolean {
|
|
|
1029
1041
|
}
|
|
1030
1042
|
|
|
1031
1043
|
function isAmbientGlobal(symbol: Symbol): boolean {
|
|
1032
|
-
for (let i = 0; i < symbol
|
|
1033
|
-
if ((symbol
|
|
1044
|
+
for (let i = 0; i < declarationCount(symbol); i++)
|
|
1045
|
+
if ((declarationAt(symbol, i).flags & NodeFlags.Ambient) === 0) return false;
|
|
1034
1046
|
return true;
|
|
1035
1047
|
}
|
|
1036
1048
|
|
|
@@ -1112,8 +1124,8 @@ function isAliasSymbolDeclaration(node: Node): boolean {
|
|
|
1112
1124
|
}
|
|
1113
1125
|
|
|
1114
1126
|
export function getDeclarationOfAliasSymbol(symbol: Symbol): Node | undefined {
|
|
1115
|
-
for (let i = symbol
|
|
1116
|
-
const declaration = symbol
|
|
1127
|
+
for (let i = declarationCount(symbol) - 1; i >= 0; i--) {
|
|
1128
|
+
const declaration = declarationAt(symbol, i);
|
|
1117
1129
|
if (isAliasSymbolDeclaration(declaration)) return declaration;
|
|
1118
1130
|
}
|
|
1119
1131
|
return undefined;
|
|
@@ -33,6 +33,7 @@ import {
|
|
|
33
33
|
HeritageClause,
|
|
34
34
|
getModifiers,
|
|
35
35
|
} from '../ast.js';
|
|
36
|
+
import { ClusteredIntLinkTable } from '../link-tables.js';
|
|
36
37
|
import { isTypeNodeKind } from '../printer/utilities.js';
|
|
37
38
|
import { SyntaxKind } from '../syntax-kind.js';
|
|
38
39
|
|
|
@@ -43,20 +44,27 @@ const enum Facts {
|
|
|
43
44
|
Final = 2,
|
|
44
45
|
}
|
|
45
46
|
|
|
47
|
+
/** The answers `TypeScriptFacts.cache` stores; zero is unknown. */
|
|
48
|
+
const enum Answer {
|
|
49
|
+
No = 1,
|
|
50
|
+
Yes = 2,
|
|
51
|
+
}
|
|
52
|
+
|
|
46
53
|
/** Memoized `containsTypeScript` answers for one emit. */
|
|
47
54
|
export class TypeScriptFacts extends NodeVisitor {
|
|
48
|
-
|
|
55
|
+
/** The answer for each node, by node id. */
|
|
56
|
+
private readonly cache: ClusteredIntLinkTable;
|
|
49
57
|
private found: boolean;
|
|
50
58
|
|
|
51
59
|
constructor() {
|
|
52
60
|
super();
|
|
53
|
-
this.cache = new
|
|
61
|
+
this.cache = new ClusteredIntLinkTable();
|
|
54
62
|
this.found = false;
|
|
55
63
|
}
|
|
56
64
|
|
|
57
65
|
containsTypeScript(node: Node): boolean {
|
|
58
|
-
const cached = this.cache.get(node);
|
|
59
|
-
if (cached !==
|
|
66
|
+
const cached = this.cache.get(node.id);
|
|
67
|
+
if (cached !== 0) return cached === Answer.Yes;
|
|
60
68
|
const own = ownFacts(node);
|
|
61
69
|
let result = (own & Facts.TypeScript) !== 0;
|
|
62
70
|
if (!result && (own & Facts.Final) === 0) {
|
|
@@ -66,7 +74,7 @@ export class TypeScriptFacts extends NodeVisitor {
|
|
|
66
74
|
result = this.found;
|
|
67
75
|
this.found = saved;
|
|
68
76
|
}
|
|
69
|
-
this.cache.set(node, result);
|
|
77
|
+
this.cache.set(node.id, result ? Answer.Yes : Answer.No);
|
|
70
78
|
return result;
|
|
71
79
|
}
|
|
72
80
|
|
|
@@ -26,6 +26,7 @@ import {
|
|
|
26
26
|
getModifiers,
|
|
27
27
|
getName,
|
|
28
28
|
} from '../ast.js';
|
|
29
|
+
import { ClusteredIntLinkTable } from '../link-tables.js';
|
|
29
30
|
import { isTypeNodeKind } from '../printer/utilities.js';
|
|
30
31
|
import { SyntaxKind } from '../syntax-kind.js';
|
|
31
32
|
import { TokenFlags } from '../types.js';
|
|
@@ -75,22 +76,26 @@ const enum Exclusions {
|
|
|
75
76
|
BindingPattern = SubtreeFacts.ContainsRestOrSpread,
|
|
76
77
|
}
|
|
77
78
|
|
|
79
|
+
/** Marks a computed entry of `SyntaxFacts.cache`, whose facts may be `None`. */
|
|
80
|
+
const computedFacts = 1 << 30;
|
|
81
|
+
|
|
78
82
|
/** Memoized subtree facts for one emit; synthesized nodes get theirs on first use. */
|
|
79
83
|
export class SyntaxFacts extends NodeVisitor {
|
|
80
|
-
|
|
84
|
+
/** The facts of each node, by node id, with `computedFacts` set. */
|
|
85
|
+
private readonly cache: ClusteredIntLinkTable;
|
|
81
86
|
private collected: SubtreeFacts;
|
|
82
87
|
|
|
83
88
|
constructor() {
|
|
84
89
|
super();
|
|
85
|
-
this.cache = new
|
|
90
|
+
this.cache = new ClusteredIntLinkTable();
|
|
86
91
|
this.collected = SubtreeFacts.None;
|
|
87
92
|
}
|
|
88
93
|
|
|
89
94
|
of(node: Node): SubtreeFacts {
|
|
90
|
-
const cached = this.cache.get(node);
|
|
91
|
-
if (cached !==
|
|
95
|
+
const cached = this.cache.get(node.id);
|
|
96
|
+
if (cached !== 0) return cached & ~computedFacts;
|
|
92
97
|
const facts = this.compute(node);
|
|
93
|
-
this.cache.set(node, facts);
|
|
98
|
+
this.cache.set(node.id, facts | computedFacts);
|
|
94
99
|
return facts;
|
|
95
100
|
}
|
|
96
101
|
|
|
@@ -24,9 +24,9 @@ import {
|
|
|
24
24
|
getIsTypeOnly,
|
|
25
25
|
} from '../ast.js';
|
|
26
26
|
import { getStrictOptionValue } from '../options.js';
|
|
27
|
-
import { Symbol, SymbolFlags } from '../symbol.js';
|
|
28
27
|
import { SyntaxKind } from '../syntax-kind.js';
|
|
29
28
|
import { ConstantKind, type ReferenceResolver } from './reference-resolver.js';
|
|
29
|
+
import { declarationAt, declarationCount, getDeclarations, Symbol, SymbolFlags } from '../symbol.js';
|
|
30
30
|
|
|
31
31
|
/** What a type reference in decorator metadata serializes to. */
|
|
32
32
|
export const enum TypeReferenceSerializationKind {
|
|
@@ -62,9 +62,9 @@ export function getTypeReferenceSerializationKind(
|
|
|
62
62
|
let isTypeOnly = false;
|
|
63
63
|
if (typeName instanceof QualifiedName) {
|
|
64
64
|
const root = resolveEntityName(resolver, getFirstIdentifier(typeName), SymbolFlags.Value, true, location);
|
|
65
|
-
if (root !== undefined && root !== unknownSymbol && root
|
|
65
|
+
if (root !== undefined && root !== unknownSymbol && declarationCount(root) > 0) {
|
|
66
66
|
isTypeOnly = true;
|
|
67
|
-
for (const declaration of root
|
|
67
|
+
for (const declaration of getDeclarations(root))
|
|
68
68
|
if (!isTypeOnlyImportOrExportDeclaration(declaration)) {
|
|
69
69
|
isTypeOnly = false;
|
|
70
70
|
break;
|
|
@@ -155,8 +155,8 @@ function hasConstructSignature(resolver: ReferenceResolver, type: Node, location
|
|
|
155
155
|
if (type instanceof TypeReferenceNode) {
|
|
156
156
|
const symbol = resolveEntityName(resolver, type.typeName, SymbolFlags.Type, false, location);
|
|
157
157
|
if (symbol === undefined || symbol === unknownSymbol) return false;
|
|
158
|
-
for (let i = 0; i < symbol
|
|
159
|
-
const declaration = symbol
|
|
158
|
+
for (let i = 0; i < declarationCount(symbol); i++) {
|
|
159
|
+
const declaration = declarationAt(symbol, i);
|
|
160
160
|
if (
|
|
161
161
|
declaration instanceof InterfaceDeclaration &&
|
|
162
162
|
hasMember(declaration.members.nodes, SyntaxKind.ConstructSignature)
|
|
@@ -196,22 +196,22 @@ class TypeClassifier {
|
|
|
196
196
|
}
|
|
197
197
|
if ((flags & SymbolFlags.Class) !== 0) return TypeReferenceSerializationKind.ObjectType;
|
|
198
198
|
if ((flags & SymbolFlags.TypeAlias) !== 0) {
|
|
199
|
-
for (let i = 0; i < symbol
|
|
200
|
-
const declaration = symbol
|
|
199
|
+
for (let i = 0; i < declarationCount(symbol); i++) {
|
|
200
|
+
const declaration = declarationAt(symbol, i);
|
|
201
201
|
if (declaration instanceof TypeAliasDeclaration)
|
|
202
202
|
return this.ofTypeNode(declaration.type, declaration, depth + 1);
|
|
203
203
|
}
|
|
204
204
|
return TypeReferenceSerializationKind.ObjectType;
|
|
205
205
|
}
|
|
206
206
|
if ((flags & SymbolFlags.TypeParameter) !== 0) {
|
|
207
|
-
const declaration = symbol
|
|
207
|
+
const declaration = declarationCount(symbol) > 0 ? symbol.declaration! : undefined;
|
|
208
208
|
if (declaration instanceof TypeParameterDeclaration && declaration.constraint !== undefined)
|
|
209
209
|
return this.ofTypeNode(declaration.constraint, declaration, depth + 1);
|
|
210
210
|
return TypeReferenceSerializationKind.ObjectType;
|
|
211
211
|
}
|
|
212
212
|
if ((flags & SymbolFlags.Interface) !== 0) {
|
|
213
|
-
for (let i = 0; i < symbol
|
|
214
|
-
const declaration = symbol
|
|
213
|
+
for (let i = 0; i < declarationCount(symbol); i++) {
|
|
214
|
+
const declaration = declarationAt(symbol, i);
|
|
215
215
|
if (
|
|
216
216
|
declaration instanceof InterfaceDeclaration &&
|
|
217
217
|
hasMember(declaration.members.nodes, SyntaxKind.CallSignature)
|
|
@@ -226,8 +226,8 @@ class TypeClassifier {
|
|
|
226
226
|
private ofEnum(symbol: Symbol): TypeReferenceSerializationKind {
|
|
227
227
|
let strings = false;
|
|
228
228
|
let numbers = false;
|
|
229
|
-
for (let i = 0; i < symbol
|
|
230
|
-
const declaration = symbol
|
|
229
|
+
for (let i = 0; i < declarationCount(symbol); i++) {
|
|
230
|
+
const declaration = declarationAt(symbol, i);
|
|
231
231
|
if (!(declaration instanceof EnumDeclaration)) continue;
|
|
232
232
|
const members = declaration.members.nodes;
|
|
233
233
|
for (let j = 0; j < members.length; j++) {
|
|
@@ -721,16 +721,13 @@ export class Orchestrator {
|
|
|
721
721
|
const host = new BuildCompilerHost(sys, this.fs, this.locale);
|
|
722
722
|
const configOptions = config.options;
|
|
723
723
|
const checkers = threads ? checkerThreads(configOptions.checkers, configOptions.singleThreaded) : 1;
|
|
724
|
-
if (
|
|
724
|
+
if (threads && configOptions.singleThreaded !== true && parallelParse.spawn !== undefined) {
|
|
725
725
|
// Threads parse and bind the program's files ahead of it (parallel-parse.ts), as for plain
|
|
726
|
-
// compiles
|
|
727
|
-
//
|
|
728
|
-
// program's FileLoader takes the files they prepared
|
|
729
|
-
//
|
|
730
|
-
//
|
|
731
|
-
// order of its resolutions and on what its own caches hold. Declaration files that earlier
|
|
732
|
-
// projects of the build parsed come from the build's cache, and parse threads don't load
|
|
733
|
-
// them again.
|
|
726
|
+
// compiles. Here also when the program is checked on this thread, with one checker or after a
|
|
727
|
+
// change with old build info, whose program is parsed in full all the same. The
|
|
728
|
+
// program's FileLoader takes the files they prepared and the resolutions found loading them.
|
|
729
|
+
// Declaration files that earlier projects of the build parsed come from the build's cache,
|
|
730
|
+
// and parse threads don't load them again.
|
|
734
731
|
const libraryDirectory = getNormalizedAbsolutePath(sys.defaultLibraryPath, sys.currentDirectory);
|
|
735
732
|
const session = new ParseSession(
|
|
736
733
|
parseThreads(checkers),
|
|
@@ -742,9 +739,15 @@ export class Orchestrator {
|
|
|
742
739
|
buildSourceFileNames.has(kind === LoadKind.Library ? combinePaths(libraryDirectory, name) : name),
|
|
743
740
|
);
|
|
744
741
|
session.start(config.fileNames, () => {
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
742
|
+
// The program takes the resolutions the threads found, as `tsc -p` does, and is loaded
|
|
743
|
+
// again resolving every file itself only where their `package.json` lookups may miss some
|
|
744
|
+
// of its own (`hasAllPackageJsonLookups`), which the build info lists.
|
|
745
|
+
let program = new Program(config, host, new FileLoader(host, config));
|
|
746
|
+
if (!program.hasAllPackageJsonLookups()) {
|
|
747
|
+
const loader = new FileLoader(host, config);
|
|
748
|
+
loader.takesPreparedResolutions = false;
|
|
749
|
+
program = new Program(config, host, loader);
|
|
750
|
+
}
|
|
748
751
|
reportPreparedFiles(program.getSourceFiles().map((f) => f.fileName));
|
|
749
752
|
if (!this.checkAndEmit(task, program, parseStart, times, oldSnapshot, mayUseThreads, then)) then();
|
|
750
753
|
});
|
|
@@ -824,7 +827,7 @@ export class Orchestrator {
|
|
|
824
827
|
this.emitAndReport(task, checked, times, oldSnapshot, undefined, incrementalProgram);
|
|
825
828
|
return false;
|
|
826
829
|
}
|
|
827
|
-
const files = incrementalProgram.
|
|
830
|
+
const files = incrementalProgram.filesForCheckers();
|
|
828
831
|
if (!rechecksOnThreads(files, count, options.checkers !== undefined)) {
|
|
829
832
|
this.emitAndReport(task, checked, times, oldSnapshot, undefined, incrementalProgram);
|
|
830
833
|
return false;
|
|
@@ -839,6 +842,7 @@ export class Orchestrator {
|
|
|
839
842
|
},
|
|
840
843
|
true,
|
|
841
844
|
incrementalProgram.emitKindsOnCheckers(files),
|
|
845
|
+
incrementalProgram.checksOnCheckers,
|
|
842
846
|
);
|
|
843
847
|
return true;
|
|
844
848
|
}
|
package/src/compiler/tsc-cli.ts
CHANGED
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
type Locale,
|
|
19
19
|
type MessageWithArgs,
|
|
20
20
|
} from './diagnostics.js';
|
|
21
|
-
import { CompilerHost, FileLoader } from './file-loader.js';
|
|
21
|
+
import { CompilerHost, FileLoader, releaseLater } from './file-loader.js';
|
|
22
22
|
import { CachedFileSystem, FileSystem, type DirectoryEntries } from './file-system.js';
|
|
23
23
|
import { Program, sortAndDeduplicateDiagnostics } from './program.js';
|
|
24
24
|
import { ConfigParser, ParsedCommandLine as ProjectConfig } from './tsconfig.js';
|
|
@@ -437,7 +437,7 @@ function executeCompile(sys: System, commandLine: ParsedCommandLine): CommandLin
|
|
|
437
437
|
config.fileNames.length > 0,
|
|
438
438
|
);
|
|
439
439
|
// While the threads load files, the program's first step (a task per root file, which looks
|
|
440
|
-
// the file up) runs, and the
|
|
440
|
+
// the file up) runs, and the program's loader takes the files they return as they come.
|
|
441
441
|
const host = new SystemCompilerHost(sys, fs, locale);
|
|
442
442
|
const loader = new FileLoader(host, config);
|
|
443
443
|
let rootFilesAdded = false;
|
|
@@ -447,7 +447,7 @@ function executeCompile(sys: System, commandLine: ParsedCommandLine): CommandLin
|
|
|
447
447
|
const resolvesPackageJsons = config.configName !== '' && config.buildInfoFileName() !== '';
|
|
448
448
|
session.onIdle = (batch) => {
|
|
449
449
|
if (!rootFilesAdded) rootFilesAdded = loader.addRootFiles(rootFilesPerChunk);
|
|
450
|
-
loader.
|
|
450
|
+
loader.walkAhead(batch.files);
|
|
451
451
|
if (resolvesPackageJsons) {
|
|
452
452
|
const lookups = batch.packageJsons;
|
|
453
453
|
for (let k = 0; k < lookups.directories.length; k++)
|
|
@@ -471,6 +471,8 @@ function executeCompile(sys: System, commandLine: ParsedCommandLine): CommandLin
|
|
|
471
471
|
result = createProgram(host, own);
|
|
472
472
|
}
|
|
473
473
|
done(result);
|
|
474
|
+
// The session's callbacks keep the loader: its tasks go once checking has started.
|
|
475
|
+
releaseLater(loader);
|
|
474
476
|
});
|
|
475
477
|
// The build info of an incremental program is read while the threads parse: reading it needs
|
|
476
478
|
// only the config (compile and recheckInParallel, tsc-compile.ts, take it from here).
|
|
@@ -504,11 +506,12 @@ export const rootFilesPerChunk = 32;
|
|
|
504
506
|
|
|
505
507
|
/**
|
|
506
508
|
* Whether threads parse and bind the files of a program with `options` ahead of it (parallel-parse.ts):
|
|
507
|
-
*
|
|
508
|
-
* on this thread
|
|
509
|
+
* unless `--singleThreaded` is given, as tsgo parses on every core whatever its checker count. Also with
|
|
510
|
+
* one checker, which checks on this thread, and for an incremental program with build info, whose
|
|
511
|
+
* program is parsed in full all the same, as in build mode.
|
|
509
512
|
*/
|
|
510
513
|
function parsesAhead(options: CompilerOptions): boolean {
|
|
511
|
-
return
|
|
514
|
+
return options.singleThreaded !== true && parallelParse.spawn !== undefined;
|
|
512
515
|
}
|
|
513
516
|
|
|
514
517
|
/**
|