typescript 5.4.0-dev.20240110 → 5.4.0-dev.20240111
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/lib/tsc.js +72 -12
- package/lib/tsserver.js +87 -13
- package/lib/typescript.d.ts +1 -0
- package/lib/typescript.js +86 -13
- package/lib/typingsInstaller.js +1 -1
- package/package.json +2 -2
package/lib/tsc.js
CHANGED
|
@@ -18,7 +18,7 @@ and limitations under the License.
|
|
|
18
18
|
|
|
19
19
|
// src/compiler/corePublic.ts
|
|
20
20
|
var versionMajorMinor = "5.4";
|
|
21
|
-
var version = `${versionMajorMinor}.0-dev.
|
|
21
|
+
var version = `${versionMajorMinor}.0-dev.20240111`;
|
|
22
22
|
|
|
23
23
|
// src/compiler/core.ts
|
|
24
24
|
var emptyArray = [];
|
|
@@ -17671,6 +17671,9 @@ var stringReplace = String.prototype.replace;
|
|
|
17671
17671
|
function replaceFirstStar(s, replacement) {
|
|
17672
17672
|
return stringReplace.call(s, "*", replacement);
|
|
17673
17673
|
}
|
|
17674
|
+
function getNameFromImportAttribute(node) {
|
|
17675
|
+
return isIdentifier(node.name) ? node.name.escapedText : escapeLeadingUnderscores(node.name.text);
|
|
17676
|
+
}
|
|
17674
17677
|
|
|
17675
17678
|
// src/compiler/factory/baseNodeFactory.ts
|
|
17676
17679
|
function createBaseNodeFactory() {
|
|
@@ -44446,6 +44449,7 @@ function createTypeChecker(host) {
|
|
|
44446
44449
|
var deferredGlobalImportMetaType;
|
|
44447
44450
|
var deferredGlobalImportMetaExpressionType;
|
|
44448
44451
|
var deferredGlobalImportCallOptionsType;
|
|
44452
|
+
var deferredGlobalImportAttributesType;
|
|
44449
44453
|
var deferredGlobalDisposableType;
|
|
44450
44454
|
var deferredGlobalAsyncDisposableType;
|
|
44451
44455
|
var deferredGlobalExtractSymbol;
|
|
@@ -52683,7 +52687,7 @@ function createTypeChecker(host) {
|
|
|
52683
52687
|
/*reportErrors*/
|
|
52684
52688
|
false
|
|
52685
52689
|
) : unknownType;
|
|
52686
|
-
return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, 0 /* Normal */, contextualType)));
|
|
52690
|
+
return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, reportErrors2 ? 0 /* Normal */ : 1 /* Contextual */, contextualType)));
|
|
52687
52691
|
}
|
|
52688
52692
|
if (isBindingPattern(element.name)) {
|
|
52689
52693
|
return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors2);
|
|
@@ -52764,6 +52768,24 @@ function createTypeChecker(host) {
|
|
|
52764
52768
|
0 /* Normal */
|
|
52765
52769
|
), declaration, reportErrors2);
|
|
52766
52770
|
}
|
|
52771
|
+
function getTypeFromImportAttributes(node) {
|
|
52772
|
+
const links = getNodeLinks(node);
|
|
52773
|
+
if (!links.resolvedType) {
|
|
52774
|
+
const symbol = createSymbol(4096 /* ObjectLiteral */, "__importAttributes" /* ImportAttributes */);
|
|
52775
|
+
const members = createSymbolTable();
|
|
52776
|
+
forEach(node.elements, (attr) => {
|
|
52777
|
+
const member = createSymbol(4 /* Property */, getNameFromImportAttribute(attr));
|
|
52778
|
+
member.parent = symbol;
|
|
52779
|
+
member.links.type = checkImportAttribute(attr);
|
|
52780
|
+
member.links.target = member;
|
|
52781
|
+
members.set(member.escapedName, member);
|
|
52782
|
+
});
|
|
52783
|
+
const type = createAnonymousType(symbol, members, emptyArray, emptyArray, emptyArray);
|
|
52784
|
+
type.objectFlags |= 128 /* ObjectLiteral */ | 262144 /* NonInferrableType */;
|
|
52785
|
+
links.resolvedType = type;
|
|
52786
|
+
}
|
|
52787
|
+
return links.resolvedType;
|
|
52788
|
+
}
|
|
52767
52789
|
function isGlobalSymbolConstructor(node) {
|
|
52768
52790
|
const symbol = getSymbolOfNode(node);
|
|
52769
52791
|
const globalSymbol = getGlobalESSymbolConstructorTypeSymbol(
|
|
@@ -52817,18 +52839,18 @@ function createTypeChecker(host) {
|
|
|
52817
52839
|
}
|
|
52818
52840
|
return false;
|
|
52819
52841
|
}
|
|
52820
|
-
function getTypeOfVariableOrParameterOrProperty(symbol) {
|
|
52842
|
+
function getTypeOfVariableOrParameterOrProperty(symbol, checkMode) {
|
|
52821
52843
|
const links = getSymbolLinks(symbol);
|
|
52822
52844
|
if (!links.type) {
|
|
52823
|
-
const type = getTypeOfVariableOrParameterOrPropertyWorker(symbol);
|
|
52824
|
-
if (!links.type && !isParameterOfContextSensitiveSignature(symbol)) {
|
|
52845
|
+
const type = getTypeOfVariableOrParameterOrPropertyWorker(symbol, checkMode);
|
|
52846
|
+
if (!links.type && !isParameterOfContextSensitiveSignature(symbol) && !checkMode) {
|
|
52825
52847
|
links.type = type;
|
|
52826
52848
|
}
|
|
52827
52849
|
return type;
|
|
52828
52850
|
}
|
|
52829
52851
|
return links.type;
|
|
52830
52852
|
}
|
|
52831
|
-
function getTypeOfVariableOrParameterOrPropertyWorker(symbol) {
|
|
52853
|
+
function getTypeOfVariableOrParameterOrPropertyWorker(symbol, checkMode) {
|
|
52832
52854
|
if (symbol.flags & 4194304 /* Prototype */) {
|
|
52833
52855
|
return getTypeOfPrototypeProperty(symbol);
|
|
52834
52856
|
}
|
|
@@ -52866,6 +52888,9 @@ function createTypeChecker(host) {
|
|
|
52866
52888
|
if (symbol.flags & 512 /* ValueModule */ && !(symbol.flags & 67108864 /* Assignment */)) {
|
|
52867
52889
|
return getTypeOfFuncClassEnumModule(symbol);
|
|
52868
52890
|
}
|
|
52891
|
+
if (isBindingElement(declaration) && checkMode === 1 /* Contextual */) {
|
|
52892
|
+
return errorType;
|
|
52893
|
+
}
|
|
52869
52894
|
return reportCircularityError(symbol);
|
|
52870
52895
|
}
|
|
52871
52896
|
let type;
|
|
@@ -52903,6 +52928,9 @@ function createTypeChecker(host) {
|
|
|
52903
52928
|
if (symbol.flags & 512 /* ValueModule */ && !(symbol.flags & 67108864 /* Assignment */)) {
|
|
52904
52929
|
return getTypeOfFuncClassEnumModule(symbol);
|
|
52905
52930
|
}
|
|
52931
|
+
if (isBindingElement(declaration) && checkMode === 1 /* Contextual */) {
|
|
52932
|
+
return type;
|
|
52933
|
+
}
|
|
52906
52934
|
return reportCircularityError(symbol);
|
|
52907
52935
|
}
|
|
52908
52936
|
return type;
|
|
@@ -53131,7 +53159,7 @@ function createTypeChecker(host) {
|
|
|
53131
53159
|
}
|
|
53132
53160
|
return getTypeOfSymbol(symbol);
|
|
53133
53161
|
}
|
|
53134
|
-
function getTypeOfSymbol(symbol) {
|
|
53162
|
+
function getTypeOfSymbol(symbol, checkMode) {
|
|
53135
53163
|
const checkFlags = getCheckFlags(symbol);
|
|
53136
53164
|
if (checkFlags & 65536 /* DeferredType */) {
|
|
53137
53165
|
return getTypeOfSymbolWithDeferredType(symbol);
|
|
@@ -53146,7 +53174,7 @@ function createTypeChecker(host) {
|
|
|
53146
53174
|
return getTypeOfReverseMappedSymbol(symbol);
|
|
53147
53175
|
}
|
|
53148
53176
|
if (symbol.flags & (3 /* Variable */ | 4 /* Property */)) {
|
|
53149
|
-
return getTypeOfVariableOrParameterOrProperty(symbol);
|
|
53177
|
+
return getTypeOfVariableOrParameterOrProperty(symbol, checkMode);
|
|
53150
53178
|
}
|
|
53151
53179
|
if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 384 /* Enum */ | 512 /* ValueModule */)) {
|
|
53152
53180
|
return getTypeOfFuncClassEnumModule(symbol);
|
|
@@ -56762,6 +56790,14 @@ function createTypeChecker(host) {
|
|
|
56762
56790
|
reportErrors2
|
|
56763
56791
|
)) || emptyObjectType;
|
|
56764
56792
|
}
|
|
56793
|
+
function getGlobalImportAttributesType(reportErrors2) {
|
|
56794
|
+
return deferredGlobalImportAttributesType || (deferredGlobalImportAttributesType = getGlobalType(
|
|
56795
|
+
"ImportAttributes",
|
|
56796
|
+
/*arity*/
|
|
56797
|
+
0,
|
|
56798
|
+
reportErrors2
|
|
56799
|
+
)) || emptyObjectType;
|
|
56800
|
+
}
|
|
56765
56801
|
function getGlobalESSymbolConstructorSymbol(reportErrors2) {
|
|
56766
56802
|
return deferredGlobalESSymbolConstructorSymbol || (deferredGlobalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol", reportErrors2));
|
|
56767
56803
|
}
|
|
@@ -67509,9 +67545,9 @@ function createTypeChecker(host) {
|
|
|
67509
67545
|
}
|
|
67510
67546
|
}
|
|
67511
67547
|
}
|
|
67512
|
-
function getNarrowedTypeOfSymbol(symbol, location) {
|
|
67548
|
+
function getNarrowedTypeOfSymbol(symbol, location, checkMode) {
|
|
67513
67549
|
var _a;
|
|
67514
|
-
const type = getTypeOfSymbol(symbol);
|
|
67550
|
+
const type = getTypeOfSymbol(symbol, checkMode);
|
|
67515
67551
|
const declaration = symbol.valueDeclaration;
|
|
67516
67552
|
if (declaration) {
|
|
67517
67553
|
if (isBindingElement(declaration) && !declaration.initializer && !declaration.dotDotDotToken && declaration.parent.elements.length >= 2) {
|
|
@@ -67638,7 +67674,7 @@ function createTypeChecker(host) {
|
|
|
67638
67674
|
}
|
|
67639
67675
|
}
|
|
67640
67676
|
checkNestedBlockScopedBinding(node, symbol);
|
|
67641
|
-
let type = getNarrowedTypeOfSymbol(localOrExportSymbol, node);
|
|
67677
|
+
let type = getNarrowedTypeOfSymbol(localOrExportSymbol, node, checkMode);
|
|
67642
67678
|
const assignmentKind = getAssignmentTargetKind(node);
|
|
67643
67679
|
if (assignmentKind) {
|
|
67644
67680
|
if (!(localOrExportSymbol.flags & 3 /* Variable */) && !(isInJSFile(node) && localOrExportSymbol.flags & 512 /* ValueModule */)) {
|
|
@@ -68948,6 +68984,8 @@ function createTypeChecker(host) {
|
|
|
68948
68984
|
case 286 /* JsxOpeningElement */:
|
|
68949
68985
|
case 285 /* JsxSelfClosingElement */:
|
|
68950
68986
|
return getContextualJsxElementAttributesType(parent, contextFlags);
|
|
68987
|
+
case 301 /* ImportAttribute */:
|
|
68988
|
+
return getContextualImportAttributeType(parent);
|
|
68951
68989
|
}
|
|
68952
68990
|
return void 0;
|
|
68953
68991
|
}
|
|
@@ -68995,6 +69033,12 @@ function createTypeChecker(host) {
|
|
|
68995
69033
|
}
|
|
68996
69034
|
}
|
|
68997
69035
|
}
|
|
69036
|
+
function getContextualImportAttributeType(node) {
|
|
69037
|
+
return getTypeOfPropertyOfContextualType(getGlobalImportAttributesType(
|
|
69038
|
+
/*reportErrors*/
|
|
69039
|
+
false
|
|
69040
|
+
), getNameFromImportAttribute(node));
|
|
69041
|
+
}
|
|
68998
69042
|
function getContextualJsxElementAttributesType(node, contextFlags) {
|
|
68999
69043
|
if (isJsxOpeningElement(node) && contextFlags !== 4 /* Completions */) {
|
|
69000
69044
|
const index = findContextualNode(
|
|
@@ -81080,6 +81124,13 @@ function createTypeChecker(host) {
|
|
|
81080
81124
|
var _a;
|
|
81081
81125
|
const node = declaration.attributes;
|
|
81082
81126
|
if (node) {
|
|
81127
|
+
const importAttributesType = getGlobalImportAttributesType(
|
|
81128
|
+
/*reportErrors*/
|
|
81129
|
+
true
|
|
81130
|
+
);
|
|
81131
|
+
if (importAttributesType !== emptyObjectType) {
|
|
81132
|
+
checkTypeAssignableTo(getTypeFromImportAttributes(node), getNullableType(importAttributesType, 32768 /* Undefined */), node);
|
|
81133
|
+
}
|
|
81083
81134
|
const validForTypeAttributes = isExclusivelyTypeOnlyImportOrExport(declaration);
|
|
81084
81135
|
const override = getResolutionModeOverride(node, validForTypeAttributes ? grammarErrorOnNode : void 0);
|
|
81085
81136
|
const isImportAttributes2 = declaration.attributes.token === 118 /* WithKeyword */;
|
|
@@ -81099,6 +81150,9 @@ function createTypeChecker(host) {
|
|
|
81099
81150
|
}
|
|
81100
81151
|
}
|
|
81101
81152
|
}
|
|
81153
|
+
function checkImportAttribute(node) {
|
|
81154
|
+
return getRegularTypeOfLiteralType(checkExpressionCached(node.value));
|
|
81155
|
+
}
|
|
81102
81156
|
function checkImportDeclaration(node) {
|
|
81103
81157
|
if (checkGrammarModuleElementContext(node, isInJSFile(node) ? Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_module : Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_namespace_or_module)) {
|
|
81104
81158
|
return;
|
|
@@ -82514,6 +82568,12 @@ function createTypeChecker(host) {
|
|
|
82514
82568
|
if (isMetaProperty(node.parent) && node.parent.keywordToken === node.kind) {
|
|
82515
82569
|
return checkMetaPropertyKeyword(node.parent);
|
|
82516
82570
|
}
|
|
82571
|
+
if (isImportAttributes(node)) {
|
|
82572
|
+
return getGlobalImportAttributesType(
|
|
82573
|
+
/*reportErrors*/
|
|
82574
|
+
false
|
|
82575
|
+
);
|
|
82576
|
+
}
|
|
82517
82577
|
return errorType;
|
|
82518
82578
|
}
|
|
82519
82579
|
function getTypeOfAssignmentPattern(expr) {
|
|
@@ -119601,7 +119661,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
119601
119661
|
}
|
|
119602
119662
|
const isFromNodeModulesSearch = resolution.isExternalLibraryImport;
|
|
119603
119663
|
const isJsFile = !resolutionExtensionIsTSOrJson(resolution.extension);
|
|
119604
|
-
const isJsFileFromNodeModules = isFromNodeModulesSearch && isJsFile;
|
|
119664
|
+
const isJsFileFromNodeModules = isFromNodeModulesSearch && isJsFile && (!resolution.originalPath || pathContainsNodeModules(resolution.resolvedFileName));
|
|
119605
119665
|
const resolvedFileName = resolution.resolvedFileName;
|
|
119606
119666
|
if (isFromNodeModulesSearch) {
|
|
119607
119667
|
currentNodeModulesDepth++;
|
package/lib/tsserver.js
CHANGED
|
@@ -898,6 +898,7 @@ __export(server_exports, {
|
|
|
898
898
|
getModuleSpecifierEndingPreference: () => getModuleSpecifierEndingPreference,
|
|
899
899
|
getModuleSpecifierResolverHost: () => getModuleSpecifierResolverHost,
|
|
900
900
|
getNameForExportedSymbol: () => getNameForExportedSymbol,
|
|
901
|
+
getNameFromImportAttribute: () => getNameFromImportAttribute,
|
|
901
902
|
getNameFromIndexInfo: () => getNameFromIndexInfo,
|
|
902
903
|
getNameFromPropertyName: () => getNameFromPropertyName,
|
|
903
904
|
getNameOfAccessExpression: () => getNameOfAccessExpression,
|
|
@@ -2340,7 +2341,7 @@ module.exports = __toCommonJS(server_exports);
|
|
|
2340
2341
|
|
|
2341
2342
|
// src/compiler/corePublic.ts
|
|
2342
2343
|
var versionMajorMinor = "5.4";
|
|
2343
|
-
var version = `${versionMajorMinor}.0-dev.
|
|
2344
|
+
var version = `${versionMajorMinor}.0-dev.20240111`;
|
|
2344
2345
|
var Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
2345
2346
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
2346
2347
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -6599,6 +6600,7 @@ var InternalSymbolName = /* @__PURE__ */ ((InternalSymbolName2) => {
|
|
|
6599
6600
|
InternalSymbolName2["Default"] = "default";
|
|
6600
6601
|
InternalSymbolName2["This"] = "this";
|
|
6601
6602
|
InternalSymbolName2["InstantiationExpression"] = "__instantiationExpression";
|
|
6603
|
+
InternalSymbolName2["ImportAttributes"] = "__importAttributes";
|
|
6602
6604
|
return InternalSymbolName2;
|
|
6603
6605
|
})(InternalSymbolName || {});
|
|
6604
6606
|
var NodeCheckFlags = /* @__PURE__ */ ((NodeCheckFlags2) => {
|
|
@@ -21902,6 +21904,9 @@ var stringReplace = String.prototype.replace;
|
|
|
21902
21904
|
function replaceFirstStar(s, replacement) {
|
|
21903
21905
|
return stringReplace.call(s, "*", replacement);
|
|
21904
21906
|
}
|
|
21907
|
+
function getNameFromImportAttribute(node) {
|
|
21908
|
+
return isIdentifier(node.name) ? node.name.escapedText : escapeLeadingUnderscores(node.name.text);
|
|
21909
|
+
}
|
|
21905
21910
|
|
|
21906
21911
|
// src/compiler/factory/baseNodeFactory.ts
|
|
21907
21912
|
function createBaseNodeFactory() {
|
|
@@ -49184,6 +49189,7 @@ function createTypeChecker(host) {
|
|
|
49184
49189
|
var deferredGlobalImportMetaType;
|
|
49185
49190
|
var deferredGlobalImportMetaExpressionType;
|
|
49186
49191
|
var deferredGlobalImportCallOptionsType;
|
|
49192
|
+
var deferredGlobalImportAttributesType;
|
|
49187
49193
|
var deferredGlobalDisposableType;
|
|
49188
49194
|
var deferredGlobalAsyncDisposableType;
|
|
49189
49195
|
var deferredGlobalExtractSymbol;
|
|
@@ -57421,7 +57427,7 @@ function createTypeChecker(host) {
|
|
|
57421
57427
|
/*reportErrors*/
|
|
57422
57428
|
false
|
|
57423
57429
|
) : unknownType;
|
|
57424
|
-
return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, 0 /* Normal */, contextualType)));
|
|
57430
|
+
return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, reportErrors2 ? 0 /* Normal */ : 1 /* Contextual */, contextualType)));
|
|
57425
57431
|
}
|
|
57426
57432
|
if (isBindingPattern(element.name)) {
|
|
57427
57433
|
return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors2);
|
|
@@ -57502,6 +57508,24 @@ function createTypeChecker(host) {
|
|
|
57502
57508
|
0 /* Normal */
|
|
57503
57509
|
), declaration, reportErrors2);
|
|
57504
57510
|
}
|
|
57511
|
+
function getTypeFromImportAttributes(node) {
|
|
57512
|
+
const links = getNodeLinks(node);
|
|
57513
|
+
if (!links.resolvedType) {
|
|
57514
|
+
const symbol = createSymbol(4096 /* ObjectLiteral */, "__importAttributes" /* ImportAttributes */);
|
|
57515
|
+
const members = createSymbolTable();
|
|
57516
|
+
forEach(node.elements, (attr) => {
|
|
57517
|
+
const member = createSymbol(4 /* Property */, getNameFromImportAttribute(attr));
|
|
57518
|
+
member.parent = symbol;
|
|
57519
|
+
member.links.type = checkImportAttribute(attr);
|
|
57520
|
+
member.links.target = member;
|
|
57521
|
+
members.set(member.escapedName, member);
|
|
57522
|
+
});
|
|
57523
|
+
const type = createAnonymousType(symbol, members, emptyArray, emptyArray, emptyArray);
|
|
57524
|
+
type.objectFlags |= 128 /* ObjectLiteral */ | 262144 /* NonInferrableType */;
|
|
57525
|
+
links.resolvedType = type;
|
|
57526
|
+
}
|
|
57527
|
+
return links.resolvedType;
|
|
57528
|
+
}
|
|
57505
57529
|
function isGlobalSymbolConstructor(node) {
|
|
57506
57530
|
const symbol = getSymbolOfNode(node);
|
|
57507
57531
|
const globalSymbol = getGlobalESSymbolConstructorTypeSymbol(
|
|
@@ -57555,18 +57579,18 @@ function createTypeChecker(host) {
|
|
|
57555
57579
|
}
|
|
57556
57580
|
return false;
|
|
57557
57581
|
}
|
|
57558
|
-
function getTypeOfVariableOrParameterOrProperty(symbol) {
|
|
57582
|
+
function getTypeOfVariableOrParameterOrProperty(symbol, checkMode) {
|
|
57559
57583
|
const links = getSymbolLinks(symbol);
|
|
57560
57584
|
if (!links.type) {
|
|
57561
|
-
const type = getTypeOfVariableOrParameterOrPropertyWorker(symbol);
|
|
57562
|
-
if (!links.type && !isParameterOfContextSensitiveSignature(symbol)) {
|
|
57585
|
+
const type = getTypeOfVariableOrParameterOrPropertyWorker(symbol, checkMode);
|
|
57586
|
+
if (!links.type && !isParameterOfContextSensitiveSignature(symbol) && !checkMode) {
|
|
57563
57587
|
links.type = type;
|
|
57564
57588
|
}
|
|
57565
57589
|
return type;
|
|
57566
57590
|
}
|
|
57567
57591
|
return links.type;
|
|
57568
57592
|
}
|
|
57569
|
-
function getTypeOfVariableOrParameterOrPropertyWorker(symbol) {
|
|
57593
|
+
function getTypeOfVariableOrParameterOrPropertyWorker(symbol, checkMode) {
|
|
57570
57594
|
if (symbol.flags & 4194304 /* Prototype */) {
|
|
57571
57595
|
return getTypeOfPrototypeProperty(symbol);
|
|
57572
57596
|
}
|
|
@@ -57604,6 +57628,9 @@ function createTypeChecker(host) {
|
|
|
57604
57628
|
if (symbol.flags & 512 /* ValueModule */ && !(symbol.flags & 67108864 /* Assignment */)) {
|
|
57605
57629
|
return getTypeOfFuncClassEnumModule(symbol);
|
|
57606
57630
|
}
|
|
57631
|
+
if (isBindingElement(declaration) && checkMode === 1 /* Contextual */) {
|
|
57632
|
+
return errorType;
|
|
57633
|
+
}
|
|
57607
57634
|
return reportCircularityError(symbol);
|
|
57608
57635
|
}
|
|
57609
57636
|
let type;
|
|
@@ -57641,6 +57668,9 @@ function createTypeChecker(host) {
|
|
|
57641
57668
|
if (symbol.flags & 512 /* ValueModule */ && !(symbol.flags & 67108864 /* Assignment */)) {
|
|
57642
57669
|
return getTypeOfFuncClassEnumModule(symbol);
|
|
57643
57670
|
}
|
|
57671
|
+
if (isBindingElement(declaration) && checkMode === 1 /* Contextual */) {
|
|
57672
|
+
return type;
|
|
57673
|
+
}
|
|
57644
57674
|
return reportCircularityError(symbol);
|
|
57645
57675
|
}
|
|
57646
57676
|
return type;
|
|
@@ -57869,7 +57899,7 @@ function createTypeChecker(host) {
|
|
|
57869
57899
|
}
|
|
57870
57900
|
return getTypeOfSymbol(symbol);
|
|
57871
57901
|
}
|
|
57872
|
-
function getTypeOfSymbol(symbol) {
|
|
57902
|
+
function getTypeOfSymbol(symbol, checkMode) {
|
|
57873
57903
|
const checkFlags = getCheckFlags(symbol);
|
|
57874
57904
|
if (checkFlags & 65536 /* DeferredType */) {
|
|
57875
57905
|
return getTypeOfSymbolWithDeferredType(symbol);
|
|
@@ -57884,7 +57914,7 @@ function createTypeChecker(host) {
|
|
|
57884
57914
|
return getTypeOfReverseMappedSymbol(symbol);
|
|
57885
57915
|
}
|
|
57886
57916
|
if (symbol.flags & (3 /* Variable */ | 4 /* Property */)) {
|
|
57887
|
-
return getTypeOfVariableOrParameterOrProperty(symbol);
|
|
57917
|
+
return getTypeOfVariableOrParameterOrProperty(symbol, checkMode);
|
|
57888
57918
|
}
|
|
57889
57919
|
if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 384 /* Enum */ | 512 /* ValueModule */)) {
|
|
57890
57920
|
return getTypeOfFuncClassEnumModule(symbol);
|
|
@@ -61500,6 +61530,14 @@ function createTypeChecker(host) {
|
|
|
61500
61530
|
reportErrors2
|
|
61501
61531
|
)) || emptyObjectType;
|
|
61502
61532
|
}
|
|
61533
|
+
function getGlobalImportAttributesType(reportErrors2) {
|
|
61534
|
+
return deferredGlobalImportAttributesType || (deferredGlobalImportAttributesType = getGlobalType(
|
|
61535
|
+
"ImportAttributes",
|
|
61536
|
+
/*arity*/
|
|
61537
|
+
0,
|
|
61538
|
+
reportErrors2
|
|
61539
|
+
)) || emptyObjectType;
|
|
61540
|
+
}
|
|
61503
61541
|
function getGlobalESSymbolConstructorSymbol(reportErrors2) {
|
|
61504
61542
|
return deferredGlobalESSymbolConstructorSymbol || (deferredGlobalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol", reportErrors2));
|
|
61505
61543
|
}
|
|
@@ -72247,9 +72285,9 @@ function createTypeChecker(host) {
|
|
|
72247
72285
|
}
|
|
72248
72286
|
}
|
|
72249
72287
|
}
|
|
72250
|
-
function getNarrowedTypeOfSymbol(symbol, location) {
|
|
72288
|
+
function getNarrowedTypeOfSymbol(symbol, location, checkMode) {
|
|
72251
72289
|
var _a;
|
|
72252
|
-
const type = getTypeOfSymbol(symbol);
|
|
72290
|
+
const type = getTypeOfSymbol(symbol, checkMode);
|
|
72253
72291
|
const declaration = symbol.valueDeclaration;
|
|
72254
72292
|
if (declaration) {
|
|
72255
72293
|
if (isBindingElement(declaration) && !declaration.initializer && !declaration.dotDotDotToken && declaration.parent.elements.length >= 2) {
|
|
@@ -72376,7 +72414,7 @@ function createTypeChecker(host) {
|
|
|
72376
72414
|
}
|
|
72377
72415
|
}
|
|
72378
72416
|
checkNestedBlockScopedBinding(node, symbol);
|
|
72379
|
-
let type = getNarrowedTypeOfSymbol(localOrExportSymbol, node);
|
|
72417
|
+
let type = getNarrowedTypeOfSymbol(localOrExportSymbol, node, checkMode);
|
|
72380
72418
|
const assignmentKind = getAssignmentTargetKind(node);
|
|
72381
72419
|
if (assignmentKind) {
|
|
72382
72420
|
if (!(localOrExportSymbol.flags & 3 /* Variable */) && !(isInJSFile(node) && localOrExportSymbol.flags & 512 /* ValueModule */)) {
|
|
@@ -73686,6 +73724,8 @@ function createTypeChecker(host) {
|
|
|
73686
73724
|
case 286 /* JsxOpeningElement */:
|
|
73687
73725
|
case 285 /* JsxSelfClosingElement */:
|
|
73688
73726
|
return getContextualJsxElementAttributesType(parent2, contextFlags);
|
|
73727
|
+
case 301 /* ImportAttribute */:
|
|
73728
|
+
return getContextualImportAttributeType(parent2);
|
|
73689
73729
|
}
|
|
73690
73730
|
return void 0;
|
|
73691
73731
|
}
|
|
@@ -73733,6 +73773,12 @@ function createTypeChecker(host) {
|
|
|
73733
73773
|
}
|
|
73734
73774
|
}
|
|
73735
73775
|
}
|
|
73776
|
+
function getContextualImportAttributeType(node) {
|
|
73777
|
+
return getTypeOfPropertyOfContextualType(getGlobalImportAttributesType(
|
|
73778
|
+
/*reportErrors*/
|
|
73779
|
+
false
|
|
73780
|
+
), getNameFromImportAttribute(node));
|
|
73781
|
+
}
|
|
73736
73782
|
function getContextualJsxElementAttributesType(node, contextFlags) {
|
|
73737
73783
|
if (isJsxOpeningElement(node) && contextFlags !== 4 /* Completions */) {
|
|
73738
73784
|
const index = findContextualNode(
|
|
@@ -85818,6 +85864,13 @@ function createTypeChecker(host) {
|
|
|
85818
85864
|
var _a;
|
|
85819
85865
|
const node = declaration.attributes;
|
|
85820
85866
|
if (node) {
|
|
85867
|
+
const importAttributesType = getGlobalImportAttributesType(
|
|
85868
|
+
/*reportErrors*/
|
|
85869
|
+
true
|
|
85870
|
+
);
|
|
85871
|
+
if (importAttributesType !== emptyObjectType) {
|
|
85872
|
+
checkTypeAssignableTo(getTypeFromImportAttributes(node), getNullableType(importAttributesType, 32768 /* Undefined */), node);
|
|
85873
|
+
}
|
|
85821
85874
|
const validForTypeAttributes = isExclusivelyTypeOnlyImportOrExport(declaration);
|
|
85822
85875
|
const override = getResolutionModeOverride(node, validForTypeAttributes ? grammarErrorOnNode : void 0);
|
|
85823
85876
|
const isImportAttributes2 = declaration.attributes.token === 118 /* WithKeyword */;
|
|
@@ -85837,6 +85890,9 @@ function createTypeChecker(host) {
|
|
|
85837
85890
|
}
|
|
85838
85891
|
}
|
|
85839
85892
|
}
|
|
85893
|
+
function checkImportAttribute(node) {
|
|
85894
|
+
return getRegularTypeOfLiteralType(checkExpressionCached(node.value));
|
|
85895
|
+
}
|
|
85840
85896
|
function checkImportDeclaration(node) {
|
|
85841
85897
|
if (checkGrammarModuleElementContext(node, isInJSFile(node) ? Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_module : Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_namespace_or_module)) {
|
|
85842
85898
|
return;
|
|
@@ -87252,6 +87308,12 @@ function createTypeChecker(host) {
|
|
|
87252
87308
|
if (isMetaProperty(node.parent) && node.parent.keywordToken === node.kind) {
|
|
87253
87309
|
return checkMetaPropertyKeyword(node.parent);
|
|
87254
87310
|
}
|
|
87311
|
+
if (isImportAttributes(node)) {
|
|
87312
|
+
return getGlobalImportAttributesType(
|
|
87313
|
+
/*reportErrors*/
|
|
87314
|
+
false
|
|
87315
|
+
);
|
|
87316
|
+
}
|
|
87255
87317
|
return errorType;
|
|
87256
87318
|
}
|
|
87257
87319
|
function getTypeOfAssignmentPattern(expr) {
|
|
@@ -124564,7 +124626,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
124564
124626
|
}
|
|
124565
124627
|
const isFromNodeModulesSearch = resolution.isExternalLibraryImport;
|
|
124566
124628
|
const isJsFile = !resolutionExtensionIsTSOrJson(resolution.extension);
|
|
124567
|
-
const isJsFileFromNodeModules = isFromNodeModulesSearch && isJsFile;
|
|
124629
|
+
const isJsFileFromNodeModules = isFromNodeModulesSearch && isJsFile && (!resolution.originalPath || pathContainsNodeModules(resolution.resolvedFileName));
|
|
124568
124630
|
const resolvedFileName = resolution.resolvedFileName;
|
|
124569
124631
|
if (isFromNodeModulesSearch) {
|
|
124570
124632
|
currentNodeModulesDepth++;
|
|
@@ -160879,7 +160941,7 @@ function getCompletionData(program, log, sourceFile, compilerOptions, position,
|
|
|
160879
160941
|
return isIdentifier(e) ? e : isPropertyAccessExpression(e) ? getLeftMostName(e.expression) : void 0;
|
|
160880
160942
|
}
|
|
160881
160943
|
function tryGetGlobalSymbols() {
|
|
160882
|
-
const result = tryGetObjectTypeLiteralInTypeArgumentCompletionSymbols() || tryGetObjectLikeCompletionSymbols() || tryGetImportCompletionSymbols() || tryGetImportOrExportClauseCompletionSymbols() || tryGetLocalNamedExportCompletionSymbols() || tryGetConstructorCompletion() || tryGetClassLikeCompletionSymbols() || tryGetJsxCompletionSymbols() || (getGlobalCompletions(), 1 /* Success */);
|
|
160944
|
+
const result = tryGetObjectTypeLiteralInTypeArgumentCompletionSymbols() || tryGetObjectLikeCompletionSymbols() || tryGetImportCompletionSymbols() || tryGetImportOrExportClauseCompletionSymbols() || tryGetImportAttributesCompletionSymbols() || tryGetLocalNamedExportCompletionSymbols() || tryGetConstructorCompletion() || tryGetClassLikeCompletionSymbols() || tryGetJsxCompletionSymbols() || (getGlobalCompletions(), 1 /* Success */);
|
|
160883
160945
|
return result === 1 /* Success */;
|
|
160884
160946
|
}
|
|
160885
160947
|
function tryGetConstructorCompletion() {
|
|
@@ -161347,6 +161409,16 @@ function getCompletionData(program, log, sourceFile, compilerOptions, position,
|
|
|
161347
161409
|
}
|
|
161348
161410
|
return 1 /* Success */;
|
|
161349
161411
|
}
|
|
161412
|
+
function tryGetImportAttributesCompletionSymbols() {
|
|
161413
|
+
if (contextToken === void 0)
|
|
161414
|
+
return 0 /* Continue */;
|
|
161415
|
+
const importAttributes = contextToken.kind === 19 /* OpenBraceToken */ || contextToken.kind === 28 /* CommaToken */ ? tryCast(contextToken.parent, isImportAttributes) : contextToken.kind === 59 /* ColonToken */ ? tryCast(contextToken.parent.parent, isImportAttributes) : void 0;
|
|
161416
|
+
if (importAttributes === void 0)
|
|
161417
|
+
return 0 /* Continue */;
|
|
161418
|
+
const existing = new Set(importAttributes.elements.map(getNameFromImportAttribute));
|
|
161419
|
+
symbols = filter(typeChecker.getTypeAtLocation(importAttributes).getApparentProperties(), (attr) => !existing.has(attr.escapedName));
|
|
161420
|
+
return 1 /* Success */;
|
|
161421
|
+
}
|
|
161350
161422
|
function tryGetLocalNamedExportCompletionSymbols() {
|
|
161351
161423
|
var _a;
|
|
161352
161424
|
const namedExports = contextToken && (contextToken.kind === 19 /* OpenBraceToken */ || contextToken.kind === 28 /* CommaToken */) ? tryCast(contextToken.parent, isNamedExports) : void 0;
|
|
@@ -174893,6 +174965,7 @@ __export(ts_exports2, {
|
|
|
174893
174965
|
getModuleSpecifierEndingPreference: () => getModuleSpecifierEndingPreference,
|
|
174894
174966
|
getModuleSpecifierResolverHost: () => getModuleSpecifierResolverHost,
|
|
174895
174967
|
getNameForExportedSymbol: () => getNameForExportedSymbol,
|
|
174968
|
+
getNameFromImportAttribute: () => getNameFromImportAttribute,
|
|
174896
174969
|
getNameFromIndexInfo: () => getNameFromIndexInfo,
|
|
174897
174970
|
getNameFromPropertyName: () => getNameFromPropertyName,
|
|
174898
174971
|
getNameOfAccessExpression: () => getNameOfAccessExpression,
|
|
@@ -189693,6 +189766,7 @@ start(initializeNodeSystem(), require("os").platform());
|
|
|
189693
189766
|
getModuleSpecifierEndingPreference,
|
|
189694
189767
|
getModuleSpecifierResolverHost,
|
|
189695
189768
|
getNameForExportedSymbol,
|
|
189769
|
+
getNameFromImportAttribute,
|
|
189696
189770
|
getNameFromIndexInfo,
|
|
189697
189771
|
getNameFromPropertyName,
|
|
189698
189772
|
getNameOfAccessExpression,
|
package/lib/typescript.d.ts
CHANGED
|
@@ -7076,6 +7076,7 @@ declare namespace ts {
|
|
|
7076
7076
|
Default = "default",
|
|
7077
7077
|
This = "this",
|
|
7078
7078
|
InstantiationExpression = "__instantiationExpression",
|
|
7079
|
+
ImportAttributes = "__importAttributes",
|
|
7079
7080
|
}
|
|
7080
7081
|
/**
|
|
7081
7082
|
* This represents a string whose leading underscore have been escaped by adding extra leading underscores.
|
package/lib/typescript.js
CHANGED
|
@@ -35,7 +35,7 @@ var ts = (() => {
|
|
|
35
35
|
"src/compiler/corePublic.ts"() {
|
|
36
36
|
"use strict";
|
|
37
37
|
versionMajorMinor = "5.4";
|
|
38
|
-
version = `${versionMajorMinor}.0-dev.
|
|
38
|
+
version = `${versionMajorMinor}.0-dev.20240111`;
|
|
39
39
|
Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
40
40
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
41
41
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -4352,6 +4352,7 @@ ${lanes.join("\n")}
|
|
|
4352
4352
|
InternalSymbolName2["Default"] = "default";
|
|
4353
4353
|
InternalSymbolName2["This"] = "this";
|
|
4354
4354
|
InternalSymbolName2["InstantiationExpression"] = "__instantiationExpression";
|
|
4355
|
+
InternalSymbolName2["ImportAttributes"] = "__importAttributes";
|
|
4355
4356
|
return InternalSymbolName2;
|
|
4356
4357
|
})(InternalSymbolName || {});
|
|
4357
4358
|
NodeCheckFlags = /* @__PURE__ */ ((NodeCheckFlags2) => {
|
|
@@ -18897,6 +18898,9 @@ ${lanes.join("\n")}
|
|
|
18897
18898
|
function replaceFirstStar(s, replacement) {
|
|
18898
18899
|
return stringReplace.call(s, "*", replacement);
|
|
18899
18900
|
}
|
|
18901
|
+
function getNameFromImportAttribute(node) {
|
|
18902
|
+
return isIdentifier(node.name) ? node.name.escapedText : escapeLeadingUnderscores(node.name.text);
|
|
18903
|
+
}
|
|
18900
18904
|
var resolvingEmptyArray, externalHelpersModuleNameText, defaultMaximumTruncationLength, noTruncationMaximumTruncationLength, stringWriter, getScriptTargetFeatures, GetLiteralTextFlags, fullTripleSlashReferencePathRegEx, fullTripleSlashReferenceTypeReferenceDirectiveRegEx, fullTripleSlashLibReferenceRegEx, fullTripleSlashAMDReferencePathRegEx, fullTripleSlashAMDModuleRegEx, defaultLibReferenceRegEx, AssignmentKind, FunctionFlags, Associativity, OperatorPrecedence, templateSubstitutionRegExp, doubleQuoteEscapedCharsRegExp, singleQuoteEscapedCharsRegExp, backtickQuoteEscapedCharsRegExp, escapedCharsMap, nonAsciiCharacters, jsxDoubleQuoteEscapedCharsRegExp, jsxSingleQuoteEscapedCharsRegExp, jsxEscapedCharsMap, indentStrings, base64Digits, carriageReturnLineFeed, lineFeed, objectAllocator, objectAllocatorPatchers, localizedDiagnosticMessages, computedOptions, getEmitScriptTarget, getEmitModuleKind, getEmitModuleResolutionKind, getEmitModuleDetectionKind, getIsolatedModules, getESModuleInterop, getAllowSyntheticDefaultImports, getResolvePackageJsonExports, getResolvePackageJsonImports, getResolveJsonModule, getEmitDeclarations, shouldPreserveConstEnums, isIncrementalCompilation, getAreDeclarationMapsEnabled, getAllowJSCompilerOption, getUseDefineForClassFields, reservedCharacterPattern, wildcardCharCodes, commonPackageFolders, implicitExcludePathRegexPattern, filesMatcher, directoriesMatcher, excludeMatcher, wildcardMatchers, supportedTSExtensions, supportedTSExtensionsFlat, supportedTSExtensionsWithJson, supportedTSExtensionsForExtractExtension, supportedJSExtensions, supportedJSExtensionsFlat, allSupportedExtensions, allSupportedExtensionsWithJson, supportedDeclarationExtensions, supportedTSImplementationExtensions, extensionsNotSupportingExtensionlessResolution, ModuleSpecifierEnding, extensionsToRemove, emptyFileSystemEntries, stringReplace;
|
|
18901
18905
|
var init_utilities = __esm({
|
|
18902
18906
|
"src/compiler/utilities.ts"() {
|
|
@@ -46939,6 +46943,7 @@ ${lanes.join("\n")}
|
|
|
46939
46943
|
var deferredGlobalImportMetaType;
|
|
46940
46944
|
var deferredGlobalImportMetaExpressionType;
|
|
46941
46945
|
var deferredGlobalImportCallOptionsType;
|
|
46946
|
+
var deferredGlobalImportAttributesType;
|
|
46942
46947
|
var deferredGlobalDisposableType;
|
|
46943
46948
|
var deferredGlobalAsyncDisposableType;
|
|
46944
46949
|
var deferredGlobalExtractSymbol;
|
|
@@ -55176,7 +55181,7 @@ ${lanes.join("\n")}
|
|
|
55176
55181
|
/*reportErrors*/
|
|
55177
55182
|
false
|
|
55178
55183
|
) : unknownType;
|
|
55179
|
-
return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, 0 /* Normal */, contextualType)));
|
|
55184
|
+
return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, reportErrors2 ? 0 /* Normal */ : 1 /* Contextual */, contextualType)));
|
|
55180
55185
|
}
|
|
55181
55186
|
if (isBindingPattern(element.name)) {
|
|
55182
55187
|
return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors2);
|
|
@@ -55257,6 +55262,24 @@ ${lanes.join("\n")}
|
|
|
55257
55262
|
0 /* Normal */
|
|
55258
55263
|
), declaration, reportErrors2);
|
|
55259
55264
|
}
|
|
55265
|
+
function getTypeFromImportAttributes(node) {
|
|
55266
|
+
const links = getNodeLinks(node);
|
|
55267
|
+
if (!links.resolvedType) {
|
|
55268
|
+
const symbol = createSymbol(4096 /* ObjectLiteral */, "__importAttributes" /* ImportAttributes */);
|
|
55269
|
+
const members = createSymbolTable();
|
|
55270
|
+
forEach(node.elements, (attr) => {
|
|
55271
|
+
const member = createSymbol(4 /* Property */, getNameFromImportAttribute(attr));
|
|
55272
|
+
member.parent = symbol;
|
|
55273
|
+
member.links.type = checkImportAttribute(attr);
|
|
55274
|
+
member.links.target = member;
|
|
55275
|
+
members.set(member.escapedName, member);
|
|
55276
|
+
});
|
|
55277
|
+
const type = createAnonymousType(symbol, members, emptyArray, emptyArray, emptyArray);
|
|
55278
|
+
type.objectFlags |= 128 /* ObjectLiteral */ | 262144 /* NonInferrableType */;
|
|
55279
|
+
links.resolvedType = type;
|
|
55280
|
+
}
|
|
55281
|
+
return links.resolvedType;
|
|
55282
|
+
}
|
|
55260
55283
|
function isGlobalSymbolConstructor(node) {
|
|
55261
55284
|
const symbol = getSymbolOfNode(node);
|
|
55262
55285
|
const globalSymbol = getGlobalESSymbolConstructorTypeSymbol(
|
|
@@ -55310,18 +55333,18 @@ ${lanes.join("\n")}
|
|
|
55310
55333
|
}
|
|
55311
55334
|
return false;
|
|
55312
55335
|
}
|
|
55313
|
-
function getTypeOfVariableOrParameterOrProperty(symbol) {
|
|
55336
|
+
function getTypeOfVariableOrParameterOrProperty(symbol, checkMode) {
|
|
55314
55337
|
const links = getSymbolLinks(symbol);
|
|
55315
55338
|
if (!links.type) {
|
|
55316
|
-
const type = getTypeOfVariableOrParameterOrPropertyWorker(symbol);
|
|
55317
|
-
if (!links.type && !isParameterOfContextSensitiveSignature(symbol)) {
|
|
55339
|
+
const type = getTypeOfVariableOrParameterOrPropertyWorker(symbol, checkMode);
|
|
55340
|
+
if (!links.type && !isParameterOfContextSensitiveSignature(symbol) && !checkMode) {
|
|
55318
55341
|
links.type = type;
|
|
55319
55342
|
}
|
|
55320
55343
|
return type;
|
|
55321
55344
|
}
|
|
55322
55345
|
return links.type;
|
|
55323
55346
|
}
|
|
55324
|
-
function getTypeOfVariableOrParameterOrPropertyWorker(symbol) {
|
|
55347
|
+
function getTypeOfVariableOrParameterOrPropertyWorker(symbol, checkMode) {
|
|
55325
55348
|
if (symbol.flags & 4194304 /* Prototype */) {
|
|
55326
55349
|
return getTypeOfPrototypeProperty(symbol);
|
|
55327
55350
|
}
|
|
@@ -55359,6 +55382,9 @@ ${lanes.join("\n")}
|
|
|
55359
55382
|
if (symbol.flags & 512 /* ValueModule */ && !(symbol.flags & 67108864 /* Assignment */)) {
|
|
55360
55383
|
return getTypeOfFuncClassEnumModule(symbol);
|
|
55361
55384
|
}
|
|
55385
|
+
if (isBindingElement(declaration) && checkMode === 1 /* Contextual */) {
|
|
55386
|
+
return errorType;
|
|
55387
|
+
}
|
|
55362
55388
|
return reportCircularityError(symbol);
|
|
55363
55389
|
}
|
|
55364
55390
|
let type;
|
|
@@ -55396,6 +55422,9 @@ ${lanes.join("\n")}
|
|
|
55396
55422
|
if (symbol.flags & 512 /* ValueModule */ && !(symbol.flags & 67108864 /* Assignment */)) {
|
|
55397
55423
|
return getTypeOfFuncClassEnumModule(symbol);
|
|
55398
55424
|
}
|
|
55425
|
+
if (isBindingElement(declaration) && checkMode === 1 /* Contextual */) {
|
|
55426
|
+
return type;
|
|
55427
|
+
}
|
|
55399
55428
|
return reportCircularityError(symbol);
|
|
55400
55429
|
}
|
|
55401
55430
|
return type;
|
|
@@ -55624,7 +55653,7 @@ ${lanes.join("\n")}
|
|
|
55624
55653
|
}
|
|
55625
55654
|
return getTypeOfSymbol(symbol);
|
|
55626
55655
|
}
|
|
55627
|
-
function getTypeOfSymbol(symbol) {
|
|
55656
|
+
function getTypeOfSymbol(symbol, checkMode) {
|
|
55628
55657
|
const checkFlags = getCheckFlags(symbol);
|
|
55629
55658
|
if (checkFlags & 65536 /* DeferredType */) {
|
|
55630
55659
|
return getTypeOfSymbolWithDeferredType(symbol);
|
|
@@ -55639,7 +55668,7 @@ ${lanes.join("\n")}
|
|
|
55639
55668
|
return getTypeOfReverseMappedSymbol(symbol);
|
|
55640
55669
|
}
|
|
55641
55670
|
if (symbol.flags & (3 /* Variable */ | 4 /* Property */)) {
|
|
55642
|
-
return getTypeOfVariableOrParameterOrProperty(symbol);
|
|
55671
|
+
return getTypeOfVariableOrParameterOrProperty(symbol, checkMode);
|
|
55643
55672
|
}
|
|
55644
55673
|
if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 384 /* Enum */ | 512 /* ValueModule */)) {
|
|
55645
55674
|
return getTypeOfFuncClassEnumModule(symbol);
|
|
@@ -59255,6 +59284,14 @@ ${lanes.join("\n")}
|
|
|
59255
59284
|
reportErrors2
|
|
59256
59285
|
)) || emptyObjectType;
|
|
59257
59286
|
}
|
|
59287
|
+
function getGlobalImportAttributesType(reportErrors2) {
|
|
59288
|
+
return deferredGlobalImportAttributesType || (deferredGlobalImportAttributesType = getGlobalType(
|
|
59289
|
+
"ImportAttributes",
|
|
59290
|
+
/*arity*/
|
|
59291
|
+
0,
|
|
59292
|
+
reportErrors2
|
|
59293
|
+
)) || emptyObjectType;
|
|
59294
|
+
}
|
|
59258
59295
|
function getGlobalESSymbolConstructorSymbol(reportErrors2) {
|
|
59259
59296
|
return deferredGlobalESSymbolConstructorSymbol || (deferredGlobalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol", reportErrors2));
|
|
59260
59297
|
}
|
|
@@ -70002,9 +70039,9 @@ ${lanes.join("\n")}
|
|
|
70002
70039
|
}
|
|
70003
70040
|
}
|
|
70004
70041
|
}
|
|
70005
|
-
function getNarrowedTypeOfSymbol(symbol, location) {
|
|
70042
|
+
function getNarrowedTypeOfSymbol(symbol, location, checkMode) {
|
|
70006
70043
|
var _a;
|
|
70007
|
-
const type = getTypeOfSymbol(symbol);
|
|
70044
|
+
const type = getTypeOfSymbol(symbol, checkMode);
|
|
70008
70045
|
const declaration = symbol.valueDeclaration;
|
|
70009
70046
|
if (declaration) {
|
|
70010
70047
|
if (isBindingElement(declaration) && !declaration.initializer && !declaration.dotDotDotToken && declaration.parent.elements.length >= 2) {
|
|
@@ -70131,7 +70168,7 @@ ${lanes.join("\n")}
|
|
|
70131
70168
|
}
|
|
70132
70169
|
}
|
|
70133
70170
|
checkNestedBlockScopedBinding(node, symbol);
|
|
70134
|
-
let type = getNarrowedTypeOfSymbol(localOrExportSymbol, node);
|
|
70171
|
+
let type = getNarrowedTypeOfSymbol(localOrExportSymbol, node, checkMode);
|
|
70135
70172
|
const assignmentKind = getAssignmentTargetKind(node);
|
|
70136
70173
|
if (assignmentKind) {
|
|
70137
70174
|
if (!(localOrExportSymbol.flags & 3 /* Variable */) && !(isInJSFile(node) && localOrExportSymbol.flags & 512 /* ValueModule */)) {
|
|
@@ -71441,6 +71478,8 @@ ${lanes.join("\n")}
|
|
|
71441
71478
|
case 286 /* JsxOpeningElement */:
|
|
71442
71479
|
case 285 /* JsxSelfClosingElement */:
|
|
71443
71480
|
return getContextualJsxElementAttributesType(parent2, contextFlags);
|
|
71481
|
+
case 301 /* ImportAttribute */:
|
|
71482
|
+
return getContextualImportAttributeType(parent2);
|
|
71444
71483
|
}
|
|
71445
71484
|
return void 0;
|
|
71446
71485
|
}
|
|
@@ -71488,6 +71527,12 @@ ${lanes.join("\n")}
|
|
|
71488
71527
|
}
|
|
71489
71528
|
}
|
|
71490
71529
|
}
|
|
71530
|
+
function getContextualImportAttributeType(node) {
|
|
71531
|
+
return getTypeOfPropertyOfContextualType(getGlobalImportAttributesType(
|
|
71532
|
+
/*reportErrors*/
|
|
71533
|
+
false
|
|
71534
|
+
), getNameFromImportAttribute(node));
|
|
71535
|
+
}
|
|
71491
71536
|
function getContextualJsxElementAttributesType(node, contextFlags) {
|
|
71492
71537
|
if (isJsxOpeningElement(node) && contextFlags !== 4 /* Completions */) {
|
|
71493
71538
|
const index = findContextualNode(
|
|
@@ -83573,6 +83618,13 @@ ${lanes.join("\n")}
|
|
|
83573
83618
|
var _a;
|
|
83574
83619
|
const node = declaration.attributes;
|
|
83575
83620
|
if (node) {
|
|
83621
|
+
const importAttributesType = getGlobalImportAttributesType(
|
|
83622
|
+
/*reportErrors*/
|
|
83623
|
+
true
|
|
83624
|
+
);
|
|
83625
|
+
if (importAttributesType !== emptyObjectType) {
|
|
83626
|
+
checkTypeAssignableTo(getTypeFromImportAttributes(node), getNullableType(importAttributesType, 32768 /* Undefined */), node);
|
|
83627
|
+
}
|
|
83576
83628
|
const validForTypeAttributes = isExclusivelyTypeOnlyImportOrExport(declaration);
|
|
83577
83629
|
const override = getResolutionModeOverride(node, validForTypeAttributes ? grammarErrorOnNode : void 0);
|
|
83578
83630
|
const isImportAttributes2 = declaration.attributes.token === 118 /* WithKeyword */;
|
|
@@ -83592,6 +83644,9 @@ ${lanes.join("\n")}
|
|
|
83592
83644
|
}
|
|
83593
83645
|
}
|
|
83594
83646
|
}
|
|
83647
|
+
function checkImportAttribute(node) {
|
|
83648
|
+
return getRegularTypeOfLiteralType(checkExpressionCached(node.value));
|
|
83649
|
+
}
|
|
83595
83650
|
function checkImportDeclaration(node) {
|
|
83596
83651
|
if (checkGrammarModuleElementContext(node, isInJSFile(node) ? Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_module : Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_namespace_or_module)) {
|
|
83597
83652
|
return;
|
|
@@ -85007,6 +85062,12 @@ ${lanes.join("\n")}
|
|
|
85007
85062
|
if (isMetaProperty(node.parent) && node.parent.keywordToken === node.kind) {
|
|
85008
85063
|
return checkMetaPropertyKeyword(node.parent);
|
|
85009
85064
|
}
|
|
85065
|
+
if (isImportAttributes(node)) {
|
|
85066
|
+
return getGlobalImportAttributesType(
|
|
85067
|
+
/*reportErrors*/
|
|
85068
|
+
false
|
|
85069
|
+
);
|
|
85070
|
+
}
|
|
85010
85071
|
return errorType;
|
|
85011
85072
|
}
|
|
85012
85073
|
function getTypeOfAssignmentPattern(expr) {
|
|
@@ -122537,7 +122598,7 @@ ${lanes.join("\n")}
|
|
|
122537
122598
|
}
|
|
122538
122599
|
const isFromNodeModulesSearch = resolution.isExternalLibraryImport;
|
|
122539
122600
|
const isJsFile = !resolutionExtensionIsTSOrJson(resolution.extension);
|
|
122540
|
-
const isJsFileFromNodeModules = isFromNodeModulesSearch && isJsFile;
|
|
122601
|
+
const isJsFileFromNodeModules = isFromNodeModulesSearch && isJsFile && (!resolution.originalPath || pathContainsNodeModules(resolution.resolvedFileName));
|
|
122541
122602
|
const resolvedFileName = resolution.resolvedFileName;
|
|
122542
122603
|
if (isFromNodeModulesSearch) {
|
|
122543
122604
|
currentNodeModulesDepth++;
|
|
@@ -160083,7 +160144,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
160083
160144
|
return isIdentifier(e) ? e : isPropertyAccessExpression(e) ? getLeftMostName(e.expression) : void 0;
|
|
160084
160145
|
}
|
|
160085
160146
|
function tryGetGlobalSymbols() {
|
|
160086
|
-
const result = tryGetObjectTypeLiteralInTypeArgumentCompletionSymbols() || tryGetObjectLikeCompletionSymbols() || tryGetImportCompletionSymbols() || tryGetImportOrExportClauseCompletionSymbols() || tryGetLocalNamedExportCompletionSymbols() || tryGetConstructorCompletion() || tryGetClassLikeCompletionSymbols() || tryGetJsxCompletionSymbols() || (getGlobalCompletions(), 1 /* Success */);
|
|
160147
|
+
const result = tryGetObjectTypeLiteralInTypeArgumentCompletionSymbols() || tryGetObjectLikeCompletionSymbols() || tryGetImportCompletionSymbols() || tryGetImportOrExportClauseCompletionSymbols() || tryGetImportAttributesCompletionSymbols() || tryGetLocalNamedExportCompletionSymbols() || tryGetConstructorCompletion() || tryGetClassLikeCompletionSymbols() || tryGetJsxCompletionSymbols() || (getGlobalCompletions(), 1 /* Success */);
|
|
160087
160148
|
return result === 1 /* Success */;
|
|
160088
160149
|
}
|
|
160089
160150
|
function tryGetConstructorCompletion() {
|
|
@@ -160551,6 +160612,16 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
160551
160612
|
}
|
|
160552
160613
|
return 1 /* Success */;
|
|
160553
160614
|
}
|
|
160615
|
+
function tryGetImportAttributesCompletionSymbols() {
|
|
160616
|
+
if (contextToken === void 0)
|
|
160617
|
+
return 0 /* Continue */;
|
|
160618
|
+
const importAttributes = contextToken.kind === 19 /* OpenBraceToken */ || contextToken.kind === 28 /* CommaToken */ ? tryCast(contextToken.parent, isImportAttributes) : contextToken.kind === 59 /* ColonToken */ ? tryCast(contextToken.parent.parent, isImportAttributes) : void 0;
|
|
160619
|
+
if (importAttributes === void 0)
|
|
160620
|
+
return 0 /* Continue */;
|
|
160621
|
+
const existing = new Set(importAttributes.elements.map(getNameFromImportAttribute));
|
|
160622
|
+
symbols = filter(typeChecker.getTypeAtLocation(importAttributes).getApparentProperties(), (attr) => !existing.has(attr.escapedName));
|
|
160623
|
+
return 1 /* Success */;
|
|
160624
|
+
}
|
|
160554
160625
|
function tryGetLocalNamedExportCompletionSymbols() {
|
|
160555
160626
|
var _a;
|
|
160556
160627
|
const namedExports = contextToken && (contextToken.kind === 19 /* OpenBraceToken */ || contextToken.kind === 28 /* CommaToken */) ? tryCast(contextToken.parent, isNamedExports) : void 0;
|
|
@@ -186443,6 +186514,7 @@ ${e.message}`;
|
|
|
186443
186514
|
getModuleSpecifierEndingPreference: () => getModuleSpecifierEndingPreference,
|
|
186444
186515
|
getModuleSpecifierResolverHost: () => getModuleSpecifierResolverHost,
|
|
186445
186516
|
getNameForExportedSymbol: () => getNameForExportedSymbol,
|
|
186517
|
+
getNameFromImportAttribute: () => getNameFromImportAttribute,
|
|
186446
186518
|
getNameFromIndexInfo: () => getNameFromIndexInfo,
|
|
186447
186519
|
getNameFromPropertyName: () => getNameFromPropertyName,
|
|
186448
186520
|
getNameOfAccessExpression: () => getNameOfAccessExpression,
|
|
@@ -188864,6 +188936,7 @@ ${e.message}`;
|
|
|
188864
188936
|
getModuleSpecifierEndingPreference: () => getModuleSpecifierEndingPreference,
|
|
188865
188937
|
getModuleSpecifierResolverHost: () => getModuleSpecifierResolverHost,
|
|
188866
188938
|
getNameForExportedSymbol: () => getNameForExportedSymbol,
|
|
188939
|
+
getNameFromImportAttribute: () => getNameFromImportAttribute,
|
|
188867
188940
|
getNameFromIndexInfo: () => getNameFromIndexInfo,
|
|
188868
188941
|
getNameFromPropertyName: () => getNameFromPropertyName,
|
|
188869
188942
|
getNameOfAccessExpression: () => getNameOfAccessExpression,
|
package/lib/typingsInstaller.js
CHANGED
|
@@ -54,7 +54,7 @@ var path = __toESM(require("path"));
|
|
|
54
54
|
|
|
55
55
|
// src/compiler/corePublic.ts
|
|
56
56
|
var versionMajorMinor = "5.4";
|
|
57
|
-
var version = `${versionMajorMinor}.0-dev.
|
|
57
|
+
var version = `${versionMajorMinor}.0-dev.20240111`;
|
|
58
58
|
|
|
59
59
|
// src/compiler/core.ts
|
|
60
60
|
var emptyArray = [];
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "typescript",
|
|
3
3
|
"author": "Microsoft Corp.",
|
|
4
4
|
"homepage": "https://www.typescriptlang.org/",
|
|
5
|
-
"version": "5.4.0-dev.
|
|
5
|
+
"version": "5.4.0-dev.20240111",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"description": "TypeScript is a language for application scale JavaScript development",
|
|
8
8
|
"keywords": [
|
|
@@ -113,5 +113,5 @@
|
|
|
113
113
|
"node": "20.1.0",
|
|
114
114
|
"npm": "8.19.4"
|
|
115
115
|
},
|
|
116
|
-
"gitHead": "
|
|
116
|
+
"gitHead": "7398b8ed2e8d9643d75a7e0fddec8b2044eceeb5"
|
|
117
117
|
}
|