tsc-ts 0.1.3 → 0.1.4
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.
|
@@ -513,9 +513,13 @@ class InferenceState {
|
|
|
513
513
|
const sourceAlias = source.alias;
|
|
514
514
|
const targetAlias = target.alias;
|
|
515
515
|
if (sourceAlias !== undefined && targetAlias !== undefined && sourceAlias.symbol === targetAlias.symbol) {
|
|
516
|
-
// Instantiations of the same alias infer between their type arguments, once for each pair of types, as tsc
|
|
516
|
+
// Instantiations of the same alias infer between their type arguments, once for each pair of types, as tsc
|
|
517
|
+
// does. The pair is memoized, which keeps inference from type arguments from repeating exponentially (tsgo
|
|
518
|
+
// #64378), but it does not take part in invokeOnce's recursion-identity check: the identities of a recursive
|
|
519
|
+
// alias repeat through its properties, and below such a property that check reports a circularity and skips
|
|
520
|
+
// an inference that tsc 7.0.2 makes (#418).
|
|
517
521
|
if (sourceAlias.typeArguments.length !== 0 || targetAlias.typeArguments.length !== 0)
|
|
518
|
-
this.invokeOnce(source, target, 0 /* InferenceAction.AliasTypeArguments
|
|
522
|
+
this.invokeOnce(source, target, 0 /* InferenceAction.AliasTypeArguments */, false);
|
|
519
523
|
return;
|
|
520
524
|
}
|
|
521
525
|
if (source === target && (source.flags & 402653184 /* TypeFlags.UnionOrIntersection */) !== 0) {
|
|
@@ -718,8 +722,13 @@ class InferenceState {
|
|
|
718
722
|
else
|
|
719
723
|
this.inferFromTypes(source, target);
|
|
720
724
|
}
|
|
721
|
-
/**
|
|
722
|
-
|
|
725
|
+
/**
|
|
726
|
+
* Runs `action` once per source and target pair, stopping at circularities. With `checkRecursion` false, the pair
|
|
727
|
+
* is still memoized but its action neither joins the recursion stacks nor stops at the recursion identities the
|
|
728
|
+
* stacks hold; alias type arguments, which infer only between the type arguments of two instantiations of one
|
|
729
|
+
* declaration, are such a pair.
|
|
730
|
+
*/
|
|
731
|
+
invokeOnce(source, target, action, checkRecursion = true) {
|
|
723
732
|
// As in tsc, a pair is visited once for each priority and variance it is inferred with.
|
|
724
733
|
const mode = visitMode(this.priority, this.contravariant, this.bivariant);
|
|
725
734
|
const key = visitKey(source, target);
|
|
@@ -735,19 +744,21 @@ class InferenceState {
|
|
|
735
744
|
const caches = this.c.inferenceCaches;
|
|
736
745
|
const stackDepth = this.stackDepth;
|
|
737
746
|
const start = this.stackBase;
|
|
738
|
-
const end = start + stackDepth + 1;
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
this.
|
|
748
|
-
|
|
749
|
-
this.
|
|
750
|
-
|
|
747
|
+
const end = start + stackDepth + (checkRecursion ? 1 : 0);
|
|
748
|
+
if (checkRecursion) {
|
|
749
|
+
setStackEntry(caches.invokeSourceStack, end - 1, source);
|
|
750
|
+
setStackEntry(caches.invokeTargetStack, end - 1, target);
|
|
751
|
+
setNumberEntry(caches.invokeModeStack, end - 1, mode);
|
|
752
|
+
setNumberEntry(caches.invokeSourceIdentities, end - 1, 0);
|
|
753
|
+
setNumberEntry(caches.invokeTargetIdentities, end - 1, 0);
|
|
754
|
+
this.stackDepth = stackDepth + 1;
|
|
755
|
+
caches.invokeStackDepth = end;
|
|
756
|
+
if (isDeeplyNestedStackEntry(this.c, caches.invokeSourceStack, caches.invokeSourceIdentities, start, end, 2))
|
|
757
|
+
this.expandingFlags |= 1 /* ExpandingFlags.Source */;
|
|
758
|
+
if (isDeeplyNestedStackEntry(this.c, caches.invokeTargetStack, caches.invokeTargetIdentities, start, end, 2))
|
|
759
|
+
this.expandingFlags |= 2 /* ExpandingFlags.Target */;
|
|
760
|
+
}
|
|
761
|
+
if (!checkRecursion || this.expandingFlags !== 3 /* ExpandingFlags.Both */) {
|
|
751
762
|
switch (action) {
|
|
752
763
|
case 0 /* InferenceAction.AliasTypeArguments */:
|
|
753
764
|
this.inferFromAliasTypeArguments(source, target);
|
|
@@ -768,9 +779,11 @@ class InferenceState {
|
|
|
768
779
|
}
|
|
769
780
|
else
|
|
770
781
|
this.inferencePriority = -1 /* InferencePriority.Circularity */;
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
782
|
+
if (checkRecursion) {
|
|
783
|
+
this.stackDepth = stackDepth;
|
|
784
|
+
caches.invokeStackDepth = end - 1;
|
|
785
|
+
this.expandingFlags = saveExpandingFlags;
|
|
786
|
+
}
|
|
774
787
|
this.setVisited(source, target, key, mode, this.inferencePriority);
|
|
775
788
|
this.inferencePriority = Math.min(this.inferencePriority, saveInferencePriority);
|
|
776
789
|
}
|
|
@@ -901,9 +901,9 @@ function getTargetOfImportClause(c, node) {
|
|
|
901
901
|
function getTargetOfModuleDefault(c, moduleSymbol, node, dontResolveAlias) {
|
|
902
902
|
const file = getSourceFileDeclaration(moduleSymbol);
|
|
903
903
|
const specifier = getModuleSpecifierForImportOrExport(node);
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
904
|
+
// Also when the value declaration is a shorthand ambient module (`declare module "m";`): a declaration of
|
|
905
|
+
// the same module with a body merges into the symbol and can export a default.
|
|
906
|
+
const exportDefaultSymbol = resolveExportByName(c, moduleSymbol, "default" /* InternalSymbolName.Default */, node, dontResolveAlias);
|
|
907
907
|
if (specifier === undefined)
|
|
908
908
|
return exportDefaultSymbol;
|
|
909
909
|
let attributes;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tsc-ts",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "The TypeScript 7 compiler, ported to TypeScript and compiled to a native executable.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -40,12 +40,12 @@
|
|
|
40
40
|
"node": ">=20"
|
|
41
41
|
},
|
|
42
42
|
"optionalDependencies": {
|
|
43
|
-
"@tsc-ts/darwin-arm64": "0.1.
|
|
44
|
-
"@tsc-ts/darwin-x64": "0.1.
|
|
45
|
-
"@tsc-ts/linux-arm64-gnu": "0.1.
|
|
46
|
-
"@tsc-ts/linux-arm64-musl": "0.1.
|
|
47
|
-
"@tsc-ts/linux-x64-gnu": "0.1.
|
|
48
|
-
"@tsc-ts/linux-x64-musl": "0.1.
|
|
49
|
-
"@tsc-ts/win32-x64-msvc": "0.1.
|
|
43
|
+
"@tsc-ts/darwin-arm64": "0.1.4",
|
|
44
|
+
"@tsc-ts/darwin-x64": "0.1.4",
|
|
45
|
+
"@tsc-ts/linux-arm64-gnu": "0.1.4",
|
|
46
|
+
"@tsc-ts/linux-arm64-musl": "0.1.4",
|
|
47
|
+
"@tsc-ts/linux-x64-gnu": "0.1.4",
|
|
48
|
+
"@tsc-ts/linux-x64-musl": "0.1.4",
|
|
49
|
+
"@tsc-ts/win32-x64-msvc": "0.1.4"
|
|
50
50
|
}
|
|
51
51
|
}
|
|
@@ -853,9 +853,13 @@ class InferenceState {
|
|
|
853
853
|
const sourceAlias = source.alias;
|
|
854
854
|
const targetAlias = target.alias;
|
|
855
855
|
if (sourceAlias !== undefined && targetAlias !== undefined && sourceAlias.symbol === targetAlias.symbol) {
|
|
856
|
-
// Instantiations of the same alias infer between their type arguments, once for each pair of types, as tsc
|
|
856
|
+
// Instantiations of the same alias infer between their type arguments, once for each pair of types, as tsc
|
|
857
|
+
// does. The pair is memoized, which keeps inference from type arguments from repeating exponentially (tsgo
|
|
858
|
+
// #64378), but it does not take part in invokeOnce's recursion-identity check: the identities of a recursive
|
|
859
|
+
// alias repeat through its properties, and below such a property that check reports a circularity and skips
|
|
860
|
+
// an inference that tsc 7.0.2 makes (#418).
|
|
857
861
|
if (sourceAlias.typeArguments.length !== 0 || targetAlias.typeArguments.length !== 0)
|
|
858
|
-
this.invokeOnce(source, target, InferenceAction.AliasTypeArguments);
|
|
862
|
+
this.invokeOnce(source, target, InferenceAction.AliasTypeArguments, false);
|
|
859
863
|
return;
|
|
860
864
|
}
|
|
861
865
|
if (source === target && (source.flags & TypeFlags.UnionOrIntersection) !== 0) {
|
|
@@ -1059,8 +1063,13 @@ class InferenceState {
|
|
|
1059
1063
|
else this.inferFromTypes(source, target);
|
|
1060
1064
|
}
|
|
1061
1065
|
|
|
1062
|
-
/**
|
|
1063
|
-
|
|
1066
|
+
/**
|
|
1067
|
+
* Runs `action` once per source and target pair, stopping at circularities. With `checkRecursion` false, the pair
|
|
1068
|
+
* is still memoized but its action neither joins the recursion stacks nor stops at the recursion identities the
|
|
1069
|
+
* stacks hold; alias type arguments, which infer only between the type arguments of two instantiations of one
|
|
1070
|
+
* declaration, are such a pair.
|
|
1071
|
+
*/
|
|
1072
|
+
invokeOnce(source: Type, target: Type, action: InferenceAction, checkRecursion = true): void {
|
|
1064
1073
|
// As in tsc, a pair is visited once for each priority and variance it is inferred with.
|
|
1065
1074
|
const mode = visitMode(this.priority, this.contravariant, this.bivariant);
|
|
1066
1075
|
const key = visitKey(source, target);
|
|
@@ -1076,19 +1085,21 @@ class InferenceState {
|
|
|
1076
1085
|
const caches = this.c.inferenceCaches;
|
|
1077
1086
|
const stackDepth = this.stackDepth;
|
|
1078
1087
|
const start = this.stackBase;
|
|
1079
|
-
const end = start + stackDepth + 1;
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
this.
|
|
1089
|
-
|
|
1090
|
-
this.
|
|
1091
|
-
|
|
1088
|
+
const end = start + stackDepth + (checkRecursion ? 1 : 0);
|
|
1089
|
+
if (checkRecursion) {
|
|
1090
|
+
setStackEntry(caches.invokeSourceStack, end - 1, source);
|
|
1091
|
+
setStackEntry(caches.invokeTargetStack, end - 1, target);
|
|
1092
|
+
setNumberEntry(caches.invokeModeStack, end - 1, mode);
|
|
1093
|
+
setNumberEntry(caches.invokeSourceIdentities, end - 1, 0);
|
|
1094
|
+
setNumberEntry(caches.invokeTargetIdentities, end - 1, 0);
|
|
1095
|
+
this.stackDepth = stackDepth + 1;
|
|
1096
|
+
caches.invokeStackDepth = end;
|
|
1097
|
+
if (isDeeplyNestedStackEntry(this.c, caches.invokeSourceStack, caches.invokeSourceIdentities, start, end, 2))
|
|
1098
|
+
this.expandingFlags |= ExpandingFlags.Source;
|
|
1099
|
+
if (isDeeplyNestedStackEntry(this.c, caches.invokeTargetStack, caches.invokeTargetIdentities, start, end, 2))
|
|
1100
|
+
this.expandingFlags |= ExpandingFlags.Target;
|
|
1101
|
+
}
|
|
1102
|
+
if (!checkRecursion || this.expandingFlags !== ExpandingFlags.Both) {
|
|
1092
1103
|
switch (action) {
|
|
1093
1104
|
case InferenceAction.AliasTypeArguments:
|
|
1094
1105
|
this.inferFromAliasTypeArguments(source, target);
|
|
@@ -1107,9 +1118,11 @@ class InferenceState {
|
|
|
1107
1118
|
break;
|
|
1108
1119
|
}
|
|
1109
1120
|
} else this.inferencePriority = InferencePriority.Circularity;
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1121
|
+
if (checkRecursion) {
|
|
1122
|
+
this.stackDepth = stackDepth;
|
|
1123
|
+
caches.invokeStackDepth = end - 1;
|
|
1124
|
+
this.expandingFlags = saveExpandingFlags;
|
|
1125
|
+
}
|
|
1113
1126
|
this.setVisited(source, target, key, mode, this.inferencePriority);
|
|
1114
1127
|
this.inferencePriority = Math.min(this.inferencePriority, saveInferencePriority);
|
|
1115
1128
|
}
|
|
@@ -1331,9 +1331,9 @@ function getTargetOfModuleDefault(
|
|
|
1331
1331
|
): Symbol | undefined {
|
|
1332
1332
|
const file = getSourceFileDeclaration(moduleSymbol);
|
|
1333
1333
|
const specifier = getModuleSpecifierForImportOrExport(node);
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1334
|
+
// Also when the value declaration is a shorthand ambient module (`declare module "m";`): a declaration of
|
|
1335
|
+
// the same module with a body merges into the symbol and can export a default.
|
|
1336
|
+
const exportDefaultSymbol = resolveExportByName(c, moduleSymbol, InternalSymbolName.Default, node, dontResolveAlias);
|
|
1337
1337
|
if (specifier === undefined) return exportDefaultSymbol;
|
|
1338
1338
|
let attributes: ImportAttributes | undefined;
|
|
1339
1339
|
if (node.kind === SyntaxKind.ImportClause) attributes = getImportAttributes(node.parent!);
|