typescript 4.6.0-dev.20220105 → 4.6.0-dev.20220109
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/lib.es2022.error.d.ts +50 -3
- package/lib/tsc.js +46 -37
- package/lib/tsserver.js +205 -130
- package/lib/tsserverlibrary.d.ts +1 -0
- package/lib/tsserverlibrary.js +176 -129
- package/lib/typescript.js +173 -129
- package/lib/typescriptServices.js +173 -129
- package/lib/typingsInstaller.js +160 -122
- package/package.json +1 -1
package/lib/typingsInstaller.js
CHANGED
|
@@ -89,7 +89,7 @@ var ts;
|
|
|
89
89
|
// The following is baselined as a literal template type without intervention
|
|
90
90
|
/** The version of the TypeScript compiler release */
|
|
91
91
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
92
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
92
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220109";
|
|
93
93
|
/* @internal */
|
|
94
94
|
var Comparison;
|
|
95
95
|
(function (Comparison) {
|
|
@@ -14445,7 +14445,8 @@ var ts;
|
|
|
14445
14445
|
Float64Array: ["at"],
|
|
14446
14446
|
BigInt64Array: ["at"],
|
|
14447
14447
|
BigUint64Array: ["at"],
|
|
14448
|
-
ObjectConstructor: ["hasOwn"]
|
|
14448
|
+
ObjectConstructor: ["hasOwn"],
|
|
14449
|
+
Error: ["cause"]
|
|
14449
14450
|
}
|
|
14450
14451
|
};
|
|
14451
14452
|
}
|
|
@@ -20756,9 +20757,40 @@ var ts;
|
|
|
20756
20757
|
}
|
|
20757
20758
|
ts.isFunctionExpressionOrArrowFunction = isFunctionExpressionOrArrowFunction;
|
|
20758
20759
|
function escapeSnippetText(text) {
|
|
20759
|
-
return text.replace(/\$/gm, "\\$");
|
|
20760
|
+
return text.replace(/\$/gm, function () { return "\\$"; });
|
|
20760
20761
|
}
|
|
20761
20762
|
ts.escapeSnippetText = escapeSnippetText;
|
|
20763
|
+
function isNumericLiteralName(name) {
|
|
20764
|
+
// The intent of numeric names is that
|
|
20765
|
+
// - they are names with text in a numeric form, and that
|
|
20766
|
+
// - setting properties/indexing with them is always equivalent to doing so with the numeric literal 'numLit',
|
|
20767
|
+
// acquired by applying the abstract 'ToNumber' operation on the name's text.
|
|
20768
|
+
//
|
|
20769
|
+
// The subtlety is in the latter portion, as we cannot reliably say that anything that looks like a numeric literal is a numeric name.
|
|
20770
|
+
// In fact, it is the case that the text of the name must be equal to 'ToString(numLit)' for this to hold.
|
|
20771
|
+
//
|
|
20772
|
+
// Consider the property name '"0xF00D"'. When one indexes with '0xF00D', they are actually indexing with the value of 'ToString(0xF00D)'
|
|
20773
|
+
// according to the ECMAScript specification, so it is actually as if the user indexed with the string '"61453"'.
|
|
20774
|
+
// Thus, the text of all numeric literals equivalent to '61543' such as '0xF00D', '0xf00D', '0170015', etc. are not valid numeric names
|
|
20775
|
+
// because their 'ToString' representation is not equal to their original text.
|
|
20776
|
+
// This is motivated by ECMA-262 sections 9.3.1, 9.8.1, 11.1.5, and 11.2.1.
|
|
20777
|
+
//
|
|
20778
|
+
// Here, we test whether 'ToString(ToNumber(name))' is exactly equal to 'name'.
|
|
20779
|
+
// The '+' prefix operator is equivalent here to applying the abstract ToNumber operation.
|
|
20780
|
+
// Applying the 'toString()' method on a number gives us the abstract ToString operation on a number.
|
|
20781
|
+
//
|
|
20782
|
+
// Note that this accepts the values 'Infinity', '-Infinity', and 'NaN', and that this is intentional.
|
|
20783
|
+
// This is desired behavior, because when indexing with them as numeric entities, you are indexing
|
|
20784
|
+
// with the strings '"Infinity"', '"-Infinity"', and '"NaN"' respectively.
|
|
20785
|
+
return (+name).toString() === name;
|
|
20786
|
+
}
|
|
20787
|
+
ts.isNumericLiteralName = isNumericLiteralName;
|
|
20788
|
+
function createPropertyNameNodeForIdentifierOrLiteral(name, target, singleQuote, stringNamed) {
|
|
20789
|
+
return ts.isIdentifierText(name, target) ? ts.factory.createIdentifier(name) :
|
|
20790
|
+
!stringNamed && isNumericLiteralName(name) && +name >= 0 ? ts.factory.createNumericLiteral(+name) :
|
|
20791
|
+
ts.factory.createStringLiteral(name, !!singleQuote);
|
|
20792
|
+
}
|
|
20793
|
+
ts.createPropertyNameNodeForIdentifierOrLiteral = createPropertyNameNodeForIdentifierOrLiteral;
|
|
20762
20794
|
function isThisTypeParameter(type) {
|
|
20763
20795
|
return !!(type.flags & 262144 /* TypeParameter */ && type.isThisType);
|
|
20764
20796
|
}
|
|
@@ -46831,6 +46863,7 @@ var ts;
|
|
|
46831
46863
|
var location = ts.getParseTreeNode(locationIn);
|
|
46832
46864
|
return location ? getTypeOfSymbolAtLocation(symbol, location) : errorType;
|
|
46833
46865
|
},
|
|
46866
|
+
getTypeOfSymbol: getTypeOfSymbol,
|
|
46834
46867
|
getSymbolsOfParameterPropertyDeclaration: function (parameterIn, parameterName) {
|
|
46835
46868
|
var parameter = ts.getParseTreeNode(parameterIn, ts.isParameter);
|
|
46836
46869
|
if (parameter === undefined)
|
|
@@ -52186,7 +52219,7 @@ var ts;
|
|
|
52186
52219
|
}
|
|
52187
52220
|
var rawName = ts.unescapeLeadingUnderscores(symbol.escapedName);
|
|
52188
52221
|
var stringNamed = !!ts.length(symbol.declarations) && ts.every(symbol.declarations, isStringNamed);
|
|
52189
|
-
return createPropertyNameNodeForIdentifierOrLiteral(rawName,
|
|
52222
|
+
return ts.createPropertyNameNodeForIdentifierOrLiteral(rawName, ts.getEmitScriptTarget(compilerOptions), singleQuote, stringNamed);
|
|
52190
52223
|
}
|
|
52191
52224
|
// See getNameForSymbolFromNameType for a stringy equivalent
|
|
52192
52225
|
function getPropertyNameNodeForSymbolFromNameType(symbol, context, singleQuote) {
|
|
@@ -52194,24 +52227,19 @@ var ts;
|
|
|
52194
52227
|
if (nameType) {
|
|
52195
52228
|
if (nameType.flags & 384 /* StringOrNumberLiteral */) {
|
|
52196
52229
|
var name = "" + nameType.value;
|
|
52197
|
-
if (!ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) && !isNumericLiteralName(name)) {
|
|
52230
|
+
if (!ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) && !ts.isNumericLiteralName(name)) {
|
|
52198
52231
|
return ts.factory.createStringLiteral(name, !!singleQuote);
|
|
52199
52232
|
}
|
|
52200
|
-
if (isNumericLiteralName(name) && ts.startsWith(name, "-")) {
|
|
52233
|
+
if (ts.isNumericLiteralName(name) && ts.startsWith(name, "-")) {
|
|
52201
52234
|
return ts.factory.createComputedPropertyName(ts.factory.createNumericLiteral(+name));
|
|
52202
52235
|
}
|
|
52203
|
-
return createPropertyNameNodeForIdentifierOrLiteral(name);
|
|
52236
|
+
return ts.createPropertyNameNodeForIdentifierOrLiteral(name, ts.getEmitScriptTarget(compilerOptions));
|
|
52204
52237
|
}
|
|
52205
52238
|
if (nameType.flags & 8192 /* UniqueESSymbol */) {
|
|
52206
52239
|
return ts.factory.createComputedPropertyName(symbolToExpression(nameType.symbol, context, 111551 /* Value */));
|
|
52207
52240
|
}
|
|
52208
52241
|
}
|
|
52209
52242
|
}
|
|
52210
|
-
function createPropertyNameNodeForIdentifierOrLiteral(name, stringNamed, singleQuote) {
|
|
52211
|
-
return ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) ? ts.factory.createIdentifier(name) :
|
|
52212
|
-
!stringNamed && isNumericLiteralName(name) && +name >= 0 ? ts.factory.createNumericLiteral(+name) :
|
|
52213
|
-
ts.factory.createStringLiteral(name, !!singleQuote);
|
|
52214
|
-
}
|
|
52215
52243
|
function cloneNodeBuilderContext(context) {
|
|
52216
52244
|
var initial = __assign({}, context);
|
|
52217
52245
|
// Make type parameters created within this context not consume the name outside this context
|
|
@@ -53727,10 +53755,10 @@ var ts;
|
|
|
53727
53755
|
if (nameType) {
|
|
53728
53756
|
if (nameType.flags & 384 /* StringOrNumberLiteral */) {
|
|
53729
53757
|
var name = "" + nameType.value;
|
|
53730
|
-
if (!ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) && !isNumericLiteralName(name)) {
|
|
53758
|
+
if (!ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) && !ts.isNumericLiteralName(name)) {
|
|
53731
53759
|
return "\"" + ts.escapeString(name, 34 /* doubleQuote */) + "\"";
|
|
53732
53760
|
}
|
|
53733
|
-
if (isNumericLiteralName(name) && ts.startsWith(name, "-")) {
|
|
53761
|
+
if (ts.isNumericLiteralName(name) && ts.startsWith(name, "-")) {
|
|
53734
53762
|
return "[" + name + "]";
|
|
53735
53763
|
}
|
|
53736
53764
|
return name;
|
|
@@ -57773,7 +57801,7 @@ var ts;
|
|
|
57773
57801
|
// signature applies to types assignable to 'number' and numeric string literal types.
|
|
57774
57802
|
return isTypeAssignableTo(source, target) ||
|
|
57775
57803
|
target === stringType && isTypeAssignableTo(source, numberType) ||
|
|
57776
|
-
target === numberType && !!(source.flags & 128 /* StringLiteral */) && isNumericLiteralName(source.value);
|
|
57804
|
+
target === numberType && !!(source.flags & 128 /* StringLiteral */) && ts.isNumericLiteralName(source.value);
|
|
57777
57805
|
}
|
|
57778
57806
|
function getIndexInfosOfStructuredType(type) {
|
|
57779
57807
|
if (type.flags & 3670016 /* StructuredType */) {
|
|
@@ -60339,7 +60367,7 @@ var ts;
|
|
|
60339
60367
|
getFlowTypeOfReference(accessExpression, propType) :
|
|
60340
60368
|
propType;
|
|
60341
60369
|
}
|
|
60342
|
-
if (everyType(objectType, isTupleType) && isNumericLiteralName(propName) && +propName >= 0) {
|
|
60370
|
+
if (everyType(objectType, isTupleType) && ts.isNumericLiteralName(propName) && +propName >= 0) {
|
|
60343
60371
|
if (accessNode && everyType(objectType, function (t) { return !t.target.hasRestElement; }) && !(accessFlags & 16 /* NoTupleBoundsCheck */)) {
|
|
60344
60372
|
var indexNode = getIndexNodeForAccessExpression(accessNode);
|
|
60345
60373
|
if (isTupleType(objectType)) {
|
|
@@ -60624,7 +60652,7 @@ var ts;
|
|
|
60624
60652
|
return everyType(indexType, function (t) {
|
|
60625
60653
|
if (t.flags & 384 /* StringOrNumberLiteral */) {
|
|
60626
60654
|
var propName = getPropertyNameFromType(t);
|
|
60627
|
-
if (isNumericLiteralName(propName)) {
|
|
60655
|
+
if (ts.isNumericLiteralName(propName)) {
|
|
60628
60656
|
var index = +propName;
|
|
60629
60657
|
return index >= 0 && index < limit;
|
|
60630
60658
|
}
|
|
@@ -64166,7 +64194,7 @@ var ts;
|
|
|
64166
64194
|
else {
|
|
64167
64195
|
// conditionals aren't related to one another via distributive constraint as it is much too inaccurate and allows way
|
|
64168
64196
|
// more assignments than are desirable (since it maps the source check type to its constraint, it loses information)
|
|
64169
|
-
var distributiveConstraint = getConstraintOfDistributiveConditionalType(source);
|
|
64197
|
+
var distributiveConstraint = hasNonCircularBaseConstraint(source) ? getConstraintOfDistributiveConditionalType(source) : undefined;
|
|
64170
64198
|
if (distributiveConstraint) {
|
|
64171
64199
|
if (result = isRelatedTo(distributiveConstraint, target, 1 /* Source */, reportErrors)) {
|
|
64172
64200
|
resetErrorInfo(saveErrorInfo);
|
|
@@ -64712,7 +64740,7 @@ var ts;
|
|
|
64712
64740
|
for (var _b = 0, _c = excludeProperties(properties, excludedProperties); _b < _c.length; _b++) {
|
|
64713
64741
|
var targetProp = _c[_b];
|
|
64714
64742
|
var name = targetProp.escapedName;
|
|
64715
|
-
if (!(targetProp.flags & 4194304 /* Prototype */) && (!numericNamesOnly || isNumericLiteralName(name) || name === "length")) {
|
|
64743
|
+
if (!(targetProp.flags & 4194304 /* Prototype */) && (!numericNamesOnly || ts.isNumericLiteralName(name) || name === "length")) {
|
|
64716
64744
|
var sourceProp = getPropertyOfType(source, name);
|
|
64717
64745
|
if (sourceProp && sourceProp !== targetProp) {
|
|
64718
64746
|
var related = propertyRelatedTo(source, target, sourceProp, targetProp, getNonMissingTypeOfSymbol, reportErrors, intersectionState, relation === comparableRelation);
|
|
@@ -64785,7 +64813,8 @@ var ts;
|
|
|
64785
64813
|
var incompatibleReporter = kind === 1 /* Construct */ ? reportIncompatibleConstructSignatureReturn : reportIncompatibleCallSignatureReturn;
|
|
64786
64814
|
var sourceObjectFlags = ts.getObjectFlags(source);
|
|
64787
64815
|
var targetObjectFlags = ts.getObjectFlags(target);
|
|
64788
|
-
if (sourceObjectFlags & 64 /* Instantiated */ && targetObjectFlags & 64 /* Instantiated */ && source.symbol === target.symbol
|
|
64816
|
+
if (sourceObjectFlags & 64 /* Instantiated */ && targetObjectFlags & 64 /* Instantiated */ && source.symbol === target.symbol ||
|
|
64817
|
+
sourceObjectFlags & 4 /* Reference */ && targetObjectFlags & 4 /* Reference */ && source.target === target.target) {
|
|
64789
64818
|
// We have instantiations of the same anonymous type (which typically will be the type of a
|
|
64790
64819
|
// method). Simply do a pairwise comparison of the signatures in the two signature lists instead
|
|
64791
64820
|
// of the much more expensive N * M comparison matrix we explore below. We erase type parameters
|
|
@@ -65820,9 +65849,12 @@ var ts;
|
|
|
65820
65849
|
* with no call or construct signatures.
|
|
65821
65850
|
*/
|
|
65822
65851
|
function isObjectTypeWithInferableIndex(type) {
|
|
65823
|
-
return type.flags & 2097152 /* Intersection */
|
|
65824
|
-
|
|
65825
|
-
|
|
65852
|
+
return type.flags & 2097152 /* Intersection */
|
|
65853
|
+
? ts.every(type.types, isObjectTypeWithInferableIndex)
|
|
65854
|
+
: !!(type.symbol
|
|
65855
|
+
&& (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */ | 384 /* Enum */ | 512 /* ValueModule */)) !== 0
|
|
65856
|
+
&& !(type.symbol.flags & 32 /* Class */)
|
|
65857
|
+
&& !typeHasCallOrConstructSignatures(type)) || !!(ts.getObjectFlags(type) & 1024 /* ReverseMapped */ && isObjectTypeWithInferableIndex(type.source));
|
|
65826
65858
|
}
|
|
65827
65859
|
function createSymbolWithType(source, type) {
|
|
65828
65860
|
var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8 /* Readonly */);
|
|
@@ -70792,7 +70824,7 @@ var ts;
|
|
|
70792
70824
|
}
|
|
70793
70825
|
if (isTupleType(t)) {
|
|
70794
70826
|
var restType = getRestTypeOfTupleType(t);
|
|
70795
|
-
if (restType && isNumericLiteralName(name) && +name >= 0) {
|
|
70827
|
+
if (restType && ts.isNumericLiteralName(name) && +name >= 0) {
|
|
70796
70828
|
return restType;
|
|
70797
70829
|
}
|
|
70798
70830
|
}
|
|
@@ -71433,10 +71465,10 @@ var ts;
|
|
|
71433
71465
|
case 161 /* ComputedPropertyName */:
|
|
71434
71466
|
return isNumericComputedName(name);
|
|
71435
71467
|
case 79 /* Identifier */:
|
|
71436
|
-
return isNumericLiteralName(name.escapedText);
|
|
71468
|
+
return ts.isNumericLiteralName(name.escapedText);
|
|
71437
71469
|
case 8 /* NumericLiteral */:
|
|
71438
71470
|
case 10 /* StringLiteral */:
|
|
71439
|
-
return isNumericLiteralName(name.text);
|
|
71471
|
+
return ts.isNumericLiteralName(name.text);
|
|
71440
71472
|
default:
|
|
71441
71473
|
return false;
|
|
71442
71474
|
}
|
|
@@ -71446,30 +71478,6 @@ var ts;
|
|
|
71446
71478
|
// but this behavior is consistent with checkIndexedAccess
|
|
71447
71479
|
return isTypeAssignableToKind(checkComputedPropertyName(name), 296 /* NumberLike */);
|
|
71448
71480
|
}
|
|
71449
|
-
function isNumericLiteralName(name) {
|
|
71450
|
-
// The intent of numeric names is that
|
|
71451
|
-
// - they are names with text in a numeric form, and that
|
|
71452
|
-
// - setting properties/indexing with them is always equivalent to doing so with the numeric literal 'numLit',
|
|
71453
|
-
// acquired by applying the abstract 'ToNumber' operation on the name's text.
|
|
71454
|
-
//
|
|
71455
|
-
// The subtlety is in the latter portion, as we cannot reliably say that anything that looks like a numeric literal is a numeric name.
|
|
71456
|
-
// In fact, it is the case that the text of the name must be equal to 'ToString(numLit)' for this to hold.
|
|
71457
|
-
//
|
|
71458
|
-
// Consider the property name '"0xF00D"'. When one indexes with '0xF00D', they are actually indexing with the value of 'ToString(0xF00D)'
|
|
71459
|
-
// according to the ECMAScript specification, so it is actually as if the user indexed with the string '"61453"'.
|
|
71460
|
-
// Thus, the text of all numeric literals equivalent to '61543' such as '0xF00D', '0xf00D', '0170015', etc. are not valid numeric names
|
|
71461
|
-
// because their 'ToString' representation is not equal to their original text.
|
|
71462
|
-
// This is motivated by ECMA-262 sections 9.3.1, 9.8.1, 11.1.5, and 11.2.1.
|
|
71463
|
-
//
|
|
71464
|
-
// Here, we test whether 'ToString(ToNumber(name))' is exactly equal to 'name'.
|
|
71465
|
-
// The '+' prefix operator is equivalent here to applying the abstract ToNumber operation.
|
|
71466
|
-
// Applying the 'toString()' method on a number gives us the abstract ToString operation on a number.
|
|
71467
|
-
//
|
|
71468
|
-
// Note that this accepts the values 'Infinity', '-Infinity', and 'NaN', and that this is intentional.
|
|
71469
|
-
// This is desired behavior, because when indexing with them as numeric entities, you are indexing
|
|
71470
|
-
// with the strings '"Infinity"', '"-Infinity"', and '"NaN"' respectively.
|
|
71471
|
-
return (+name).toString() === name;
|
|
71472
|
-
}
|
|
71473
71481
|
function checkComputedPropertyName(node) {
|
|
71474
71482
|
var links = getNodeLinks(node.expression);
|
|
71475
71483
|
if (!links.resolvedType) {
|
|
@@ -71505,7 +71513,7 @@ var ts;
|
|
|
71505
71513
|
function isSymbolWithNumericName(symbol) {
|
|
71506
71514
|
var _a;
|
|
71507
71515
|
var firstDecl = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a[0];
|
|
71508
|
-
return isNumericLiteralName(symbol.escapedName) || (firstDecl && ts.isNamedDeclaration(firstDecl) && isNumericName(firstDecl.name));
|
|
71516
|
+
return ts.isNumericLiteralName(symbol.escapedName) || (firstDecl && ts.isNamedDeclaration(firstDecl) && isNumericName(firstDecl.name));
|
|
71509
71517
|
}
|
|
71510
71518
|
function isSymbolWithSymbolName(symbol) {
|
|
71511
71519
|
var _a;
|
|
@@ -82443,7 +82451,7 @@ var ts;
|
|
|
82443
82451
|
}
|
|
82444
82452
|
else {
|
|
82445
82453
|
var text = ts.getTextOfPropertyName(member.name);
|
|
82446
|
-
if (isNumericLiteralName(text) && !ts.isInfinityOrNaNString(text)) {
|
|
82454
|
+
if (ts.isNumericLiteralName(text) && !ts.isInfinityOrNaNString(text)) {
|
|
82447
82455
|
error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name);
|
|
82448
82456
|
}
|
|
82449
82457
|
}
|
|
@@ -119908,7 +119916,7 @@ var ts;
|
|
|
119908
119916
|
}
|
|
119909
119917
|
ts.getLocaleTimeString = getLocaleTimeString;
|
|
119910
119918
|
/**
|
|
119911
|
-
* Create a function that reports watch status by writing to the system and handles the
|
|
119919
|
+
* Create a function that reports watch status by writing to the system and handles the formatting of the diagnostic
|
|
119912
119920
|
*/
|
|
119913
119921
|
function createWatchStatusReporter(system, pretty) {
|
|
119914
119922
|
return pretty ?
|
|
@@ -119969,7 +119977,7 @@ var ts;
|
|
|
119969
119977
|
ts.Diagnostics.Found_0_errors_Watching_for_file_changes;
|
|
119970
119978
|
}
|
|
119971
119979
|
ts.getWatchErrorSummaryDiagnosticMessage = getWatchErrorSummaryDiagnosticMessage;
|
|
119972
|
-
function getErrorSummaryText(errorCount, filesInError, newLine) {
|
|
119980
|
+
function getErrorSummaryText(errorCount, filesInError, newLine, host) {
|
|
119973
119981
|
if (errorCount === 0)
|
|
119974
119982
|
return "";
|
|
119975
119983
|
var nonNilFiles = filesInError.filter(function (fileInError) { return fileInError !== undefined; });
|
|
@@ -119984,10 +119992,10 @@ var ts;
|
|
|
119984
119992
|
distinctFileNamesWithLines.length === 1 ?
|
|
119985
119993
|
ts.Diagnostics.Found_0_errors_in_1_file :
|
|
119986
119994
|
ts.Diagnostics.Found_0_errors_in_1_files, errorCount, distinctFileNamesWithLines.length);
|
|
119987
|
-
return "" + newLine + ts.flattenDiagnosticMessageText(d.messageText, newLine) + newLine + newLine + (errorCount > 1 ? createTabularErrorsDisplay(nonNilFiles) : "");
|
|
119995
|
+
return "" + newLine + ts.flattenDiagnosticMessageText(d.messageText, newLine) + newLine + newLine + (errorCount > 1 ? createTabularErrorsDisplay(nonNilFiles, host) : "");
|
|
119988
119996
|
}
|
|
119989
119997
|
ts.getErrorSummaryText = getErrorSummaryText;
|
|
119990
|
-
function createTabularErrorsDisplay(filesInError) {
|
|
119998
|
+
function createTabularErrorsDisplay(filesInError, host) {
|
|
119991
119999
|
var distinctFiles = filesInError.filter(function (value, index, self) { return index === self.findIndex(function (file) { return (file === null || file === void 0 ? void 0 : file.fileName) === (value === null || value === void 0 ? void 0 : value.fileName); }); });
|
|
119992
120000
|
if (distinctFiles.length === 0)
|
|
119993
120001
|
return "";
|
|
@@ -120006,7 +120014,8 @@ var ts;
|
|
|
120006
120014
|
var leftPadding = errorCountDigitsLength < leftPaddingGoal ?
|
|
120007
120015
|
" ".repeat(leftPaddingGoal - errorCountDigitsLength)
|
|
120008
120016
|
: "";
|
|
120009
|
-
|
|
120017
|
+
var relativePath = ts.getRelativePathFromDirectory(host.getCurrentDirectory(), file.fileName, /* ignoreCase */ false);
|
|
120018
|
+
tabularData += "" + leftPadding + errorCount + " " + relativePath + ":" + file.line + "\n";
|
|
120010
120019
|
});
|
|
120011
120020
|
return tabularData;
|
|
120012
120021
|
}
|
|
@@ -120424,7 +120433,7 @@ var ts;
|
|
|
120424
120433
|
var system = input.system || ts.sys;
|
|
120425
120434
|
var host = input.host || (input.host = ts.createIncrementalCompilerHost(input.options, system));
|
|
120426
120435
|
var builderProgram = ts.createIncrementalProgram(input);
|
|
120427
|
-
var exitStatus = emitFilesAndReportErrorsAndGetExitStatus(builderProgram, input.reportDiagnostic || createDiagnosticReporter(system), function (s) { return host.trace && host.trace(s); }, input.reportErrorSummary || input.options.pretty ? function (errorCount, filesInError) { return system.write(getErrorSummaryText(errorCount, filesInError, system.newLine)); } : undefined);
|
|
120436
|
+
var exitStatus = emitFilesAndReportErrorsAndGetExitStatus(builderProgram, input.reportDiagnostic || createDiagnosticReporter(system), function (s) { return host.trace && host.trace(s); }, input.reportErrorSummary || input.options.pretty ? function (errorCount, filesInError) { return system.write(getErrorSummaryText(errorCount, filesInError, system.newLine, host)); } : undefined);
|
|
120428
120437
|
if (input.afterProgramEmitAndDiagnostics)
|
|
120429
120438
|
input.afterProgramEmitAndDiagnostics(builderProgram);
|
|
120430
120439
|
return exitStatus;
|
|
@@ -122898,14 +122907,8 @@ var ts;
|
|
|
122898
122907
|
var possibleSearchDirs = new ts.Set(fileNames.map(ts.getDirectoryPath));
|
|
122899
122908
|
possibleSearchDirs.add(projectRootPath);
|
|
122900
122909
|
possibleSearchDirs.forEach(function (searchDir) {
|
|
122901
|
-
|
|
122902
|
-
|
|
122903
|
-
var bowerJsonPath = ts.combinePaths(searchDir, "bower.json");
|
|
122904
|
-
getTypingNamesFromJson(bowerJsonPath, filesToWatch);
|
|
122905
|
-
var bowerComponentsPath = ts.combinePaths(searchDir, "bower_components");
|
|
122906
|
-
getTypingNamesFromPackagesFolder(bowerComponentsPath, filesToWatch);
|
|
122907
|
-
var nodeModulesPath = ts.combinePaths(searchDir, "node_modules");
|
|
122908
|
-
getTypingNamesFromPackagesFolder(nodeModulesPath, filesToWatch);
|
|
122910
|
+
getTypingNames(searchDir, "bower.json", "bower_components", filesToWatch);
|
|
122911
|
+
getTypingNames(searchDir, "package.json", "node_modules", filesToWatch);
|
|
122909
122912
|
});
|
|
122910
122913
|
if (!typeAcquisition.disableFilenameBasedTypeAcquisition) {
|
|
122911
122914
|
getTypingNamesFromSourceFileNames(fileNames);
|
|
@@ -122954,16 +122957,100 @@ var ts;
|
|
|
122954
122957
|
ts.forEach(typingNames, addInferredTyping);
|
|
122955
122958
|
}
|
|
122956
122959
|
/**
|
|
122957
|
-
*
|
|
122960
|
+
* Adds inferred typings from manifest/module pairs (think package.json + node_modules)
|
|
122961
|
+
*
|
|
122962
|
+
* @param projectRootPath is the path to the directory where to look for package.json, bower.json and other typing information
|
|
122963
|
+
* @param manifestName is the name of the manifest (package.json or bower.json)
|
|
122964
|
+
* @param modulesDirName is the directory name for modules (node_modules or bower_components). Should be lowercase!
|
|
122965
|
+
* @param filesToWatch are the files to watch for changes. We will push things into this array.
|
|
122958
122966
|
*/
|
|
122959
|
-
function
|
|
122960
|
-
|
|
122967
|
+
function getTypingNames(projectRootPath, manifestName, modulesDirName, filesToWatch) {
|
|
122968
|
+
// First, we check the manifests themselves. They're not
|
|
122969
|
+
// _required_, but they allow us to do some filtering when dealing
|
|
122970
|
+
// with big flat dep directories.
|
|
122971
|
+
var manifestPath = ts.combinePaths(projectRootPath, manifestName);
|
|
122972
|
+
var manifest;
|
|
122973
|
+
var manifestTypingNames;
|
|
122974
|
+
if (host.fileExists(manifestPath)) {
|
|
122975
|
+
filesToWatch.push(manifestPath);
|
|
122976
|
+
manifest = ts.readConfigFile(manifestPath, function (path) { return host.readFile(path); }).config;
|
|
122977
|
+
manifestTypingNames = ts.flatMap([manifest.dependencies, manifest.devDependencies, manifest.optionalDependencies, manifest.peerDependencies], ts.getOwnKeys);
|
|
122978
|
+
addInferredTypings(manifestTypingNames, "Typing names in '" + manifestPath + "' dependencies");
|
|
122979
|
+
}
|
|
122980
|
+
// Now we scan the directories for typing information in
|
|
122981
|
+
// already-installed dependencies (if present). Note that this
|
|
122982
|
+
// step happens regardless of whether a manifest was present,
|
|
122983
|
+
// which is certainly a valid configuration, if an unusual one.
|
|
122984
|
+
var packagesFolderPath = ts.combinePaths(projectRootPath, modulesDirName);
|
|
122985
|
+
filesToWatch.push(packagesFolderPath);
|
|
122986
|
+
if (!host.directoryExists(packagesFolderPath)) {
|
|
122961
122987
|
return;
|
|
122962
122988
|
}
|
|
122963
|
-
|
|
122964
|
-
|
|
122965
|
-
|
|
122966
|
-
|
|
122989
|
+
// There's two cases we have to take into account here:
|
|
122990
|
+
// 1. If manifest is undefined, then we're not using a manifest.
|
|
122991
|
+
// That means that we should scan _all_ dependencies at the top
|
|
122992
|
+
// level of the modulesDir.
|
|
122993
|
+
// 2. If manifest is defined, then we can do some special
|
|
122994
|
+
// filtering to reduce the amount of scanning we need to do.
|
|
122995
|
+
//
|
|
122996
|
+
// Previous versions of this algorithm checked for a `_requiredBy`
|
|
122997
|
+
// field in the package.json, but that field is only present in
|
|
122998
|
+
// `npm@>=3 <7`.
|
|
122999
|
+
// Package names that do **not** provide their own typings, so
|
|
123000
|
+
// we'll look them up.
|
|
123001
|
+
var packageNames = [];
|
|
123002
|
+
var dependencyManifestNames = manifestTypingNames
|
|
123003
|
+
// This is #1 described above.
|
|
123004
|
+
? manifestTypingNames.map(function (typingName) { return ts.combinePaths(packagesFolderPath, typingName, manifestName); })
|
|
123005
|
+
// And #2. Depth = 3 because scoped packages look like `node_modules/@foo/bar/package.json`
|
|
123006
|
+
: host.readDirectory(packagesFolderPath, [".json" /* Json */], /*excludes*/ undefined, /*includes*/ undefined, /*depth*/ 3)
|
|
123007
|
+
.filter(function (manifestPath) {
|
|
123008
|
+
if (ts.getBaseFileName(manifestPath) !== manifestName) {
|
|
123009
|
+
return false;
|
|
123010
|
+
}
|
|
123011
|
+
// It's ok to treat
|
|
123012
|
+
// `node_modules/@foo/bar/package.json` as a manifest,
|
|
123013
|
+
// but not `node_modules/jquery/nested/package.json`.
|
|
123014
|
+
// We only assume depth 3 is ok for formally scoped
|
|
123015
|
+
// packages. So that needs this dance here.
|
|
123016
|
+
var pathComponents = ts.getPathComponents(ts.normalizePath(manifestPath));
|
|
123017
|
+
var isScoped = pathComponents[pathComponents.length - 3][0] === "@";
|
|
123018
|
+
return isScoped && pathComponents[pathComponents.length - 4].toLowerCase() === modulesDirName || // `node_modules/@foo/bar`
|
|
123019
|
+
!isScoped && pathComponents[pathComponents.length - 3].toLowerCase() === modulesDirName; // `node_modules/foo`
|
|
123020
|
+
});
|
|
123021
|
+
if (log)
|
|
123022
|
+
log("Searching for typing names in " + packagesFolderPath + "; all files: " + JSON.stringify(dependencyManifestNames));
|
|
123023
|
+
// Once we have the names of things to look up, we iterate over
|
|
123024
|
+
// and either collect their included typings, or add them to the
|
|
123025
|
+
// list of typings we need to look up separately.
|
|
123026
|
+
for (var _i = 0, dependencyManifestNames_1 = dependencyManifestNames; _i < dependencyManifestNames_1.length; _i++) {
|
|
123027
|
+
var manifestPath_1 = dependencyManifestNames_1[_i];
|
|
123028
|
+
var normalizedFileName = ts.normalizePath(manifestPath_1);
|
|
123029
|
+
var result_1 = ts.readConfigFile(normalizedFileName, function (path) { return host.readFile(path); });
|
|
123030
|
+
var manifest_1 = result_1.config;
|
|
123031
|
+
// If the package has its own d.ts typings, those will take precedence. Otherwise the package name will be used
|
|
123032
|
+
// to download d.ts files from DefinitelyTyped
|
|
123033
|
+
if (!manifest_1.name) {
|
|
123034
|
+
continue;
|
|
123035
|
+
}
|
|
123036
|
+
var ownTypes = manifest_1.types || manifest_1.typings;
|
|
123037
|
+
if (ownTypes) {
|
|
123038
|
+
var absolutePath = ts.getNormalizedAbsolutePath(ownTypes, ts.getDirectoryPath(normalizedFileName));
|
|
123039
|
+
if (host.fileExists(absolutePath)) {
|
|
123040
|
+
if (log)
|
|
123041
|
+
log(" Package '" + manifest_1.name + "' provides its own types.");
|
|
123042
|
+
inferredTypings.set(manifest_1.name, absolutePath);
|
|
123043
|
+
}
|
|
123044
|
+
else {
|
|
123045
|
+
if (log)
|
|
123046
|
+
log(" Package '" + manifest_1.name + "' provides its own types but they are missing.");
|
|
123047
|
+
}
|
|
123048
|
+
}
|
|
123049
|
+
else {
|
|
123050
|
+
packageNames.push(manifest_1.name);
|
|
123051
|
+
}
|
|
123052
|
+
}
|
|
123053
|
+
addInferredTypings(packageNames, " Found package names");
|
|
122967
123054
|
}
|
|
122968
123055
|
/**
|
|
122969
123056
|
* Infer typing names from given file names. For example, the file name "jquery-min.2.3.4.js"
|
|
@@ -122989,55 +123076,6 @@ var ts;
|
|
|
122989
123076
|
addInferredTyping("react");
|
|
122990
123077
|
}
|
|
122991
123078
|
}
|
|
122992
|
-
/**
|
|
122993
|
-
* Infer typing names from packages folder (ex: node_module, bower_components)
|
|
122994
|
-
* @param packagesFolderPath is the path to the packages folder
|
|
122995
|
-
*/
|
|
122996
|
-
function getTypingNamesFromPackagesFolder(packagesFolderPath, filesToWatch) {
|
|
122997
|
-
filesToWatch.push(packagesFolderPath);
|
|
122998
|
-
// Todo: add support for ModuleResolutionHost too
|
|
122999
|
-
if (!host.directoryExists(packagesFolderPath)) {
|
|
123000
|
-
return;
|
|
123001
|
-
}
|
|
123002
|
-
// depth of 2, so we access `node_modules/foo` but not `node_modules/foo/bar`
|
|
123003
|
-
var fileNames = host.readDirectory(packagesFolderPath, [".json" /* Json */], /*excludes*/ undefined, /*includes*/ undefined, /*depth*/ 2);
|
|
123004
|
-
if (log)
|
|
123005
|
-
log("Searching for typing names in " + packagesFolderPath + "; all files: " + JSON.stringify(fileNames));
|
|
123006
|
-
var packageNames = [];
|
|
123007
|
-
for (var _i = 0, fileNames_1 = fileNames; _i < fileNames_1.length; _i++) {
|
|
123008
|
-
var fileName = fileNames_1[_i];
|
|
123009
|
-
var normalizedFileName = ts.normalizePath(fileName);
|
|
123010
|
-
var baseFileName = ts.getBaseFileName(normalizedFileName);
|
|
123011
|
-
if (baseFileName !== "package.json" && baseFileName !== "bower.json") {
|
|
123012
|
-
continue;
|
|
123013
|
-
}
|
|
123014
|
-
var result_1 = ts.readConfigFile(normalizedFileName, function (path) { return host.readFile(path); });
|
|
123015
|
-
var packageJson = result_1.config;
|
|
123016
|
-
// npm 3's package.json contains a "_requiredBy" field
|
|
123017
|
-
// we should include all the top level module names for npm 2, and only module names whose
|
|
123018
|
-
// "_requiredBy" field starts with "#" or equals "/" for npm 3.
|
|
123019
|
-
if (baseFileName === "package.json" && packageJson._requiredBy &&
|
|
123020
|
-
ts.filter(packageJson._requiredBy, function (r) { return r[0] === "#" || r === "/"; }).length === 0) {
|
|
123021
|
-
continue;
|
|
123022
|
-
}
|
|
123023
|
-
// If the package has its own d.ts typings, those will take precedence. Otherwise the package name will be used
|
|
123024
|
-
// to download d.ts files from DefinitelyTyped
|
|
123025
|
-
if (!packageJson.name) {
|
|
123026
|
-
continue;
|
|
123027
|
-
}
|
|
123028
|
-
var ownTypes = packageJson.types || packageJson.typings;
|
|
123029
|
-
if (ownTypes) {
|
|
123030
|
-
var absolutePath = ts.getNormalizedAbsolutePath(ownTypes, ts.getDirectoryPath(normalizedFileName));
|
|
123031
|
-
if (log)
|
|
123032
|
-
log(" Package '" + packageJson.name + "' provides its own types.");
|
|
123033
|
-
inferredTypings.set(packageJson.name, absolutePath);
|
|
123034
|
-
}
|
|
123035
|
-
else {
|
|
123036
|
-
packageNames.push(packageJson.name);
|
|
123037
|
-
}
|
|
123038
|
-
}
|
|
123039
|
-
addInferredTypings(packageNames, " Found package names");
|
|
123040
|
-
}
|
|
123041
123079
|
}
|
|
123042
123080
|
JsTyping.discoverTypings = discoverTypings;
|
|
123043
123081
|
var NameValidationResult;
|
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": "4.6.0-dev.
|
|
5
|
+
"version": "4.6.0-dev.20220109",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"description": "TypeScript is a language for application scale JavaScript development",
|
|
8
8
|
"keywords": [
|