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
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
VariableDeclaration,
|
|
13
13
|
VariableStatement,
|
|
14
14
|
} from '../ast.js';
|
|
15
|
+
import { ClusteredLinkTable } from '../link-tables.js';
|
|
15
16
|
import { SyntaxKind } from '../syntax-kind.js';
|
|
16
17
|
import { EmitFlags, GeneratedIdentifierFlags } from './emit-flags.js';
|
|
17
18
|
import { AutoGenerateInfo } from './auto-generate.js';
|
|
@@ -135,8 +136,10 @@ export { AutoGenerateInfo, newAutoGenerateId } from './auto-generate.js';
|
|
|
135
136
|
export class EmitContext extends NodeFactory {
|
|
136
137
|
readonly autoGenerate: Map<Node, AutoGenerateInfo>;
|
|
137
138
|
readonly textSource: Map<Node, Node>;
|
|
138
|
-
|
|
139
|
-
readonly
|
|
139
|
+
/** The node each node was made from, by node id. */
|
|
140
|
+
readonly original: ClusteredLinkTable<Node>;
|
|
141
|
+
/** The emit data of nodes, by node id. */
|
|
142
|
+
readonly emitNodes: ClusteredLinkTable<EmitNode>;
|
|
140
143
|
private lastLookup: Node | undefined;
|
|
141
144
|
private lastEmitNode: EmitNode | undefined;
|
|
142
145
|
readonly assignedNames: Map<Node, Node>;
|
|
@@ -150,8 +153,8 @@ export class EmitContext extends NodeFactory {
|
|
|
150
153
|
super();
|
|
151
154
|
this.autoGenerate = new Map<Node, AutoGenerateInfo>();
|
|
152
155
|
this.textSource = new Map<Node, Node>();
|
|
153
|
-
this.original = new
|
|
154
|
-
this.emitNodes = new
|
|
156
|
+
this.original = new ClusteredLinkTable<Node>();
|
|
157
|
+
this.emitNodes = new ClusteredLinkTable<EmitNode>();
|
|
155
158
|
this.lastLookup = undefined;
|
|
156
159
|
this.lastEmitNode = undefined;
|
|
157
160
|
this.assignedNames = new Map<Node, Node>();
|
|
@@ -187,7 +190,7 @@ export class EmitContext extends NodeFactory {
|
|
|
187
190
|
let emitNode = this.lookup(node);
|
|
188
191
|
if (emitNode === undefined) {
|
|
189
192
|
emitNode = new EmitNode();
|
|
190
|
-
this.emitNodes.set(node, emitNode);
|
|
193
|
+
this.emitNodes.set(node.id, emitNode);
|
|
191
194
|
this.lastLookup = node;
|
|
192
195
|
this.lastEmitNode = emitNode;
|
|
193
196
|
}
|
|
@@ -197,7 +200,7 @@ export class EmitContext extends NodeFactory {
|
|
|
197
200
|
/** The emit data of `node`. The printer asks for several of a node's in a row, so the last answer is kept. */
|
|
198
201
|
private lookup(node: Node): EmitNode | undefined {
|
|
199
202
|
if (node === this.lastLookup) return this.lastEmitNode;
|
|
200
|
-
const emitNode = this.emitNodes.get(node);
|
|
203
|
+
const emitNode = this.emitNodes.get(node.id);
|
|
201
204
|
this.lastLookup = node;
|
|
202
205
|
this.lastEmitNode = emitNode;
|
|
203
206
|
return emitNode;
|
|
@@ -210,29 +213,31 @@ export class EmitContext extends NodeFactory {
|
|
|
210
213
|
}
|
|
211
214
|
|
|
212
215
|
setOriginalEx(node: Node, original: Node, allowOverwrite: boolean): void {
|
|
213
|
-
const existing = this.original.get(node);
|
|
216
|
+
const existing = this.original.get(node.id);
|
|
214
217
|
if (existing === undefined) {
|
|
215
|
-
this.original.set(node, original);
|
|
218
|
+
this.original.set(node.id, original);
|
|
216
219
|
const emitNode = this.lookup(original);
|
|
217
220
|
if (emitNode !== undefined) this.emitNode(node).copyFrom(emitNode);
|
|
218
|
-
} else if (allowOverwrite) this.original.set(node, original);
|
|
221
|
+
} else if (allowOverwrite) this.original.set(node.id, original);
|
|
219
222
|
else if (existing !== original) throw new Error('Original node already set.');
|
|
220
223
|
}
|
|
221
224
|
|
|
222
225
|
unsetOriginal(node: Node): boolean {
|
|
223
|
-
|
|
226
|
+
if (this.original.get(node.id) === undefined) return false;
|
|
227
|
+
this.original.set(node.id, undefined);
|
|
228
|
+
return true;
|
|
224
229
|
}
|
|
225
230
|
|
|
226
231
|
getOriginal(node: Node): Node | undefined {
|
|
227
|
-
return this.original.get(node);
|
|
232
|
+
return this.original.get(node.id);
|
|
228
233
|
}
|
|
229
234
|
|
|
230
235
|
/** The node at the end of the chain of original nodes. */
|
|
231
236
|
mostOriginal(node: Node): Node {
|
|
232
|
-
let original = this.original.get(node);
|
|
237
|
+
let original = this.original.get(node.id);
|
|
233
238
|
while (original !== undefined) {
|
|
234
239
|
node = original;
|
|
235
|
-
original = this.original.get(node);
|
|
240
|
+
original = this.original.get(node.id);
|
|
236
241
|
}
|
|
237
242
|
return node;
|
|
238
243
|
}
|
|
@@ -260,7 +265,7 @@ export class EmitContext extends NodeFactory {
|
|
|
260
265
|
return name;
|
|
261
266
|
let node = info.node!;
|
|
262
267
|
const id = info.id;
|
|
263
|
-
let original = this.original.get(node);
|
|
268
|
+
let original = this.original.get(node.id);
|
|
264
269
|
while (original !== undefined) {
|
|
265
270
|
node = original;
|
|
266
271
|
if (node instanceof Identifier || node instanceof PrivateIdentifier) {
|
|
@@ -275,7 +280,7 @@ export class EmitContext extends NodeFactory {
|
|
|
275
280
|
continue;
|
|
276
281
|
}
|
|
277
282
|
}
|
|
278
|
-
original = this.original.get(node);
|
|
283
|
+
original = this.original.get(node.id);
|
|
279
284
|
}
|
|
280
285
|
return node;
|
|
281
286
|
}
|
|
@@ -199,6 +199,13 @@ import {
|
|
|
199
199
|
type Node,
|
|
200
200
|
type NodeList,
|
|
201
201
|
type Token,
|
|
202
|
+
propertyAssignmentPostfixToken,
|
|
203
|
+
propertyAssignmentType,
|
|
204
|
+
callQuestionDotToken,
|
|
205
|
+
propertyAssignmentModifiers,
|
|
206
|
+
callTypeArguments,
|
|
207
|
+
newCallExpression,
|
|
208
|
+
newPropertyAssignment,
|
|
202
209
|
} from '../ast.js';
|
|
203
210
|
import type { SyntaxKind } from '../syntax-kind.js';
|
|
204
211
|
|
|
@@ -359,12 +366,12 @@ export abstract class NodeFactoryBase {
|
|
|
359
366
|
): CallExpression {
|
|
360
367
|
if (
|
|
361
368
|
expression !== node.expression ||
|
|
362
|
-
questionDotToken !== node
|
|
363
|
-
typeArguments !== node
|
|
369
|
+
questionDotToken !== callQuestionDotToken(node) ||
|
|
370
|
+
typeArguments !== callTypeArguments(node) ||
|
|
364
371
|
args !== node.arguments ||
|
|
365
372
|
flags !== node.flags
|
|
366
373
|
) {
|
|
367
|
-
const updated =
|
|
374
|
+
const updated = newCallExpression(expression, questionDotToken, typeArguments, args, flags, false);
|
|
368
375
|
this.finishUpdate(updated, node);
|
|
369
376
|
return updated;
|
|
370
377
|
}
|
|
@@ -2057,13 +2064,13 @@ export abstract class NodeFactoryBase {
|
|
|
2057
2064
|
initializer: Expression,
|
|
2058
2065
|
): PropertyAssignment {
|
|
2059
2066
|
if (
|
|
2060
|
-
modifiers !== node
|
|
2067
|
+
modifiers !== propertyAssignmentModifiers(node) ||
|
|
2061
2068
|
name !== node.name ||
|
|
2062
|
-
postfixToken !== node
|
|
2063
|
-
typeNode !== node
|
|
2069
|
+
postfixToken !== propertyAssignmentPostfixToken(node) ||
|
|
2070
|
+
typeNode !== propertyAssignmentType(node) ||
|
|
2064
2071
|
initializer !== node.initializer
|
|
2065
2072
|
) {
|
|
2066
|
-
const updated =
|
|
2073
|
+
const updated = newPropertyAssignment(modifiers, name, postfixToken, typeNode, initializer, false);
|
|
2067
2074
|
this.finishUpdate(updated, node);
|
|
2068
2075
|
return updated;
|
|
2069
2076
|
}
|
|
@@ -45,6 +45,8 @@ import {
|
|
|
45
45
|
VariableDeclarationList,
|
|
46
46
|
VariableStatement,
|
|
47
47
|
VoidExpression,
|
|
48
|
+
newCallExpression,
|
|
49
|
+
newPropertyAssignment,
|
|
48
50
|
} from '../ast.js';
|
|
49
51
|
import { modifierToFlag } from '../ast-utilities.js';
|
|
50
52
|
import { getNameOfDeclaration, getNonAssignedNameOfDeclaration, hasSyntacticModifier } from '../binder-utilities.js';
|
|
@@ -166,7 +168,7 @@ export abstract class NodeFactory extends NodeFactoryBase {
|
|
|
166
168
|
|
|
167
169
|
createCallExpression(expression: Node, args: Node[]): CallExpression {
|
|
168
170
|
return this.created(
|
|
169
|
-
|
|
171
|
+
newCallExpression(expression, undefined, undefined, this.createNodeList(args), NodeFlags.None, false),
|
|
170
172
|
);
|
|
171
173
|
}
|
|
172
174
|
|
|
@@ -265,7 +267,7 @@ export abstract class NodeFactory extends NodeFactoryBase {
|
|
|
265
267
|
}
|
|
266
268
|
|
|
267
269
|
createPropertyAssignment(name: Node, initializer: Node): PropertyAssignment {
|
|
268
|
-
return this.created(
|
|
270
|
+
return this.created(newPropertyAssignment(undefined, name, undefined, undefined, initializer, false));
|
|
269
271
|
}
|
|
270
272
|
|
|
271
273
|
createParameter(name: Node): ParameterDeclaration {
|
|
@@ -546,7 +548,7 @@ export abstract class NodeFactory extends NodeFactoryBase {
|
|
|
546
548
|
createMethodCall(object: Node, method: string, args: Node[]): CallExpression {
|
|
547
549
|
const callee = this.createPropertyAccessExpression(object, this.createIdentifier(method));
|
|
548
550
|
const flags = object instanceof CallExpression ? object.flags & NodeFlags.OptionalChain : NodeFlags.None;
|
|
549
|
-
return this.created(
|
|
551
|
+
return this.created(newCallExpression(callee, undefined, undefined, this.createNodeList(args), flags, false));
|
|
550
552
|
}
|
|
551
553
|
|
|
552
554
|
/** `Global.method(...args)`, such as `Math.pow(a, b)`. */
|
|
@@ -157,6 +157,8 @@ import {
|
|
|
157
157
|
getProperties,
|
|
158
158
|
getStatements,
|
|
159
159
|
getModifiers,
|
|
160
|
+
callQuestionDotToken,
|
|
161
|
+
callTypeArguments,
|
|
160
162
|
} from '../ast.js';
|
|
161
163
|
import { OperatorPrecedence } from '../ast-utilities.js';
|
|
162
164
|
import {
|
|
@@ -2248,8 +2250,8 @@ export class Printer extends NameGeneratorHost {
|
|
|
2248
2250
|
private emitCallExpression(node: CallExpression): boolean {
|
|
2249
2251
|
const state = this.enterNode(node);
|
|
2250
2252
|
this.emitCallee(node.expression, node);
|
|
2251
|
-
this.emitOptionalToken(node
|
|
2252
|
-
this.emitTypeArguments(node, node
|
|
2253
|
+
this.emitOptionalToken(callQuestionDotToken(node));
|
|
2254
|
+
this.emitTypeArguments(node, callTypeArguments(node));
|
|
2253
2255
|
this.emitList(ListItem.Argument, node, node.arguments, ListFormat.CallExpressionArguments);
|
|
2254
2256
|
this.exitNode(node, state);
|
|
2255
2257
|
return true;
|
|
@@ -2653,8 +2655,8 @@ export class Printer extends NameGeneratorHost {
|
|
|
2653
2655
|
return factory.updateCallExpression(
|
|
2654
2656
|
node,
|
|
2655
2657
|
this.parenthesizeExpressionForNoAsi(node.expression),
|
|
2656
|
-
node
|
|
2657
|
-
node
|
|
2658
|
+
callQuestionDotToken(node),
|
|
2659
|
+
callTypeArguments(node),
|
|
2658
2660
|
node.arguments,
|
|
2659
2661
|
node.flags,
|
|
2660
2662
|
);
|
|
@@ -2921,8 +2923,8 @@ export class Printer extends NameGeneratorHost {
|
|
|
2921
2923
|
this.write1('(');
|
|
2922
2924
|
this.emitExpression(call.expression, OperatorPrecedence.Lowest);
|
|
2923
2925
|
this.write1(')');
|
|
2924
|
-
this.emitOptionalToken(call
|
|
2925
|
-
this.emitTypeArguments(call, call
|
|
2926
|
+
this.emitOptionalToken(callQuestionDotToken(call));
|
|
2927
|
+
this.emitTypeArguments(call, callTypeArguments(call));
|
|
2926
2928
|
this.emitList(ListItem.Argument, call, call.arguments, ListFormat.CallExpressionArguments);
|
|
2927
2929
|
this.exitNode(call, callState);
|
|
2928
2930
|
}
|
|
@@ -32,6 +32,11 @@ import { CommentDirectiveKind } from './types.js';
|
|
|
32
32
|
/** What the checker needs, answered by a program. */
|
|
33
33
|
export class ProgramCheckerHost extends CheckerHost {
|
|
34
34
|
private specifierHost: ProgramModuleSpecifierHost | undefined = undefined;
|
|
35
|
+
/**
|
|
36
|
+
* `getSourceFileForResolvedModule` by resolved file name (null when there is none): every import of
|
|
37
|
+
* a module asks again, and the program finds a file by its path, which it computes from the name.
|
|
38
|
+
*/
|
|
39
|
+
private readonly resolvedSourceFiles = new Map<string, SourceFile | null>();
|
|
35
40
|
|
|
36
41
|
constructor(readonly program: Program) {
|
|
37
42
|
super();
|
|
@@ -54,7 +59,11 @@ export class ProgramCheckerHost extends CheckerHost {
|
|
|
54
59
|
}
|
|
55
60
|
|
|
56
61
|
getSourceFileForResolvedModule(fileName: string): SourceFile | undefined {
|
|
57
|
-
|
|
62
|
+
const known = this.resolvedSourceFiles.get(fileName);
|
|
63
|
+
if (known !== undefined) return known ?? undefined;
|
|
64
|
+
const file = this.program.getSourceFileForResolvedModule(fileName);
|
|
65
|
+
this.resolvedSourceFiles.set(fileName, file ?? null);
|
|
66
|
+
return file;
|
|
58
67
|
}
|
|
59
68
|
|
|
60
69
|
getModeForUsageLocation(file: SourceFile, location: Node): ModuleKind {
|
|
@@ -425,6 +434,8 @@ class Directives {
|
|
|
425
434
|
private readonly byLine = new Map<number, { pos: number; end: number; kind: CommentDirectiveKind }>();
|
|
426
435
|
|
|
427
436
|
constructor(readonly file: SourceFile) {
|
|
437
|
+
// Most files have no directives, and need no line starts.
|
|
438
|
+
if (file.commentDirectives.length === 0) return;
|
|
428
439
|
const lineStarts = file.diagnosticFile().getLineStarts();
|
|
429
440
|
for (const directive of file.commentDirectives) {
|
|
430
441
|
const line = computeLineOfPosition(lineStarts, directive.pos);
|
package/src/compiler/program.ts
CHANGED
|
@@ -152,12 +152,19 @@ export class Program implements OutputPathsHost {
|
|
|
152
152
|
this.includeProcessor = processed.includeProcessor;
|
|
153
153
|
for (const diagnostic of previous.programDiagnosticsList) this.programDiagnosticsList.push(diagnostic);
|
|
154
154
|
for (const path of previous.emitBlockingPaths) this.emitBlockingPaths.add(path);
|
|
155
|
-
|
|
155
|
+
// The files and include reasons it takes from a program shared with checker threads are immutable, and
|
|
156
|
+
// so is that program's symlink cache: this one computes its own then (`getSymlinkCache`).
|
|
157
|
+
this.shared = previous.shared;
|
|
158
|
+
if (!previous.shared) this.symlinks = previous.symlinks;
|
|
159
|
+
// The same files are emitted, so the common source directory is the same. Its diagnostics are those
|
|
160
|
+
// `previous` was created with (`IncludeProcessor.copy`).
|
|
161
|
+
this.commonSourceDirectoryValue = previous.commonSourceDirectoryValue;
|
|
156
162
|
} else {
|
|
157
163
|
this.processed = (loader ?? new FileLoader(host, commandLine)).load();
|
|
158
164
|
this.includeProcessor = this.processed.includeProcessor;
|
|
159
165
|
this.verifyCompilerOptions();
|
|
160
166
|
}
|
|
167
|
+
this.includeProcessor.noteProgramCreated();
|
|
161
168
|
}
|
|
162
169
|
|
|
163
170
|
/**
|
|
@@ -13,7 +13,6 @@ import {
|
|
|
13
13
|
import { getSymbolNameForPrivateIdentifier } from './binder.js';
|
|
14
14
|
import { getCombinedModifierFlags } from './binder-utilities.js';
|
|
15
15
|
import { Diagnostic, type DiagnosticMessage, Diagnostics, messageElidedInCompatibilityPyramid } from './diagnostics.js';
|
|
16
|
-
import { CheckFlags, type Symbol, SymbolFlags, getSymbolId } from './symbol.js';
|
|
17
16
|
import { SyntaxKind } from './syntax-kind.js';
|
|
18
17
|
import { isContextSensitive } from './checker-functions.js';
|
|
19
18
|
import { type Checker, createDiagnosticForNode } from './checker.js';
|
|
@@ -130,6 +129,8 @@ import {
|
|
|
130
129
|
getResolvedMember,
|
|
131
130
|
hasResolvedProperties,
|
|
132
131
|
resolvedPropertiesAreOptional,
|
|
132
|
+
positionsOfNamesFoundInSource,
|
|
133
|
+
firstUnmatchedProperty,
|
|
133
134
|
} from './checker-members.js';
|
|
134
135
|
import {
|
|
135
136
|
getParentOfSymbol,
|
|
@@ -224,6 +225,7 @@ import {
|
|
|
224
225
|
isNumericLiteralName,
|
|
225
226
|
maybeTypeOfKind,
|
|
226
227
|
} from './checker-utilities.js';
|
|
228
|
+
import { CheckFlags, declarationCount, getDeclarations, getSymbolId, type Symbol, SymbolFlags } from './symbol.js';
|
|
227
229
|
|
|
228
230
|
// ---- Results and caches
|
|
229
231
|
|
|
@@ -754,8 +756,8 @@ function isEnumTypeRelatedTo(c: Checker, source: Symbol, target: Symbol, reporte
|
|
|
754
756
|
c.enumRelation.set(key, RelationComparisonResult.Failed);
|
|
755
757
|
return false;
|
|
756
758
|
}
|
|
757
|
-
const sourceDecl = sourceProperty.
|
|
758
|
-
const targetDecl = targetProperty.
|
|
759
|
+
const sourceDecl = getDeclarations(sourceProperty).find((d) => d.kind === SyntaxKind.EnumMember);
|
|
760
|
+
const targetDecl = getDeclarations(targetProperty).find((d) => d.kind === SyntaxKind.EnumMember);
|
|
759
761
|
if (sourceDecl === undefined || targetDecl === undefined) continue;
|
|
760
762
|
computeEnumMemberValues(c, sourceDecl.parent!);
|
|
761
763
|
computeEnumMemberValues(c, targetDecl.parent!);
|
|
@@ -1375,8 +1377,8 @@ export class Relater extends TypeComparer {
|
|
|
1375
1377
|
return true;
|
|
1376
1378
|
}
|
|
1377
1379
|
const objectLiteralDeclaration =
|
|
1378
|
-
source.symbol !== undefined && source.symbol
|
|
1379
|
-
? source.symbol.
|
|
1380
|
+
source.symbol !== undefined && declarationCount(source.symbol) !== 0
|
|
1381
|
+
? source.symbol.declaration!
|
|
1380
1382
|
: undefined;
|
|
1381
1383
|
const valueDeclaration = prop.valueDeclaration;
|
|
1382
1384
|
let suggestion: Symbol | undefined = undefined;
|
|
@@ -2822,7 +2824,13 @@ export class Relater extends TypeComparer {
|
|
|
2822
2824
|
!isObjectLiteralType(source) &&
|
|
2823
2825
|
!isEmptyArrayLiteralType(c, source) &&
|
|
2824
2826
|
!isTupleType(source);
|
|
2825
|
-
const
|
|
2827
|
+
const targetProperties = getPropertiesOfType(c, target);
|
|
2828
|
+
// Where it is known which target names the source has, nothing else is looked up by name.
|
|
2829
|
+
const found = positionsOfNamesFoundInSource(c, source, target, targetProperties);
|
|
2830
|
+
const unmatchedProperty =
|
|
2831
|
+
found !== undefined
|
|
2832
|
+
? firstUnmatchedProperty(c, targetProperties, found, requireOptionalProperties)
|
|
2833
|
+
: getUnmatchedProperty(c, source, target, requireOptionalProperties, false);
|
|
2826
2834
|
if (unmatchedProperty !== undefined) {
|
|
2827
2835
|
if (reportErrors && shouldReportUnmatchedPropertyError(c, source, target))
|
|
2828
2836
|
this.reportUnmatchedProperty(source, target, unmatchedProperty, requireOptionalProperties);
|
|
@@ -2842,7 +2850,7 @@ export class Relater extends TypeComparer {
|
|
|
2842
2850
|
}
|
|
2843
2851
|
}
|
|
2844
2852
|
const numericNamesOnly = isTupleType(source) && isTupleType(target);
|
|
2845
|
-
for (const targetProp of
|
|
2853
|
+
for (const targetProp of found !== undefined ? found.map((i) => targetProperties[i]!) : targetProperties) {
|
|
2846
2854
|
if (excludedProperties !== undefined && excludedProperties.has(targetProp.name)) continue;
|
|
2847
2855
|
const name = targetProp.name;
|
|
2848
2856
|
if (
|
|
@@ -3037,9 +3045,9 @@ export class Relater extends TypeComparer {
|
|
|
3037
3045
|
names[0],
|
|
3038
3046
|
names[1],
|
|
3039
3047
|
]);
|
|
3040
|
-
if (unmatchedProperty
|
|
3048
|
+
if (declarationCount(unmatchedProperty) !== 0)
|
|
3041
3049
|
this.relatedInfo.push(
|
|
3042
|
-
createDiagnosticForNode(unmatchedProperty.
|
|
3050
|
+
createDiagnosticForNode(unmatchedProperty.declaration!, Diagnostics.X_0_is_declared_here, [propName]),
|
|
3043
3051
|
);
|
|
3044
3052
|
} else if (this.tryElaborateArrayLikeErrors(source, target, false)) {
|
|
3045
3053
|
const names = getTypeNamesForErrorDisplay(c, source, target);
|
|
@@ -3486,7 +3494,7 @@ export class Relater extends TypeComparer {
|
|
|
3486
3494
|
if (
|
|
3487
3495
|
(source.flags & TypeFlags.TypeParameter) !== 0 &&
|
|
3488
3496
|
source.symbol !== undefined &&
|
|
3489
|
-
source.symbol
|
|
3497
|
+
declarationCount(source.symbol) !== 0 &&
|
|
3490
3498
|
getConstraintOfType(c, source) === undefined
|
|
3491
3499
|
) {
|
|
3492
3500
|
const syntheticParam = cloneTypeParameter(c, source);
|
|
@@ -3494,7 +3502,7 @@ export class Relater extends TypeComparer {
|
|
|
3494
3502
|
if (hasNonCircularBaseConstraint(c, syntheticParam)) {
|
|
3495
3503
|
this.relatedInfo.push(
|
|
3496
3504
|
createDiagnosticForNode(
|
|
3497
|
-
source.symbol.
|
|
3505
|
+
source.symbol.declaration!,
|
|
3498
3506
|
Diagnostics.This_type_parameter_might_need_an_extends_0_constraint,
|
|
3499
3507
|
[typeToString(c, target)],
|
|
3500
3508
|
),
|
|
@@ -4504,7 +4512,7 @@ import { getTypeAliasInstantiation } from './checker-type-nodes.js';
|
|
|
4504
4512
|
|
|
4505
4513
|
export function getTypeParameterModifiers(tp: Type): ModifierFlags {
|
|
4506
4514
|
let flags = 0;
|
|
4507
|
-
if (tp.symbol !== undefined) for (const d of tp.symbol
|
|
4515
|
+
if (tp.symbol !== undefined) for (const d of getDeclarations(tp.symbol)) flags |= getCombinedModifierFlags(d);
|
|
4508
4516
|
return flags & (ModifierFlags.In | ModifierFlags.Out | ModifierFlags.Const);
|
|
4509
4517
|
}
|
|
4510
4518
|
|
package/src/compiler/reparser.ts
CHANGED
|
@@ -84,6 +84,7 @@ import {
|
|
|
84
84
|
getTypeExpression,
|
|
85
85
|
getTypeParameters,
|
|
86
86
|
type TypeNode,
|
|
87
|
+
FullPropertyAssignment,
|
|
87
88
|
} from './ast.js';
|
|
88
89
|
import {
|
|
89
90
|
isAssignmentOperator,
|
|
@@ -855,10 +856,14 @@ export class Reparser {
|
|
|
855
856
|
if (parent.kind !== SyntaxKind.ClassDeclaration && parent.kind !== SyntaxKind.ClassExpression) return false;
|
|
856
857
|
const className = tag.className;
|
|
857
858
|
const heritageClauses = getHeritageClauses(parent);
|
|
859
|
+
// Parsed lists may share their nodes array (empty ones do), so a longer list is a new list.
|
|
858
860
|
if (heritageClauses !== undefined) {
|
|
859
861
|
for (const clause of heritageClauses.nodes)
|
|
860
862
|
if (clause instanceof HeritageClause && (clause as HeritageClause).token === SyntaxKind.ImplementsKeyword) {
|
|
861
|
-
(clause as HeritageClause).types
|
|
863
|
+
const types = (clause as HeritageClause).types;
|
|
864
|
+
const nodes = types.nodes.slice();
|
|
865
|
+
nodes.push(this.addDeepCloneReparse(className));
|
|
866
|
+
(clause as HeritageClause).types = this.p.newNodeList(types.pos, types.end, nodes);
|
|
862
867
|
this.finishMutatedNode(clause);
|
|
863
868
|
return true;
|
|
864
869
|
}
|
|
@@ -868,7 +873,11 @@ export class Reparser {
|
|
|
868
873
|
this.finishReparsedNode(heritageClause, className);
|
|
869
874
|
if (heritageClauses === undefined)
|
|
870
875
|
setHeritageClauses(parent, this.p.newNodeList(className.pos, className.end, [heritageClause]));
|
|
871
|
-
else
|
|
876
|
+
else {
|
|
877
|
+
const nodes = heritageClauses.nodes.slice();
|
|
878
|
+
nodes.push(heritageClause);
|
|
879
|
+
setHeritageClauses(parent, this.p.newNodeList(heritageClauses.pos, heritageClauses.end, nodes));
|
|
880
|
+
}
|
|
872
881
|
this.finishMutatedNode(parent);
|
|
873
882
|
return true;
|
|
874
883
|
}
|
|
@@ -1420,8 +1429,9 @@ function setType(node: Node, value: Node): boolean {
|
|
|
1420
1429
|
(node as PropertyDeclaration).type = value;
|
|
1421
1430
|
return true;
|
|
1422
1431
|
}
|
|
1423
|
-
|
|
1424
|
-
|
|
1432
|
+
// Property assignments in JavaScript files, which are the ones reparsed, are full ones.
|
|
1433
|
+
if (node instanceof FullPropertyAssignment) {
|
|
1434
|
+
(node as FullPropertyAssignment).type = value;
|
|
1425
1435
|
return true;
|
|
1426
1436
|
}
|
|
1427
1437
|
if (node instanceof ShorthandPropertyAssignment) {
|