tsc-ts 0.0.6 → 0.0.8
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 +57 -18
- package/dist/api/compiler/ast.js +134 -39
- package/dist/api/compiler/binder-utilities.js +2 -2
- package/dist/api/compiler/binder.js +6 -6
- package/dist/api/compiler/checker-calls.js +4 -4
- package/dist/api/compiler/checker-contextual.js +1 -1
- package/dist/api/compiler/checker-declaration-order.js +3 -2
- package/dist/api/compiler/checker-declared-types.js +6 -3
- package/dist/api/compiler/checker-deprecation.js +14 -13
- package/dist/api/compiler/checker-destructuring.js +3 -2
- 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-grammar.js +5 -5
- package/dist/api/compiler/checker-inference.d.ts +20 -10
- package/dist/api/compiler/checker-inference.js +48 -25
- package/dist/api/compiler/checker-members.d.ts +27 -0
- package/dist/api/compiler/checker-members.js +165 -0
- package/dist/api/compiler/checker-modules.d.ts +14 -0
- package/dist/api/compiler/checker-modules.js +73 -1
- package/dist/api/compiler/checker-symbol-types.js +5 -5
- package/dist/api/compiler/checker-symbols.js +3 -1
- package/dist/api/compiler/checker.d.ts +16 -0
- package/dist/api/compiler/checker.js +17 -0
- package/dist/api/compiler/diagnostics.js +9 -5
- package/dist/api/compiler/parallel-parse.js +3 -1
- package/dist/api/compiler/parser.d.ts +7 -0
- package/dist/api/compiler/parser.js +73 -41
- 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 +11 -1
- package/dist/api/compiler/relations.js +8 -3
- package/dist/api/compiler/reparser.js +13 -5
- 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-pseudo.js +2 -2
- package/dist/api/compiler/transformers/module.js +2 -2
- package/dist/api/compiler/transformers/optional-chain.js +3 -3
- package/dist/api/compiler/transformers/subtree-facts.js +2 -2
- 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/visitor-base.js +3 -3
- package/dist/api/compiler/tsconfig.js +2 -2
- package/package.json +9 -9
- package/src/compiler/ast.ts +184 -59
- package/src/compiler/binder-utilities.ts +2 -1
- package/src/compiler/binder.ts +11 -5
- package/src/compiler/checker-calls.ts +5 -3
- package/src/compiler/checker-contextual.ts +1 -1
- package/src/compiler/checker-declaration-order.ts +3 -2
- package/src/compiler/checker-declared-types.ts +6 -3
- package/src/compiler/checker-deprecation.ts +13 -11
- package/src/compiler/checker-destructuring.ts +11 -2
- package/src/compiler/checker-emit-helpers.ts +5 -4
- package/src/compiler/checker-grammar.ts +5 -3
- package/src/compiler/checker-inference.ts +49 -25
- package/src/compiler/checker-members.ts +164 -0
- package/src/compiler/checker-modules.ts +92 -1
- package/src/compiler/checker-symbol-types.ts +14 -4
- package/src/compiler/checker-symbols.ts +4 -1
- package/src/compiler/checker.ts +19 -0
- package/src/compiler/decoder.ts +5 -4
- package/src/compiler/diagnostics.ts +10 -5
- package/src/compiler/encoder.ts +10 -5
- package/src/compiler/parallel-parse.ts +3 -1
- package/src/compiler/parser.ts +93 -39
- 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 +10 -1
- package/src/compiler/relations.ts +10 -2
- package/src/compiler/reparser.ts +14 -4
- package/src/compiler/transformers/class-fields.ts +12 -2
- package/src/compiler/transformers/commonjs-module.ts +3 -2
- package/src/compiler/transformers/declarations-pseudo.ts +2 -1
- package/src/compiler/transformers/declarations.ts +1 -1
- package/src/compiler/transformers/module.ts +2 -1
- package/src/compiler/transformers/optional-chain.ts +5 -2
- package/src/compiler/transformers/subtree-facts.ts +2 -1
- package/src/compiler/transformers/tagged-template.ts +2 -2
- package/src/compiler/transformers/type-eraser.ts +2 -1
- package/src/compiler/transformers/visitor-base.ts +10 -5
- package/src/compiler/tsconfig.ts +2 -1
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) {
|
|
@@ -55,6 +55,9 @@ import {
|
|
|
55
55
|
getMembers,
|
|
56
56
|
getModifiers,
|
|
57
57
|
getName,
|
|
58
|
+
callQuestionDotToken,
|
|
59
|
+
callTypeArguments,
|
|
60
|
+
newCallExpression,
|
|
58
61
|
} from '../ast.js';
|
|
59
62
|
import { isLeftHandSideExpression } from '../ast-utilities.js';
|
|
60
63
|
import {
|
|
@@ -1209,7 +1212,14 @@ export class ClassFieldsTransformer extends Transformer {
|
|
|
1209
1212
|
if (node instanceof CallExpression)
|
|
1210
1213
|
return factory.cloneNode(
|
|
1211
1214
|
node,
|
|
1212
|
-
|
|
1215
|
+
newCallExpression(
|
|
1216
|
+
node.expression,
|
|
1217
|
+
callQuestionDotToken(node),
|
|
1218
|
+
callTypeArguments(node),
|
|
1219
|
+
node.arguments,
|
|
1220
|
+
node.flags,
|
|
1221
|
+
false,
|
|
1222
|
+
),
|
|
1213
1223
|
);
|
|
1214
1224
|
return factory.cloneNode(node, node.deepClone());
|
|
1215
1225
|
}
|
|
@@ -1232,7 +1242,7 @@ export class ClassFieldsTransformer extends Transformer {
|
|
|
1232
1242
|
const call = factory.created(
|
|
1233
1243
|
new PropertyAccessExpression(
|
|
1234
1244
|
target,
|
|
1235
|
-
optional ? node
|
|
1245
|
+
optional ? callQuestionDotToken(node) : undefined,
|
|
1236
1246
|
factory.createIdentifier('call'),
|
|
1237
1247
|
optional ? NodeFlags.OptionalChain : NodeFlags.None,
|
|
1238
1248
|
),
|
|
@@ -63,6 +63,7 @@ import {
|
|
|
63
63
|
ModifierList,
|
|
64
64
|
getElements,
|
|
65
65
|
getName,
|
|
66
|
+
callQuestionDotToken,
|
|
66
67
|
} from '../ast.js';
|
|
67
68
|
import { getExternalModuleName, isImportCall, isInJSFile, isRequireCall } from '../ast-utilities.js';
|
|
68
69
|
import { isAssignmentExpression, isDestructuringAssignment } from '../binder-utilities.js';
|
|
@@ -1248,7 +1249,7 @@ export class CommonJSModuleTransformer extends Transformer {
|
|
|
1248
1249
|
const updated = this.factory.updateCallExpression(
|
|
1249
1250
|
node,
|
|
1250
1251
|
expression,
|
|
1251
|
-
node
|
|
1252
|
+
callQuestionDotToken(node),
|
|
1252
1253
|
undefined,
|
|
1253
1254
|
this.visitNodes(node.arguments)!,
|
|
1254
1255
|
node.flags,
|
|
@@ -1340,7 +1341,7 @@ export class CommonJSModuleTransformer extends Transformer {
|
|
|
1340
1341
|
if (rewritten !== first || visitedRest !== rest)
|
|
1341
1342
|
args = new NodeList(args.pos, args.end, [rewritten].concat(visitedRest));
|
|
1342
1343
|
}
|
|
1343
|
-
return factory.updateCallExpression(node, expression, node
|
|
1344
|
+
return factory.updateCallExpression(node, expression, callQuestionDotToken(node), undefined, args, node.flags);
|
|
1344
1345
|
}
|
|
1345
1346
|
|
|
1346
1347
|
private visitTaggedTemplateExpression(node: TaggedTemplateExpression): Node {
|
|
@@ -33,6 +33,7 @@ import {
|
|
|
33
33
|
getSymbol,
|
|
34
34
|
getType,
|
|
35
35
|
getTypeParameters,
|
|
36
|
+
propertyAssignmentPostfixToken,
|
|
36
37
|
} from '../ast.js';
|
|
37
38
|
import { isFunctionLike, nodeIsMissing } from '../ast-utilities.js';
|
|
38
39
|
import { getCombinedNodeFlags, hasSyntacticModifier, isIdentifierNamed } from '../binder-utilities.js';
|
|
@@ -544,7 +545,7 @@ export class PseudoChecker {
|
|
|
544
545
|
}
|
|
545
546
|
case SyntaxKind.PropertyAssignment: {
|
|
546
547
|
const assignment = property as PropertyAssignment;
|
|
547
|
-
const postfix = assignment
|
|
548
|
+
const postfix = propertyAssignmentPostfixToken(assignment);
|
|
548
549
|
members.push(
|
|
549
550
|
new PseudoMember(
|
|
550
551
|
PseudoMemberKind.Property,
|
|
@@ -2751,7 +2751,7 @@ const modifierKindsInOrder: SyntaxKind[] = [
|
|
|
2751
2751
|
SyntaxKind.OutKeyword,
|
|
2752
2752
|
];
|
|
2753
2753
|
|
|
2754
|
-
function preservedReferences(references: FileReference[]): FileReference[] {
|
|
2754
|
+
function preservedReferences(references: readonly FileReference[]): FileReference[] {
|
|
2755
2755
|
const result: FileReference[] = [];
|
|
2756
2756
|
for (const reference of references)
|
|
2757
2757
|
if (reference.preserve)
|
|
@@ -26,6 +26,7 @@ import {
|
|
|
26
26
|
StringLiteral,
|
|
27
27
|
NoSubstitutionTemplateLiteral,
|
|
28
28
|
Identifier,
|
|
29
|
+
callQuestionDotToken,
|
|
29
30
|
} from '../ast.js';
|
|
30
31
|
import { isAnyImportOrReExport, isImportCall, isInJSFile, isRequireCall } from '../ast-utilities.js';
|
|
31
32
|
import { type CompilerOptions, JsxEmit, ModuleKind, getEmitModuleKind, getIsolatedModules } from '../options.js';
|
|
@@ -392,7 +393,7 @@ export class ESModuleTransformer extends Transformer {
|
|
|
392
393
|
return factory.updateCallExpression(
|
|
393
394
|
node,
|
|
394
395
|
this.visitNode(node.expression)!,
|
|
395
|
-
node
|
|
396
|
+
callQuestionDotToken(node),
|
|
396
397
|
undefined,
|
|
397
398
|
new NodeList(node.arguments.pos, node.arguments.end, [argument].concat(rest)),
|
|
398
399
|
node.flags,
|
|
@@ -9,6 +9,8 @@ import {
|
|
|
9
9
|
PropertyAccessExpression,
|
|
10
10
|
SyntheticReferenceExpression,
|
|
11
11
|
TaggedTemplateExpression,
|
|
12
|
+
callQuestionDotToken,
|
|
13
|
+
newCallExpression,
|
|
12
14
|
} from '../ast.js';
|
|
13
15
|
import { skipParentheses } from '../binder-utilities.js';
|
|
14
16
|
import type { EmitContext } from '../printer/emit-context.js';
|
|
@@ -201,12 +203,13 @@ export class OptionalChainTransformer extends Transformer {
|
|
|
201
203
|
);
|
|
202
204
|
} else
|
|
203
205
|
rightExpression = factory.created(
|
|
204
|
-
|
|
206
|
+
newCallExpression(
|
|
205
207
|
rightExpression,
|
|
206
208
|
undefined,
|
|
207
209
|
undefined,
|
|
208
210
|
this.visitNodes(segment.arguments)!,
|
|
209
211
|
NodeFlags.None,
|
|
212
|
+
false,
|
|
210
213
|
),
|
|
211
214
|
);
|
|
212
215
|
}
|
|
@@ -231,7 +234,7 @@ export class OptionalChainTransformer extends Transformer {
|
|
|
231
234
|
function questionDotTokenOf(node: Node): Node | undefined {
|
|
232
235
|
if (node instanceof PropertyAccessExpression) return node.questionDotToken;
|
|
233
236
|
if (node instanceof ElementAccessExpression) return node.questionDotToken;
|
|
234
|
-
if (node instanceof CallExpression) return node
|
|
237
|
+
if (node instanceof CallExpression) return callQuestionDotToken(node);
|
|
235
238
|
return undefined;
|
|
236
239
|
}
|
|
237
240
|
|
|
@@ -32,6 +32,7 @@ import {
|
|
|
32
32
|
JsxSelfClosingElement,
|
|
33
33
|
HeritageClause,
|
|
34
34
|
getModifiers,
|
|
35
|
+
callTypeArguments,
|
|
35
36
|
} from '../ast.js';
|
|
36
37
|
import { ClusteredIntLinkTable } from '../link-tables.js';
|
|
37
38
|
import { isTypeNodeKind } from '../printer/utilities.js';
|
|
@@ -233,7 +234,7 @@ function ownFacts(node: Node): Facts {
|
|
|
233
234
|
? Facts.TypeScript
|
|
234
235
|
: Facts.None;
|
|
235
236
|
case SyntaxKind.CallExpression:
|
|
236
|
-
return node instanceof CallExpression && node
|
|
237
|
+
return node instanceof CallExpression && callTypeArguments(node) !== undefined ? Facts.TypeScript : Facts.None;
|
|
237
238
|
case SyntaxKind.NewExpression:
|
|
238
239
|
return node instanceof NewExpression && node.typeArguments !== undefined ? Facts.TypeScript : Facts.None;
|
|
239
240
|
case SyntaxKind.TaggedTemplateExpression:
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
// calls with a `__makeTemplateObject` template object.
|
|
3
3
|
import {
|
|
4
4
|
ArrayLiteralExpression,
|
|
5
|
-
CallExpression,
|
|
6
5
|
type Node,
|
|
7
6
|
NodeFlags,
|
|
8
7
|
NoSubstitutionTemplateLiteral,
|
|
@@ -13,6 +12,7 @@ import {
|
|
|
13
12
|
TemplateMiddle,
|
|
14
13
|
TemplateSpan,
|
|
15
14
|
TemplateTail,
|
|
15
|
+
newCallExpression,
|
|
16
16
|
} from '../ast.js';
|
|
17
17
|
import type { EmitContext } from '../printer/emit-context.js';
|
|
18
18
|
import { getSourceTextOfNode } from '../printer/utilities.js';
|
|
@@ -106,7 +106,7 @@ export class TaggedTemplateTransformer extends Transformer {
|
|
|
106
106
|
templateObject = factory.createLogicalOr(name, factory.createAssignment(name, helperCall));
|
|
107
107
|
}
|
|
108
108
|
args.unshift(templateObject);
|
|
109
|
-
const call = factory.created(
|
|
109
|
+
const call = factory.created(newCallExpression(tag, undefined, undefined, factory.createNodeList(args), 0, false));
|
|
110
110
|
call.pos = node.pos;
|
|
111
111
|
call.end = node.end;
|
|
112
112
|
return call;
|
|
@@ -38,6 +38,7 @@ import {
|
|
|
38
38
|
VariableDeclaration,
|
|
39
39
|
ArrowFunction,
|
|
40
40
|
getExpression,
|
|
41
|
+
callQuestionDotToken,
|
|
41
42
|
} from '../ast.js';
|
|
42
43
|
import { nodeIsMissing } from '../ast-utilities.js';
|
|
43
44
|
import type { CompilerOptions } from '../options.js';
|
|
@@ -317,7 +318,7 @@ export class TypeEraser extends Transformer {
|
|
|
317
318
|
return factory.updateCallExpression(
|
|
318
319
|
node,
|
|
319
320
|
this.required(node.expression),
|
|
320
|
-
node
|
|
321
|
+
callQuestionDotToken(node),
|
|
321
322
|
undefined,
|
|
322
323
|
this.visitNodes(node.arguments)!,
|
|
323
324
|
node.flags,
|
|
@@ -170,6 +170,11 @@ import {
|
|
|
170
170
|
WithStatement,
|
|
171
171
|
YieldExpression,
|
|
172
172
|
type Node,
|
|
173
|
+
propertyAssignmentPostfixToken,
|
|
174
|
+
propertyAssignmentType,
|
|
175
|
+
callQuestionDotToken,
|
|
176
|
+
propertyAssignmentModifiers,
|
|
177
|
+
callTypeArguments,
|
|
173
178
|
} from '../ast.js';
|
|
174
179
|
import { SyntaxKind } from '../syntax-kind.js';
|
|
175
180
|
import { VisitorHooks } from './visitor-hooks.js';
|
|
@@ -381,8 +386,8 @@ export abstract class VisitorBase extends VisitorHooks {
|
|
|
381
386
|
return this.factory.updateCallExpression(
|
|
382
387
|
node,
|
|
383
388
|
required(this.visitNode(node.expression), node.expression),
|
|
384
|
-
asOptionalToken(this.visitNode(node
|
|
385
|
-
this.visitNodes(node
|
|
389
|
+
asOptionalToken(this.visitNode(callQuestionDotToken(node))),
|
|
390
|
+
this.visitNodes(callTypeArguments(node)),
|
|
386
391
|
this.visitNodes(node.arguments)!,
|
|
387
392
|
node.flags,
|
|
388
393
|
);
|
|
@@ -1301,10 +1306,10 @@ export abstract class VisitorBase extends VisitorHooks {
|
|
|
1301
1306
|
if (node instanceof PropertyAssignment)
|
|
1302
1307
|
return this.factory.updatePropertyAssignment(
|
|
1303
1308
|
node,
|
|
1304
|
-
this.visitModifiers(node
|
|
1309
|
+
this.visitModifiers(propertyAssignmentModifiers(node)),
|
|
1305
1310
|
required(this.visitNode(node.name), node.name),
|
|
1306
|
-
asOptionalToken(this.visitNode(node
|
|
1307
|
-
this.visitNode(node
|
|
1311
|
+
asOptionalToken(this.visitNode(propertyAssignmentPostfixToken(node))),
|
|
1312
|
+
this.visitNode(propertyAssignmentType(node)),
|
|
1308
1313
|
required(this.visitNode(node.initializer), node.initializer),
|
|
1309
1314
|
);
|
|
1310
1315
|
break;
|
package/src/compiler/tsconfig.ts
CHANGED
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
StringLiteral,
|
|
23
23
|
type Node,
|
|
24
24
|
type SourceFile,
|
|
25
|
+
propertyAssignmentPostfixToken,
|
|
25
26
|
} from './ast.js';
|
|
26
27
|
import { enumNamesList } from './command-line.js';
|
|
27
28
|
import {
|
|
@@ -868,7 +869,7 @@ class ConfigFileConverter {
|
|
|
868
869
|
this.errors.push(diagnosticAtRange(this.file, element, Diagnostics.Property_assignment_expected));
|
|
869
870
|
continue;
|
|
870
871
|
}
|
|
871
|
-
const postfix = element
|
|
872
|
+
const postfix = propertyAssignmentPostfixToken(element);
|
|
872
873
|
if (postfix !== undefined && postfix.kind === SyntaxKind.QuestionToken) {
|
|
873
874
|
this.errors.push(
|
|
874
875
|
diagnosticAtRange(this.file, postfix, Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, '?'),
|