tsc-ts 0.0.5 → 0.0.7
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 +67 -27
- package/dist/api/compiler/ast.js +156 -55
- package/dist/api/compiler/binder-utilities.js +4 -3
- package/dist/api/compiler/binder.js +14 -13
- package/dist/api/compiler/checker-calls.js +7 -6
- package/dist/api/compiler/checker-contextual.js +1 -1
- 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-helpers.d.ts +2 -1
- package/dist/api/compiler/checker-emit-helpers.js +5 -4
- 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 +23 -9
- 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 +21 -11
- package/dist/api/compiler/checker-inference.js +57 -34
- 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 +32 -3
- package/dist/api/compiler/checker-members.js +240 -53
- package/dist/api/compiler/checker-modules.d.ts +15 -1
- package/dist/api/compiler/checker-modules.js +86 -14
- 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 +45 -8
- package/dist/api/compiler/checker.js +46 -9
- package/dist/api/compiler/diagnostics.d.ts +2 -8
- package/dist/api/compiler/diagnostics.js +13 -45
- 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 +7 -1
- package/dist/api/compiler/parser.d.ts +33 -16
- package/dist/api/compiler/parser.js +127 -98
- 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/printer/factory-base.js +8 -8
- package/dist/api/compiler/printer/factory.js +4 -4
- package/dist/api/compiler/printer/printer.js +6 -6
- package/dist/api/compiler/program-checker.d.ts +5 -0
- package/dist/api/compiler/program-checker.js +14 -1
- package/dist/api/compiler/program.js +9 -1
- package/dist/api/compiler/relations.d.ts +1 -1
- package/dist/api/compiler/relations.js +18 -13
- package/dist/api/compiler/reparser.js +13 -5
- 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/class-fields.js +3 -3
- package/dist/api/compiler/transformers/commonjs-module.js +3 -3
- package/dist/api/compiler/transformers/declarations-diagnostics.js +2 -1
- package/dist/api/compiler/transformers/declarations-pseudo.js +6 -4
- 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/module.js +2 -2
- package/dist/api/compiler/transformers/optional-chain.js +3 -3
- 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 +9 -7
- 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/tagged-template.js +2 -2
- package/dist/api/compiler/transformers/type-eraser.js +2 -2
- package/dist/api/compiler/transformers/type-serialization.js +12 -12
- package/dist/api/compiler/transformers/visitor-base.js +3 -3
- package/dist/api/compiler/tsconfig.js +2 -2
- package/package.json +9 -9
- package/src/compiler/ast.ts +211 -78
- package/src/compiler/binder-utilities.ts +4 -3
- package/src/compiler/binder.ts +26 -16
- package/src/compiler/checker-calls.ts +8 -6
- package/src/compiler/checker-contextual.ts +1 -1
- 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-helpers.ts +5 -4
- package/src/compiler/checker-emit-resolver.ts +5 -5
- package/src/compiler/checker-grammar.ts +22 -8
- package/src/compiler/checker-heritage.ts +21 -14
- package/src/compiler/checker-inference.ts +66 -34
- 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 +255 -47
- package/src/compiler/checker-modules.ts +115 -14
- 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 +50 -9
- package/src/compiler/decoder.ts +5 -4
- package/src/compiler/diagnostics.ts +14 -48
- package/src/compiler/encoder.ts +10 -5
- 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 +8 -1
- package/src/compiler/parse-thread.ts +0 -4
- package/src/compiler/parser.ts +173 -93
- package/src/compiler/printer/emit-context.ts +20 -15
- package/src/compiler/printer/factory-base.ts +14 -7
- package/src/compiler/printer/factory.ts +5 -3
- package/src/compiler/printer/printer.ts +8 -6
- package/src/compiler/program-checker.ts +12 -1
- package/src/compiler/program.ts +8 -1
- package/src/compiler/relations.ts +20 -12
- package/src/compiler/reparser.ts +14 -4
- 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/class-fields.ts +12 -2
- package/src/compiler/transformers/commonjs-module.ts +3 -2
- package/src/compiler/transformers/declarations-diagnostics.ts +2 -1
- package/src/compiler/transformers/declarations-pseudo.ts +9 -5
- package/src/compiler/transformers/declarations-syntactic.ts +17 -9
- package/src/compiler/transformers/declarations-tracker.ts +3 -3
- package/src/compiler/transformers/declarations.ts +7 -7
- package/src/compiler/transformers/module.ts +2 -1
- package/src/compiler/transformers/optional-chain.ts +5 -2
- package/src/compiler/transformers/reference-resolver.ts +37 -25
- package/src/compiler/transformers/subtree-facts.ts +15 -6
- package/src/compiler/transformers/syntax-facts.ts +10 -5
- package/src/compiler/transformers/tagged-template.ts +2 -2
- package/src/compiler/transformers/type-eraser.ts +2 -1
- package/src/compiler/transformers/type-serialization.ts +12 -12
- package/src/compiler/transformers/visitor-base.ts +10 -5
- 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
- package/src/compiler/tsconfig.ts +2 -1
|
@@ -84,7 +84,6 @@ import {
|
|
|
84
84
|
import { tryReuseExistingNode } from './node-builder-reuse.js';
|
|
85
85
|
import { EmitFlags } from './printer/emit-flags.js';
|
|
86
86
|
import { compareTypesIdentical } from './relations.js';
|
|
87
|
-
import { CheckFlags, type Symbol, SymbolFlags } from './symbol.js';
|
|
88
87
|
import { SyntaxKind } from './syntax-kind.js';
|
|
89
88
|
import { NodeBuilderFlags } from './transformers/declarations-resolver.js';
|
|
90
89
|
import {
|
|
@@ -106,6 +105,7 @@ import {
|
|
|
106
105
|
} from './transformers/declarations-pseudo.js';
|
|
107
106
|
import { tryGetTextOfPropertyName } from './transformers/declarations-syntactic.js';
|
|
108
107
|
import { TokenFlags } from './types.js';
|
|
108
|
+
import { CheckFlags, declarationCount, type Symbol, SymbolFlags } from './symbol.js';
|
|
109
109
|
|
|
110
110
|
/** Resolves no names: `undefined` in an expression is the undefined value, as tsgo's pseudochecker assumes. */
|
|
111
111
|
class NoNames extends NameResolver {
|
|
@@ -562,7 +562,7 @@ export function pseudoTypeEquivalentToType(
|
|
|
562
562
|
const targetProps = getPropertiesOfType(c, undefinedStripped);
|
|
563
563
|
// Accessor pairs are two members but one property.
|
|
564
564
|
let targetDeclCount = 0;
|
|
565
|
-
for (const prop of targetProps) targetDeclCount += prop
|
|
565
|
+
for (const prop of targetProps) targetDeclCount += declarationCount(prop);
|
|
566
566
|
if (pt.members.length !== targetDeclCount) return false;
|
|
567
567
|
for (const e of pt.members) {
|
|
568
568
|
let targetProp: Symbol | undefined = undefined;
|
|
@@ -214,7 +214,6 @@ import { TextWriter } from './printer/text-writer.js';
|
|
|
214
214
|
import type { NodeFactory } from './printer/factory.js';
|
|
215
215
|
import { isTypeIdenticalTo } from './relations.js';
|
|
216
216
|
import { isIdentifierText } from './scanner.js';
|
|
217
|
-
import { CheckFlags, type Symbol, SymbolFlags, type SymbolTable, getSymbolId } from './symbol.js';
|
|
218
217
|
import { SyntaxKind } from './syntax-kind.js';
|
|
219
218
|
import {
|
|
220
219
|
NodeBuilderFlags,
|
|
@@ -263,6 +262,15 @@ import {
|
|
|
263
262
|
couldAlreadyReferToUndefined,
|
|
264
263
|
undefinedType as pseudoUndefinedType,
|
|
265
264
|
} from './transformers/declarations-pseudo.js';
|
|
265
|
+
import {
|
|
266
|
+
CheckFlags,
|
|
267
|
+
declarationCount,
|
|
268
|
+
getDeclarations,
|
|
269
|
+
getSymbolId,
|
|
270
|
+
type Symbol,
|
|
271
|
+
SymbolFlags,
|
|
272
|
+
type SymbolTable,
|
|
273
|
+
} from './symbol.js';
|
|
266
274
|
|
|
267
275
|
const defaultMaximumTruncationLength = 160;
|
|
268
276
|
const noTruncationMaximumTruncationLength = 1_000_000;
|
|
@@ -693,7 +701,7 @@ export class NodeBuilder {
|
|
|
693
701
|
|
|
694
702
|
/** Adds the names bound by a destructured parameter; false if `param` isn't one. */
|
|
695
703
|
private addBindingPatternParameters(param: Symbol, table: SymbolTable): boolean {
|
|
696
|
-
for (const d of param
|
|
704
|
+
for (const d of getDeclarations(param)) {
|
|
697
705
|
if (d.kind !== SyntaxKind.Parameter) continue;
|
|
698
706
|
const name = asBindingPattern(getName(d));
|
|
699
707
|
if (name !== undefined) {
|
|
@@ -1431,14 +1439,14 @@ export class NodeBuilder {
|
|
|
1431
1439
|
const c = this.c;
|
|
1432
1440
|
let isStaticMethodSymbol = false;
|
|
1433
1441
|
if ((symbol.flags & SymbolFlags.Method) !== 0)
|
|
1434
|
-
for (const d of symbol
|
|
1442
|
+
for (const d of getDeclarations(symbol))
|
|
1435
1443
|
if (isStatic(d) && !hasLateBindableIndexSignature(c, d)) isStaticMethodSymbol = true;
|
|
1436
1444
|
let isNonLocalFunctionSymbol = false;
|
|
1437
1445
|
let isFunctionExpressionSymbol = false;
|
|
1438
1446
|
if ((symbol.flags & SymbolFlags.Function) !== 0) {
|
|
1439
1447
|
if (symbol.parent !== undefined) isNonLocalFunctionSymbol = true;
|
|
1440
1448
|
else
|
|
1441
|
-
for (const d of symbol
|
|
1449
|
+
for (const d of getDeclarations(symbol)) {
|
|
1442
1450
|
const parent = d.parent!;
|
|
1443
1451
|
if (parent.kind === SyntaxKind.SourceFile || parent.kind === SyntaxKind.ModuleBlock) {
|
|
1444
1452
|
isNonLocalFunctionSymbol = true;
|
|
@@ -1740,8 +1748,8 @@ export class NodeBuilder {
|
|
|
1740
1748
|
const saveEnclosingDeclaration = this.enclosingDeclaration;
|
|
1741
1749
|
this.enclosingDeclaration = undefined;
|
|
1742
1750
|
if (isLateBoundName(propertySymbol.name)) {
|
|
1743
|
-
if (propertySymbol
|
|
1744
|
-
const decl = propertySymbol.
|
|
1751
|
+
if (declarationCount(propertySymbol) > 0) {
|
|
1752
|
+
const decl = propertySymbol.declaration!;
|
|
1745
1753
|
if (hasLateBindableName(c, decl)) {
|
|
1746
1754
|
if (decl instanceof BinaryExpression) {
|
|
1747
1755
|
const name = getNameOfDeclaration(decl);
|
|
@@ -1756,7 +1764,7 @@ export class NodeBuilder {
|
|
|
1756
1764
|
}
|
|
1757
1765
|
this.enclosingDeclaration =
|
|
1758
1766
|
propertySymbol.valueDeclaration ??
|
|
1759
|
-
(propertySymbol
|
|
1767
|
+
(declarationCount(propertySymbol) > 0 ? propertySymbol.declaration! : saveEnclosingDeclaration);
|
|
1760
1768
|
const propertyName = getPropertyNameNodeForSymbol(this, propertySymbol);
|
|
1761
1769
|
this.enclosingDeclaration = saveEnclosingDeclaration;
|
|
1762
1770
|
this.approximateLength += symbolName(propertySymbol).length + 1;
|
|
@@ -1883,7 +1891,7 @@ export class NodeBuilder {
|
|
|
1883
1891
|
}
|
|
1884
1892
|
|
|
1885
1893
|
private isDeclaredInEnclosingFile(symbol: Symbol): boolean {
|
|
1886
|
-
for (const d of symbol
|
|
1894
|
+
for (const d of getDeclarations(symbol)) if (getSourceFileOfNode(d) === this.enclosingFile) return true;
|
|
1887
1895
|
return false;
|
|
1888
1896
|
}
|
|
1889
1897
|
|
|
@@ -2119,8 +2127,8 @@ export class NodeBuilder {
|
|
|
2119
2127
|
let result = symbolToName(this, typeParameter.symbol!, SymbolFlags.Type, true);
|
|
2120
2128
|
if (!(result instanceof Identifier)) return this.identifier('(Missing type parameter)');
|
|
2121
2129
|
const symbol = typeParameter.symbol;
|
|
2122
|
-
if (symbol !== undefined && symbol
|
|
2123
|
-
const decl = symbol.
|
|
2130
|
+
if (symbol !== undefined && declarationCount(symbol) > 0) {
|
|
2131
|
+
const decl = symbol.declaration!;
|
|
2124
2132
|
if (decl.kind === SyntaxKind.TypeParameter) result = this.setTextRange(result, getName(decl)) as Identifier;
|
|
2125
2133
|
}
|
|
2126
2134
|
if (generateNames) {
|
|
@@ -2484,7 +2492,7 @@ export class NodeBuilder {
|
|
|
2484
2492
|
): Node {
|
|
2485
2493
|
const c = this.c;
|
|
2486
2494
|
if (declaration === undefined && symbol !== undefined)
|
|
2487
|
-
declaration = symbol.valueDeclaration ?? (symbol
|
|
2495
|
+
declaration = symbol.valueDeclaration ?? (declarationCount(symbol) > 0 ? symbol.declaration! : undefined);
|
|
2488
2496
|
if (symbol === undefined && declaration !== undefined) symbol = getSymbolOfDeclaration(c, declaration);
|
|
2489
2497
|
let t = type;
|
|
2490
2498
|
if (t === undefined && symbol !== undefined) {
|
|
@@ -2567,7 +2575,7 @@ export class NodeBuilder {
|
|
|
2567
2575
|
: pseudo.getTypeOfDeclaration(declaration);
|
|
2568
2576
|
if (pt.kind === PseudoTypeKind.NoResult && declaration.kind === SyntaxKind.BinaryExpression) {
|
|
2569
2577
|
// The first annotated assignment declares the type for the rest.
|
|
2570
|
-
for (const d of symbol
|
|
2578
|
+
for (const d of getDeclarations(symbol))
|
|
2571
2579
|
if (getType(d) !== undefined) {
|
|
2572
2580
|
pt = pseudo.getTypeOfDeclaration(d);
|
|
2573
2581
|
break;
|
|
@@ -2814,9 +2822,9 @@ function isClassInstanceSide(c: Checker, t: Type): boolean {
|
|
|
2814
2822
|
|
|
2815
2823
|
function getTypeAliasForTypeLiteral(c: Checker, t: Type): Symbol | undefined {
|
|
2816
2824
|
const symbol = t.symbol;
|
|
2817
|
-
if (symbol === undefined || (symbol.flags & SymbolFlags.TypeLiteral) === 0 || symbol
|
|
2825
|
+
if (symbol === undefined || (symbol.flags & SymbolFlags.TypeLiteral) === 0 || declarationCount(symbol) === 0)
|
|
2818
2826
|
return undefined;
|
|
2819
|
-
let node = symbol.
|
|
2827
|
+
let node = symbol.declaration!.parent;
|
|
2820
2828
|
while (node !== undefined && node.kind === SyntaxKind.ParenthesizedType) node = node.parent;
|
|
2821
2829
|
if (node !== undefined && node.kind === SyntaxKind.TypeAliasDeclaration) return getSymbolOfDeclaration(c, node);
|
|
2822
2830
|
return undefined;
|
|
@@ -2825,7 +2833,7 @@ function getTypeAliasForTypeLiteral(c: Checker, t: Type): Symbol | undefined {
|
|
|
2825
2833
|
/** A copy of `t`, whose members are `resolved`, without its abstract construct signatures. */
|
|
2826
2834
|
function getResolvedTypeWithoutAbstractConstructSignatures(c: Checker, t: Type, resolved: StructuredType): Type {
|
|
2827
2835
|
if (resolved.constructSignatures.length === 0) return t;
|
|
2828
|
-
const side =
|
|
2836
|
+
const side = membersHolder(c, t);
|
|
2829
2837
|
if (side.objectTypeWithoutAbstractConstructSignatures !== undefined)
|
|
2830
2838
|
return side.objectTypeWithoutAbstractConstructSignatures;
|
|
2831
2839
|
const constructSignatures = resolved.constructSignatures.filter((s) => (s.flags & SignatureFlags.Abstract) === 0);
|
|
@@ -2865,7 +2873,7 @@ function getEffectiveConstraint(typeParameter: Node): Node | undefined {
|
|
|
2865
2873
|
|
|
2866
2874
|
function getTypeParameterModifiers(tp: Type): ModifierFlags {
|
|
2867
2875
|
let flags = ModifierFlags.None;
|
|
2868
|
-
if (tp.symbol !== undefined) for (const d of tp.symbol
|
|
2876
|
+
if (tp.symbol !== undefined) for (const d of getDeclarations(tp.symbol)) flags |= getCombinedModifierFlags(d);
|
|
2869
2877
|
return flags & (ModifierFlags.In | ModifierFlags.Out | ModifierFlags.Const);
|
|
2870
2878
|
}
|
|
2871
2879
|
|
|
@@ -440,7 +440,7 @@ function checksLittle(program: Program): boolean {
|
|
|
440
440
|
let text = 0;
|
|
441
441
|
for (const file of program.getSourceFiles()) {
|
|
442
442
|
if (file.isDeclarationFile && options.skipLibCheck === true) continue;
|
|
443
|
-
text += file.
|
|
443
|
+
text += file.end;
|
|
444
444
|
if (text >= littleText) return false;
|
|
445
445
|
}
|
|
446
446
|
return true;
|
|
@@ -454,10 +454,14 @@ export function autoCheckers(cpus: number, fit: number): number {
|
|
|
454
454
|
/**
|
|
455
455
|
* The number of threads that parse ahead of a program checked by `checkers` checkers: every CPU this
|
|
456
456
|
* process may run on, as tsgo parses on every core whatever its checker count (parse threads hand
|
|
457
|
-
* their files to the shared program; what else they allocate is reused by the checker threads)
|
|
457
|
+
* their files to the shared program; what else they allocate is reused by the checker threads), but
|
|
458
|
+
* one. The main thread hands out the chunks they load: with a thread on every CPU, it waits for a CPU
|
|
459
|
+
* each time a thread returns a chunk, and so does that thread for its next chunk (VS Code's parse took
|
|
460
|
+
* 18-57 ms longer with 16 threads on 16 CPUs than with 15).
|
|
458
461
|
*/
|
|
459
462
|
export function parseThreads(checkers: number): number {
|
|
460
|
-
|
|
463
|
+
const cpus = availableParallelism();
|
|
464
|
+
return Math.max(1, Math.min(cpus - 1, Math.max(checkers, Math.min(cpus, maxAutoCheckers))));
|
|
461
465
|
}
|
|
462
466
|
|
|
463
467
|
/**
|
|
@@ -572,15 +576,14 @@ let lengthsProgram: Program | undefined = undefined;
|
|
|
572
576
|
let lengthsOfProgram: number[] = [];
|
|
573
577
|
|
|
574
578
|
/**
|
|
575
|
-
* The text length of each of `program`'s files, by index, computed once per program
|
|
576
|
-
* builds a thread caches the UTF-16 length of only the few
|
|
577
|
-
* read
|
|
578
|
-
* several times (its cost, the load of each group candidate importing it, its position).
|
|
579
|
+
* The text length of each of `program`'s files, by index, computed once per program: a file's `end`,
|
|
580
|
+
* the length the parser found. In scriptc builds a thread caches the UTF-16 length of only the few
|
|
581
|
+
* non-ASCII strings it read last, so reading a non-ASCII file's `text.length` scans its text.
|
|
579
582
|
*/
|
|
580
583
|
export function textLengths(program: Program): number[] {
|
|
581
584
|
if (lengthsProgram !== program) {
|
|
582
585
|
const lengths: number[] = [];
|
|
583
|
-
for (const file of program.getSourceFiles()) lengths.push(file.
|
|
586
|
+
for (const file of program.getSourceFiles()) lengths.push(file.end);
|
|
584
587
|
lengthsProgram = program;
|
|
585
588
|
lengthsOfProgram = lengths;
|
|
586
589
|
}
|
|
@@ -86,6 +86,11 @@ export function preparedVersion(file: SourceFile): string {
|
|
|
86
86
|
return prepared !== undefined && prepared.file === file ? prepared.version : '';
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
+
/** Whether a parse thread prepared `fileName`. */
|
|
90
|
+
export function isPrepared(fileName: string): boolean {
|
|
91
|
+
return parallelParse.files.has(fileName);
|
|
92
|
+
}
|
|
93
|
+
|
|
89
94
|
/** What a parse thread's FileLoader found loading `fileName`, if the thread prepared it. */
|
|
90
95
|
export function preparedLoad(fileName: string): LoadedFile | undefined {
|
|
91
96
|
if (parallelParse.files.size === 0) return undefined;
|
|
@@ -489,7 +494,9 @@ export class ParseSession {
|
|
|
489
494
|
}
|
|
490
495
|
|
|
491
496
|
private post(i: number, chunk: LoadMessage): void {
|
|
492
|
-
|
|
497
|
+
// Published, the chunk reaches the thread by pointer: copying its names into the message took the
|
|
498
|
+
// main thread 25-45 us per chunk, which during config read delays the matching of root files.
|
|
499
|
+
this.workers[i]!.postMessage(publish(chunk));
|
|
493
500
|
this.outstanding[i] = this.outstanding[i]! + 1;
|
|
494
501
|
if (chunk.kinds[0] === LoadKind.Library && largeLibraries.has(chunk.names[0]!)) this.blocked[i] = true;
|
|
495
502
|
this.busy++;
|
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
import { publish } from '@scriptc/threads';
|
|
7
7
|
import { type ExternalModuleIndicatorOptions, ParseOptions, ScriptKind, type SourceFile } from './ast.js';
|
|
8
8
|
import { bindSourceFile } from './binder.js';
|
|
9
|
-
import { scanSiblingProperties } from './checker-symbol-types.js';
|
|
10
9
|
import { useThreadTextCaches } from './diagnostics.js';
|
|
11
10
|
import { CompilerHost, FileLoader } from './file-loader.js';
|
|
12
11
|
import { computeHash } from './incremental.js';
|
|
@@ -50,9 +49,6 @@ class PreparingHost extends CompilerHost {
|
|
|
50
49
|
);
|
|
51
50
|
const t2 = timeline ? performance.now() : 0;
|
|
52
51
|
bindSourceFile(file);
|
|
53
|
-
// Checkers look up the unions of the files tsgo checks with one checker (firstSiblingProperty):
|
|
54
|
-
// each file is scanned here once instead of by every checker.
|
|
55
|
-
file.siblingProperties = scanSiblingProperties(file, undefined);
|
|
56
52
|
if (timeline) {
|
|
57
53
|
const t3 = performance.now();
|
|
58
54
|
this.readMs += t1 - t0;
|