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/typescript.js
CHANGED
|
@@ -294,7 +294,7 @@ var ts;
|
|
|
294
294
|
// The following is baselined as a literal template type without intervention
|
|
295
295
|
/** The version of the TypeScript compiler release */
|
|
296
296
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
297
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
297
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220109";
|
|
298
298
|
/* @internal */
|
|
299
299
|
var Comparison;
|
|
300
300
|
(function (Comparison) {
|
|
@@ -14650,7 +14650,8 @@ var ts;
|
|
|
14650
14650
|
Float64Array: ["at"],
|
|
14651
14651
|
BigInt64Array: ["at"],
|
|
14652
14652
|
BigUint64Array: ["at"],
|
|
14653
|
-
ObjectConstructor: ["hasOwn"]
|
|
14653
|
+
ObjectConstructor: ["hasOwn"],
|
|
14654
|
+
Error: ["cause"]
|
|
14654
14655
|
}
|
|
14655
14656
|
};
|
|
14656
14657
|
}
|
|
@@ -20961,9 +20962,40 @@ var ts;
|
|
|
20961
20962
|
}
|
|
20962
20963
|
ts.isFunctionExpressionOrArrowFunction = isFunctionExpressionOrArrowFunction;
|
|
20963
20964
|
function escapeSnippetText(text) {
|
|
20964
|
-
return text.replace(/\$/gm, "\\$");
|
|
20965
|
+
return text.replace(/\$/gm, function () { return "\\$"; });
|
|
20965
20966
|
}
|
|
20966
20967
|
ts.escapeSnippetText = escapeSnippetText;
|
|
20968
|
+
function isNumericLiteralName(name) {
|
|
20969
|
+
// The intent of numeric names is that
|
|
20970
|
+
// - they are names with text in a numeric form, and that
|
|
20971
|
+
// - setting properties/indexing with them is always equivalent to doing so with the numeric literal 'numLit',
|
|
20972
|
+
// acquired by applying the abstract 'ToNumber' operation on the name's text.
|
|
20973
|
+
//
|
|
20974
|
+
// The subtlety is in the latter portion, as we cannot reliably say that anything that looks like a numeric literal is a numeric name.
|
|
20975
|
+
// In fact, it is the case that the text of the name must be equal to 'ToString(numLit)' for this to hold.
|
|
20976
|
+
//
|
|
20977
|
+
// Consider the property name '"0xF00D"'. When one indexes with '0xF00D', they are actually indexing with the value of 'ToString(0xF00D)'
|
|
20978
|
+
// according to the ECMAScript specification, so it is actually as if the user indexed with the string '"61453"'.
|
|
20979
|
+
// Thus, the text of all numeric literals equivalent to '61543' such as '0xF00D', '0xf00D', '0170015', etc. are not valid numeric names
|
|
20980
|
+
// because their 'ToString' representation is not equal to their original text.
|
|
20981
|
+
// This is motivated by ECMA-262 sections 9.3.1, 9.8.1, 11.1.5, and 11.2.1.
|
|
20982
|
+
//
|
|
20983
|
+
// Here, we test whether 'ToString(ToNumber(name))' is exactly equal to 'name'.
|
|
20984
|
+
// The '+' prefix operator is equivalent here to applying the abstract ToNumber operation.
|
|
20985
|
+
// Applying the 'toString()' method on a number gives us the abstract ToString operation on a number.
|
|
20986
|
+
//
|
|
20987
|
+
// Note that this accepts the values 'Infinity', '-Infinity', and 'NaN', and that this is intentional.
|
|
20988
|
+
// This is desired behavior, because when indexing with them as numeric entities, you are indexing
|
|
20989
|
+
// with the strings '"Infinity"', '"-Infinity"', and '"NaN"' respectively.
|
|
20990
|
+
return (+name).toString() === name;
|
|
20991
|
+
}
|
|
20992
|
+
ts.isNumericLiteralName = isNumericLiteralName;
|
|
20993
|
+
function createPropertyNameNodeForIdentifierOrLiteral(name, target, singleQuote, stringNamed) {
|
|
20994
|
+
return ts.isIdentifierText(name, target) ? ts.factory.createIdentifier(name) :
|
|
20995
|
+
!stringNamed && isNumericLiteralName(name) && +name >= 0 ? ts.factory.createNumericLiteral(+name) :
|
|
20996
|
+
ts.factory.createStringLiteral(name, !!singleQuote);
|
|
20997
|
+
}
|
|
20998
|
+
ts.createPropertyNameNodeForIdentifierOrLiteral = createPropertyNameNodeForIdentifierOrLiteral;
|
|
20967
20999
|
function isThisTypeParameter(type) {
|
|
20968
21000
|
return !!(type.flags & 262144 /* TypeParameter */ && type.isThisType);
|
|
20969
21001
|
}
|
|
@@ -47036,6 +47068,7 @@ var ts;
|
|
|
47036
47068
|
var location = ts.getParseTreeNode(locationIn);
|
|
47037
47069
|
return location ? getTypeOfSymbolAtLocation(symbol, location) : errorType;
|
|
47038
47070
|
},
|
|
47071
|
+
getTypeOfSymbol: getTypeOfSymbol,
|
|
47039
47072
|
getSymbolsOfParameterPropertyDeclaration: function (parameterIn, parameterName) {
|
|
47040
47073
|
var parameter = ts.getParseTreeNode(parameterIn, ts.isParameter);
|
|
47041
47074
|
if (parameter === undefined)
|
|
@@ -52391,7 +52424,7 @@ var ts;
|
|
|
52391
52424
|
}
|
|
52392
52425
|
var rawName = ts.unescapeLeadingUnderscores(symbol.escapedName);
|
|
52393
52426
|
var stringNamed = !!ts.length(symbol.declarations) && ts.every(symbol.declarations, isStringNamed);
|
|
52394
|
-
return createPropertyNameNodeForIdentifierOrLiteral(rawName,
|
|
52427
|
+
return ts.createPropertyNameNodeForIdentifierOrLiteral(rawName, ts.getEmitScriptTarget(compilerOptions), singleQuote, stringNamed);
|
|
52395
52428
|
}
|
|
52396
52429
|
// See getNameForSymbolFromNameType for a stringy equivalent
|
|
52397
52430
|
function getPropertyNameNodeForSymbolFromNameType(symbol, context, singleQuote) {
|
|
@@ -52399,24 +52432,19 @@ var ts;
|
|
|
52399
52432
|
if (nameType) {
|
|
52400
52433
|
if (nameType.flags & 384 /* StringOrNumberLiteral */) {
|
|
52401
52434
|
var name = "" + nameType.value;
|
|
52402
|
-
if (!ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) && !isNumericLiteralName(name)) {
|
|
52435
|
+
if (!ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) && !ts.isNumericLiteralName(name)) {
|
|
52403
52436
|
return ts.factory.createStringLiteral(name, !!singleQuote);
|
|
52404
52437
|
}
|
|
52405
|
-
if (isNumericLiteralName(name) && ts.startsWith(name, "-")) {
|
|
52438
|
+
if (ts.isNumericLiteralName(name) && ts.startsWith(name, "-")) {
|
|
52406
52439
|
return ts.factory.createComputedPropertyName(ts.factory.createNumericLiteral(+name));
|
|
52407
52440
|
}
|
|
52408
|
-
return createPropertyNameNodeForIdentifierOrLiteral(name);
|
|
52441
|
+
return ts.createPropertyNameNodeForIdentifierOrLiteral(name, ts.getEmitScriptTarget(compilerOptions));
|
|
52409
52442
|
}
|
|
52410
52443
|
if (nameType.flags & 8192 /* UniqueESSymbol */) {
|
|
52411
52444
|
return ts.factory.createComputedPropertyName(symbolToExpression(nameType.symbol, context, 111551 /* Value */));
|
|
52412
52445
|
}
|
|
52413
52446
|
}
|
|
52414
52447
|
}
|
|
52415
|
-
function createPropertyNameNodeForIdentifierOrLiteral(name, stringNamed, singleQuote) {
|
|
52416
|
-
return ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) ? ts.factory.createIdentifier(name) :
|
|
52417
|
-
!stringNamed && isNumericLiteralName(name) && +name >= 0 ? ts.factory.createNumericLiteral(+name) :
|
|
52418
|
-
ts.factory.createStringLiteral(name, !!singleQuote);
|
|
52419
|
-
}
|
|
52420
52448
|
function cloneNodeBuilderContext(context) {
|
|
52421
52449
|
var initial = __assign({}, context);
|
|
52422
52450
|
// Make type parameters created within this context not consume the name outside this context
|
|
@@ -53932,10 +53960,10 @@ var ts;
|
|
|
53932
53960
|
if (nameType) {
|
|
53933
53961
|
if (nameType.flags & 384 /* StringOrNumberLiteral */) {
|
|
53934
53962
|
var name = "" + nameType.value;
|
|
53935
|
-
if (!ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) && !isNumericLiteralName(name)) {
|
|
53963
|
+
if (!ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) && !ts.isNumericLiteralName(name)) {
|
|
53936
53964
|
return "\"" + ts.escapeString(name, 34 /* doubleQuote */) + "\"";
|
|
53937
53965
|
}
|
|
53938
|
-
if (isNumericLiteralName(name) && ts.startsWith(name, "-")) {
|
|
53966
|
+
if (ts.isNumericLiteralName(name) && ts.startsWith(name, "-")) {
|
|
53939
53967
|
return "[" + name + "]";
|
|
53940
53968
|
}
|
|
53941
53969
|
return name;
|
|
@@ -57978,7 +58006,7 @@ var ts;
|
|
|
57978
58006
|
// signature applies to types assignable to 'number' and numeric string literal types.
|
|
57979
58007
|
return isTypeAssignableTo(source, target) ||
|
|
57980
58008
|
target === stringType && isTypeAssignableTo(source, numberType) ||
|
|
57981
|
-
target === numberType && !!(source.flags & 128 /* StringLiteral */) && isNumericLiteralName(source.value);
|
|
58009
|
+
target === numberType && !!(source.flags & 128 /* StringLiteral */) && ts.isNumericLiteralName(source.value);
|
|
57982
58010
|
}
|
|
57983
58011
|
function getIndexInfosOfStructuredType(type) {
|
|
57984
58012
|
if (type.flags & 3670016 /* StructuredType */) {
|
|
@@ -60544,7 +60572,7 @@ var ts;
|
|
|
60544
60572
|
getFlowTypeOfReference(accessExpression, propType) :
|
|
60545
60573
|
propType;
|
|
60546
60574
|
}
|
|
60547
|
-
if (everyType(objectType, isTupleType) && isNumericLiteralName(propName) && +propName >= 0) {
|
|
60575
|
+
if (everyType(objectType, isTupleType) && ts.isNumericLiteralName(propName) && +propName >= 0) {
|
|
60548
60576
|
if (accessNode && everyType(objectType, function (t) { return !t.target.hasRestElement; }) && !(accessFlags & 16 /* NoTupleBoundsCheck */)) {
|
|
60549
60577
|
var indexNode = getIndexNodeForAccessExpression(accessNode);
|
|
60550
60578
|
if (isTupleType(objectType)) {
|
|
@@ -60829,7 +60857,7 @@ var ts;
|
|
|
60829
60857
|
return everyType(indexType, function (t) {
|
|
60830
60858
|
if (t.flags & 384 /* StringOrNumberLiteral */) {
|
|
60831
60859
|
var propName = getPropertyNameFromType(t);
|
|
60832
|
-
if (isNumericLiteralName(propName)) {
|
|
60860
|
+
if (ts.isNumericLiteralName(propName)) {
|
|
60833
60861
|
var index = +propName;
|
|
60834
60862
|
return index >= 0 && index < limit;
|
|
60835
60863
|
}
|
|
@@ -64371,7 +64399,7 @@ var ts;
|
|
|
64371
64399
|
else {
|
|
64372
64400
|
// conditionals aren't related to one another via distributive constraint as it is much too inaccurate and allows way
|
|
64373
64401
|
// more assignments than are desirable (since it maps the source check type to its constraint, it loses information)
|
|
64374
|
-
var distributiveConstraint = getConstraintOfDistributiveConditionalType(source);
|
|
64402
|
+
var distributiveConstraint = hasNonCircularBaseConstraint(source) ? getConstraintOfDistributiveConditionalType(source) : undefined;
|
|
64375
64403
|
if (distributiveConstraint) {
|
|
64376
64404
|
if (result = isRelatedTo(distributiveConstraint, target, 1 /* Source */, reportErrors)) {
|
|
64377
64405
|
resetErrorInfo(saveErrorInfo);
|
|
@@ -64917,7 +64945,7 @@ var ts;
|
|
|
64917
64945
|
for (var _b = 0, _c = excludeProperties(properties, excludedProperties); _b < _c.length; _b++) {
|
|
64918
64946
|
var targetProp = _c[_b];
|
|
64919
64947
|
var name = targetProp.escapedName;
|
|
64920
|
-
if (!(targetProp.flags & 4194304 /* Prototype */) && (!numericNamesOnly || isNumericLiteralName(name) || name === "length")) {
|
|
64948
|
+
if (!(targetProp.flags & 4194304 /* Prototype */) && (!numericNamesOnly || ts.isNumericLiteralName(name) || name === "length")) {
|
|
64921
64949
|
var sourceProp = getPropertyOfType(source, name);
|
|
64922
64950
|
if (sourceProp && sourceProp !== targetProp) {
|
|
64923
64951
|
var related = propertyRelatedTo(source, target, sourceProp, targetProp, getNonMissingTypeOfSymbol, reportErrors, intersectionState, relation === comparableRelation);
|
|
@@ -64990,7 +65018,8 @@ var ts;
|
|
|
64990
65018
|
var incompatibleReporter = kind === 1 /* Construct */ ? reportIncompatibleConstructSignatureReturn : reportIncompatibleCallSignatureReturn;
|
|
64991
65019
|
var sourceObjectFlags = ts.getObjectFlags(source);
|
|
64992
65020
|
var targetObjectFlags = ts.getObjectFlags(target);
|
|
64993
|
-
if (sourceObjectFlags & 64 /* Instantiated */ && targetObjectFlags & 64 /* Instantiated */ && source.symbol === target.symbol
|
|
65021
|
+
if (sourceObjectFlags & 64 /* Instantiated */ && targetObjectFlags & 64 /* Instantiated */ && source.symbol === target.symbol ||
|
|
65022
|
+
sourceObjectFlags & 4 /* Reference */ && targetObjectFlags & 4 /* Reference */ && source.target === target.target) {
|
|
64994
65023
|
// We have instantiations of the same anonymous type (which typically will be the type of a
|
|
64995
65024
|
// method). Simply do a pairwise comparison of the signatures in the two signature lists instead
|
|
64996
65025
|
// of the much more expensive N * M comparison matrix we explore below. We erase type parameters
|
|
@@ -66025,9 +66054,12 @@ var ts;
|
|
|
66025
66054
|
* with no call or construct signatures.
|
|
66026
66055
|
*/
|
|
66027
66056
|
function isObjectTypeWithInferableIndex(type) {
|
|
66028
|
-
return type.flags & 2097152 /* Intersection */
|
|
66029
|
-
|
|
66030
|
-
|
|
66057
|
+
return type.flags & 2097152 /* Intersection */
|
|
66058
|
+
? ts.every(type.types, isObjectTypeWithInferableIndex)
|
|
66059
|
+
: !!(type.symbol
|
|
66060
|
+
&& (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */ | 384 /* Enum */ | 512 /* ValueModule */)) !== 0
|
|
66061
|
+
&& !(type.symbol.flags & 32 /* Class */)
|
|
66062
|
+
&& !typeHasCallOrConstructSignatures(type)) || !!(ts.getObjectFlags(type) & 1024 /* ReverseMapped */ && isObjectTypeWithInferableIndex(type.source));
|
|
66031
66063
|
}
|
|
66032
66064
|
function createSymbolWithType(source, type) {
|
|
66033
66065
|
var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8 /* Readonly */);
|
|
@@ -70997,7 +71029,7 @@ var ts;
|
|
|
70997
71029
|
}
|
|
70998
71030
|
if (isTupleType(t)) {
|
|
70999
71031
|
var restType = getRestTypeOfTupleType(t);
|
|
71000
|
-
if (restType && isNumericLiteralName(name) && +name >= 0) {
|
|
71032
|
+
if (restType && ts.isNumericLiteralName(name) && +name >= 0) {
|
|
71001
71033
|
return restType;
|
|
71002
71034
|
}
|
|
71003
71035
|
}
|
|
@@ -71638,10 +71670,10 @@ var ts;
|
|
|
71638
71670
|
case 161 /* ComputedPropertyName */:
|
|
71639
71671
|
return isNumericComputedName(name);
|
|
71640
71672
|
case 79 /* Identifier */:
|
|
71641
|
-
return isNumericLiteralName(name.escapedText);
|
|
71673
|
+
return ts.isNumericLiteralName(name.escapedText);
|
|
71642
71674
|
case 8 /* NumericLiteral */:
|
|
71643
71675
|
case 10 /* StringLiteral */:
|
|
71644
|
-
return isNumericLiteralName(name.text);
|
|
71676
|
+
return ts.isNumericLiteralName(name.text);
|
|
71645
71677
|
default:
|
|
71646
71678
|
return false;
|
|
71647
71679
|
}
|
|
@@ -71651,30 +71683,6 @@ var ts;
|
|
|
71651
71683
|
// but this behavior is consistent with checkIndexedAccess
|
|
71652
71684
|
return isTypeAssignableToKind(checkComputedPropertyName(name), 296 /* NumberLike */);
|
|
71653
71685
|
}
|
|
71654
|
-
function isNumericLiteralName(name) {
|
|
71655
|
-
// The intent of numeric names is that
|
|
71656
|
-
// - they are names with text in a numeric form, and that
|
|
71657
|
-
// - setting properties/indexing with them is always equivalent to doing so with the numeric literal 'numLit',
|
|
71658
|
-
// acquired by applying the abstract 'ToNumber' operation on the name's text.
|
|
71659
|
-
//
|
|
71660
|
-
// The subtlety is in the latter portion, as we cannot reliably say that anything that looks like a numeric literal is a numeric name.
|
|
71661
|
-
// In fact, it is the case that the text of the name must be equal to 'ToString(numLit)' for this to hold.
|
|
71662
|
-
//
|
|
71663
|
-
// Consider the property name '"0xF00D"'. When one indexes with '0xF00D', they are actually indexing with the value of 'ToString(0xF00D)'
|
|
71664
|
-
// according to the ECMAScript specification, so it is actually as if the user indexed with the string '"61453"'.
|
|
71665
|
-
// Thus, the text of all numeric literals equivalent to '61543' such as '0xF00D', '0xf00D', '0170015', etc. are not valid numeric names
|
|
71666
|
-
// because their 'ToString' representation is not equal to their original text.
|
|
71667
|
-
// This is motivated by ECMA-262 sections 9.3.1, 9.8.1, 11.1.5, and 11.2.1.
|
|
71668
|
-
//
|
|
71669
|
-
// Here, we test whether 'ToString(ToNumber(name))' is exactly equal to 'name'.
|
|
71670
|
-
// The '+' prefix operator is equivalent here to applying the abstract ToNumber operation.
|
|
71671
|
-
// Applying the 'toString()' method on a number gives us the abstract ToString operation on a number.
|
|
71672
|
-
//
|
|
71673
|
-
// Note that this accepts the values 'Infinity', '-Infinity', and 'NaN', and that this is intentional.
|
|
71674
|
-
// This is desired behavior, because when indexing with them as numeric entities, you are indexing
|
|
71675
|
-
// with the strings '"Infinity"', '"-Infinity"', and '"NaN"' respectively.
|
|
71676
|
-
return (+name).toString() === name;
|
|
71677
|
-
}
|
|
71678
71686
|
function checkComputedPropertyName(node) {
|
|
71679
71687
|
var links = getNodeLinks(node.expression);
|
|
71680
71688
|
if (!links.resolvedType) {
|
|
@@ -71710,7 +71718,7 @@ var ts;
|
|
|
71710
71718
|
function isSymbolWithNumericName(symbol) {
|
|
71711
71719
|
var _a;
|
|
71712
71720
|
var firstDecl = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a[0];
|
|
71713
|
-
return isNumericLiteralName(symbol.escapedName) || (firstDecl && ts.isNamedDeclaration(firstDecl) && isNumericName(firstDecl.name));
|
|
71721
|
+
return ts.isNumericLiteralName(symbol.escapedName) || (firstDecl && ts.isNamedDeclaration(firstDecl) && isNumericName(firstDecl.name));
|
|
71714
71722
|
}
|
|
71715
71723
|
function isSymbolWithSymbolName(symbol) {
|
|
71716
71724
|
var _a;
|
|
@@ -82648,7 +82656,7 @@ var ts;
|
|
|
82648
82656
|
}
|
|
82649
82657
|
else {
|
|
82650
82658
|
var text = ts.getTextOfPropertyName(member.name);
|
|
82651
|
-
if (isNumericLiteralName(text) && !ts.isInfinityOrNaNString(text)) {
|
|
82659
|
+
if (ts.isNumericLiteralName(text) && !ts.isInfinityOrNaNString(text)) {
|
|
82652
82660
|
error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name);
|
|
82653
82661
|
}
|
|
82654
82662
|
}
|
|
@@ -120113,7 +120121,7 @@ var ts;
|
|
|
120113
120121
|
}
|
|
120114
120122
|
ts.getLocaleTimeString = getLocaleTimeString;
|
|
120115
120123
|
/**
|
|
120116
|
-
* Create a function that reports watch status by writing to the system and handles the
|
|
120124
|
+
* Create a function that reports watch status by writing to the system and handles the formatting of the diagnostic
|
|
120117
120125
|
*/
|
|
120118
120126
|
function createWatchStatusReporter(system, pretty) {
|
|
120119
120127
|
return pretty ?
|
|
@@ -120174,7 +120182,7 @@ var ts;
|
|
|
120174
120182
|
ts.Diagnostics.Found_0_errors_Watching_for_file_changes;
|
|
120175
120183
|
}
|
|
120176
120184
|
ts.getWatchErrorSummaryDiagnosticMessage = getWatchErrorSummaryDiagnosticMessage;
|
|
120177
|
-
function getErrorSummaryText(errorCount, filesInError, newLine) {
|
|
120185
|
+
function getErrorSummaryText(errorCount, filesInError, newLine, host) {
|
|
120178
120186
|
if (errorCount === 0)
|
|
120179
120187
|
return "";
|
|
120180
120188
|
var nonNilFiles = filesInError.filter(function (fileInError) { return fileInError !== undefined; });
|
|
@@ -120189,10 +120197,10 @@ var ts;
|
|
|
120189
120197
|
distinctFileNamesWithLines.length === 1 ?
|
|
120190
120198
|
ts.Diagnostics.Found_0_errors_in_1_file :
|
|
120191
120199
|
ts.Diagnostics.Found_0_errors_in_1_files, errorCount, distinctFileNamesWithLines.length);
|
|
120192
|
-
return "" + newLine + ts.flattenDiagnosticMessageText(d.messageText, newLine) + newLine + newLine + (errorCount > 1 ? createTabularErrorsDisplay(nonNilFiles) : "");
|
|
120200
|
+
return "" + newLine + ts.flattenDiagnosticMessageText(d.messageText, newLine) + newLine + newLine + (errorCount > 1 ? createTabularErrorsDisplay(nonNilFiles, host) : "");
|
|
120193
120201
|
}
|
|
120194
120202
|
ts.getErrorSummaryText = getErrorSummaryText;
|
|
120195
|
-
function createTabularErrorsDisplay(filesInError) {
|
|
120203
|
+
function createTabularErrorsDisplay(filesInError, host) {
|
|
120196
120204
|
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); }); });
|
|
120197
120205
|
if (distinctFiles.length === 0)
|
|
120198
120206
|
return "";
|
|
@@ -120211,7 +120219,8 @@ var ts;
|
|
|
120211
120219
|
var leftPadding = errorCountDigitsLength < leftPaddingGoal ?
|
|
120212
120220
|
" ".repeat(leftPaddingGoal - errorCountDigitsLength)
|
|
120213
120221
|
: "";
|
|
120214
|
-
|
|
120222
|
+
var relativePath = ts.getRelativePathFromDirectory(host.getCurrentDirectory(), file.fileName, /* ignoreCase */ false);
|
|
120223
|
+
tabularData += "" + leftPadding + errorCount + " " + relativePath + ":" + file.line + "\n";
|
|
120215
120224
|
});
|
|
120216
120225
|
return tabularData;
|
|
120217
120226
|
}
|
|
@@ -120629,7 +120638,7 @@ var ts;
|
|
|
120629
120638
|
var system = input.system || ts.sys;
|
|
120630
120639
|
var host = input.host || (input.host = ts.createIncrementalCompilerHost(input.options, system));
|
|
120631
120640
|
var builderProgram = ts.createIncrementalProgram(input);
|
|
120632
|
-
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);
|
|
120641
|
+
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);
|
|
120633
120642
|
if (input.afterProgramEmitAndDiagnostics)
|
|
120634
120643
|
input.afterProgramEmitAndDiagnostics(builderProgram);
|
|
120635
120644
|
return exitStatus;
|
|
@@ -123103,14 +123112,8 @@ var ts;
|
|
|
123103
123112
|
var possibleSearchDirs = new ts.Set(fileNames.map(ts.getDirectoryPath));
|
|
123104
123113
|
possibleSearchDirs.add(projectRootPath);
|
|
123105
123114
|
possibleSearchDirs.forEach(function (searchDir) {
|
|
123106
|
-
|
|
123107
|
-
|
|
123108
|
-
var bowerJsonPath = ts.combinePaths(searchDir, "bower.json");
|
|
123109
|
-
getTypingNamesFromJson(bowerJsonPath, filesToWatch);
|
|
123110
|
-
var bowerComponentsPath = ts.combinePaths(searchDir, "bower_components");
|
|
123111
|
-
getTypingNamesFromPackagesFolder(bowerComponentsPath, filesToWatch);
|
|
123112
|
-
var nodeModulesPath = ts.combinePaths(searchDir, "node_modules");
|
|
123113
|
-
getTypingNamesFromPackagesFolder(nodeModulesPath, filesToWatch);
|
|
123115
|
+
getTypingNames(searchDir, "bower.json", "bower_components", filesToWatch);
|
|
123116
|
+
getTypingNames(searchDir, "package.json", "node_modules", filesToWatch);
|
|
123114
123117
|
});
|
|
123115
123118
|
if (!typeAcquisition.disableFilenameBasedTypeAcquisition) {
|
|
123116
123119
|
getTypingNamesFromSourceFileNames(fileNames);
|
|
@@ -123159,16 +123162,100 @@ var ts;
|
|
|
123159
123162
|
ts.forEach(typingNames, addInferredTyping);
|
|
123160
123163
|
}
|
|
123161
123164
|
/**
|
|
123162
|
-
*
|
|
123165
|
+
* Adds inferred typings from manifest/module pairs (think package.json + node_modules)
|
|
123166
|
+
*
|
|
123167
|
+
* @param projectRootPath is the path to the directory where to look for package.json, bower.json and other typing information
|
|
123168
|
+
* @param manifestName is the name of the manifest (package.json or bower.json)
|
|
123169
|
+
* @param modulesDirName is the directory name for modules (node_modules or bower_components). Should be lowercase!
|
|
123170
|
+
* @param filesToWatch are the files to watch for changes. We will push things into this array.
|
|
123163
123171
|
*/
|
|
123164
|
-
function
|
|
123165
|
-
|
|
123172
|
+
function getTypingNames(projectRootPath, manifestName, modulesDirName, filesToWatch) {
|
|
123173
|
+
// First, we check the manifests themselves. They're not
|
|
123174
|
+
// _required_, but they allow us to do some filtering when dealing
|
|
123175
|
+
// with big flat dep directories.
|
|
123176
|
+
var manifestPath = ts.combinePaths(projectRootPath, manifestName);
|
|
123177
|
+
var manifest;
|
|
123178
|
+
var manifestTypingNames;
|
|
123179
|
+
if (host.fileExists(manifestPath)) {
|
|
123180
|
+
filesToWatch.push(manifestPath);
|
|
123181
|
+
manifest = ts.readConfigFile(manifestPath, function (path) { return host.readFile(path); }).config;
|
|
123182
|
+
manifestTypingNames = ts.flatMap([manifest.dependencies, manifest.devDependencies, manifest.optionalDependencies, manifest.peerDependencies], ts.getOwnKeys);
|
|
123183
|
+
addInferredTypings(manifestTypingNames, "Typing names in '" + manifestPath + "' dependencies");
|
|
123184
|
+
}
|
|
123185
|
+
// Now we scan the directories for typing information in
|
|
123186
|
+
// already-installed dependencies (if present). Note that this
|
|
123187
|
+
// step happens regardless of whether a manifest was present,
|
|
123188
|
+
// which is certainly a valid configuration, if an unusual one.
|
|
123189
|
+
var packagesFolderPath = ts.combinePaths(projectRootPath, modulesDirName);
|
|
123190
|
+
filesToWatch.push(packagesFolderPath);
|
|
123191
|
+
if (!host.directoryExists(packagesFolderPath)) {
|
|
123166
123192
|
return;
|
|
123167
123193
|
}
|
|
123168
|
-
|
|
123169
|
-
|
|
123170
|
-
|
|
123171
|
-
|
|
123194
|
+
// There's two cases we have to take into account here:
|
|
123195
|
+
// 1. If manifest is undefined, then we're not using a manifest.
|
|
123196
|
+
// That means that we should scan _all_ dependencies at the top
|
|
123197
|
+
// level of the modulesDir.
|
|
123198
|
+
// 2. If manifest is defined, then we can do some special
|
|
123199
|
+
// filtering to reduce the amount of scanning we need to do.
|
|
123200
|
+
//
|
|
123201
|
+
// Previous versions of this algorithm checked for a `_requiredBy`
|
|
123202
|
+
// field in the package.json, but that field is only present in
|
|
123203
|
+
// `npm@>=3 <7`.
|
|
123204
|
+
// Package names that do **not** provide their own typings, so
|
|
123205
|
+
// we'll look them up.
|
|
123206
|
+
var packageNames = [];
|
|
123207
|
+
var dependencyManifestNames = manifestTypingNames
|
|
123208
|
+
// This is #1 described above.
|
|
123209
|
+
? manifestTypingNames.map(function (typingName) { return ts.combinePaths(packagesFolderPath, typingName, manifestName); })
|
|
123210
|
+
// And #2. Depth = 3 because scoped packages look like `node_modules/@foo/bar/package.json`
|
|
123211
|
+
: host.readDirectory(packagesFolderPath, [".json" /* Json */], /*excludes*/ undefined, /*includes*/ undefined, /*depth*/ 3)
|
|
123212
|
+
.filter(function (manifestPath) {
|
|
123213
|
+
if (ts.getBaseFileName(manifestPath) !== manifestName) {
|
|
123214
|
+
return false;
|
|
123215
|
+
}
|
|
123216
|
+
// It's ok to treat
|
|
123217
|
+
// `node_modules/@foo/bar/package.json` as a manifest,
|
|
123218
|
+
// but not `node_modules/jquery/nested/package.json`.
|
|
123219
|
+
// We only assume depth 3 is ok for formally scoped
|
|
123220
|
+
// packages. So that needs this dance here.
|
|
123221
|
+
var pathComponents = ts.getPathComponents(ts.normalizePath(manifestPath));
|
|
123222
|
+
var isScoped = pathComponents[pathComponents.length - 3][0] === "@";
|
|
123223
|
+
return isScoped && pathComponents[pathComponents.length - 4].toLowerCase() === modulesDirName || // `node_modules/@foo/bar`
|
|
123224
|
+
!isScoped && pathComponents[pathComponents.length - 3].toLowerCase() === modulesDirName; // `node_modules/foo`
|
|
123225
|
+
});
|
|
123226
|
+
if (log)
|
|
123227
|
+
log("Searching for typing names in " + packagesFolderPath + "; all files: " + JSON.stringify(dependencyManifestNames));
|
|
123228
|
+
// Once we have the names of things to look up, we iterate over
|
|
123229
|
+
// and either collect their included typings, or add them to the
|
|
123230
|
+
// list of typings we need to look up separately.
|
|
123231
|
+
for (var _i = 0, dependencyManifestNames_1 = dependencyManifestNames; _i < dependencyManifestNames_1.length; _i++) {
|
|
123232
|
+
var manifestPath_1 = dependencyManifestNames_1[_i];
|
|
123233
|
+
var normalizedFileName = ts.normalizePath(manifestPath_1);
|
|
123234
|
+
var result_1 = ts.readConfigFile(normalizedFileName, function (path) { return host.readFile(path); });
|
|
123235
|
+
var manifest_1 = result_1.config;
|
|
123236
|
+
// If the package has its own d.ts typings, those will take precedence. Otherwise the package name will be used
|
|
123237
|
+
// to download d.ts files from DefinitelyTyped
|
|
123238
|
+
if (!manifest_1.name) {
|
|
123239
|
+
continue;
|
|
123240
|
+
}
|
|
123241
|
+
var ownTypes = manifest_1.types || manifest_1.typings;
|
|
123242
|
+
if (ownTypes) {
|
|
123243
|
+
var absolutePath = ts.getNormalizedAbsolutePath(ownTypes, ts.getDirectoryPath(normalizedFileName));
|
|
123244
|
+
if (host.fileExists(absolutePath)) {
|
|
123245
|
+
if (log)
|
|
123246
|
+
log(" Package '" + manifest_1.name + "' provides its own types.");
|
|
123247
|
+
inferredTypings.set(manifest_1.name, absolutePath);
|
|
123248
|
+
}
|
|
123249
|
+
else {
|
|
123250
|
+
if (log)
|
|
123251
|
+
log(" Package '" + manifest_1.name + "' provides its own types but they are missing.");
|
|
123252
|
+
}
|
|
123253
|
+
}
|
|
123254
|
+
else {
|
|
123255
|
+
packageNames.push(manifest_1.name);
|
|
123256
|
+
}
|
|
123257
|
+
}
|
|
123258
|
+
addInferredTypings(packageNames, " Found package names");
|
|
123172
123259
|
}
|
|
123173
123260
|
/**
|
|
123174
123261
|
* Infer typing names from given file names. For example, the file name "jquery-min.2.3.4.js"
|
|
@@ -123194,55 +123281,6 @@ var ts;
|
|
|
123194
123281
|
addInferredTyping("react");
|
|
123195
123282
|
}
|
|
123196
123283
|
}
|
|
123197
|
-
/**
|
|
123198
|
-
* Infer typing names from packages folder (ex: node_module, bower_components)
|
|
123199
|
-
* @param packagesFolderPath is the path to the packages folder
|
|
123200
|
-
*/
|
|
123201
|
-
function getTypingNamesFromPackagesFolder(packagesFolderPath, filesToWatch) {
|
|
123202
|
-
filesToWatch.push(packagesFolderPath);
|
|
123203
|
-
// Todo: add support for ModuleResolutionHost too
|
|
123204
|
-
if (!host.directoryExists(packagesFolderPath)) {
|
|
123205
|
-
return;
|
|
123206
|
-
}
|
|
123207
|
-
// depth of 2, so we access `node_modules/foo` but not `node_modules/foo/bar`
|
|
123208
|
-
var fileNames = host.readDirectory(packagesFolderPath, [".json" /* Json */], /*excludes*/ undefined, /*includes*/ undefined, /*depth*/ 2);
|
|
123209
|
-
if (log)
|
|
123210
|
-
log("Searching for typing names in " + packagesFolderPath + "; all files: " + JSON.stringify(fileNames));
|
|
123211
|
-
var packageNames = [];
|
|
123212
|
-
for (var _i = 0, fileNames_1 = fileNames; _i < fileNames_1.length; _i++) {
|
|
123213
|
-
var fileName = fileNames_1[_i];
|
|
123214
|
-
var normalizedFileName = ts.normalizePath(fileName);
|
|
123215
|
-
var baseFileName = ts.getBaseFileName(normalizedFileName);
|
|
123216
|
-
if (baseFileName !== "package.json" && baseFileName !== "bower.json") {
|
|
123217
|
-
continue;
|
|
123218
|
-
}
|
|
123219
|
-
var result_1 = ts.readConfigFile(normalizedFileName, function (path) { return host.readFile(path); });
|
|
123220
|
-
var packageJson = result_1.config;
|
|
123221
|
-
// npm 3's package.json contains a "_requiredBy" field
|
|
123222
|
-
// we should include all the top level module names for npm 2, and only module names whose
|
|
123223
|
-
// "_requiredBy" field starts with "#" or equals "/" for npm 3.
|
|
123224
|
-
if (baseFileName === "package.json" && packageJson._requiredBy &&
|
|
123225
|
-
ts.filter(packageJson._requiredBy, function (r) { return r[0] === "#" || r === "/"; }).length === 0) {
|
|
123226
|
-
continue;
|
|
123227
|
-
}
|
|
123228
|
-
// If the package has its own d.ts typings, those will take precedence. Otherwise the package name will be used
|
|
123229
|
-
// to download d.ts files from DefinitelyTyped
|
|
123230
|
-
if (!packageJson.name) {
|
|
123231
|
-
continue;
|
|
123232
|
-
}
|
|
123233
|
-
var ownTypes = packageJson.types || packageJson.typings;
|
|
123234
|
-
if (ownTypes) {
|
|
123235
|
-
var absolutePath = ts.getNormalizedAbsolutePath(ownTypes, ts.getDirectoryPath(normalizedFileName));
|
|
123236
|
-
if (log)
|
|
123237
|
-
log(" Package '" + packageJson.name + "' provides its own types.");
|
|
123238
|
-
inferredTypings.set(packageJson.name, absolutePath);
|
|
123239
|
-
}
|
|
123240
|
-
else {
|
|
123241
|
-
packageNames.push(packageJson.name);
|
|
123242
|
-
}
|
|
123243
|
-
}
|
|
123244
|
-
addInferredTypings(packageNames, " Found package names");
|
|
123245
|
-
}
|
|
123246
123284
|
}
|
|
123247
123285
|
JsTyping.discoverTypings = discoverTypings;
|
|
123248
123286
|
var NameValidationResult;
|
|
@@ -151002,7 +151040,8 @@ var ts;
|
|
|
151002
151040
|
return { kind: 3 /* ObjectLiteral */, token: token, properties: properties, indentation: undefined, parentDeclaration: parent.initializer };
|
|
151003
151041
|
}
|
|
151004
151042
|
if (ts.isIdentifier(token) && ts.isJsxOpeningLikeElement(token.parent)) {
|
|
151005
|
-
var
|
|
151043
|
+
var target = ts.getEmitScriptTarget(program.getCompilerOptions());
|
|
151044
|
+
var attributes = getUnmatchedAttributes(checker, target, token.parent);
|
|
151006
151045
|
if (!ts.length(attributes))
|
|
151007
151046
|
return undefined;
|
|
151008
151047
|
return { kind: 4 /* JsxAttributes */, token: token, attributes: attributes, parentDeclaration: token.parent };
|
|
@@ -151237,8 +151276,12 @@ var ts;
|
|
|
151237
151276
|
var jsxAttributesNode = info.parentDeclaration.attributes;
|
|
151238
151277
|
var hasSpreadAttribute = ts.some(jsxAttributesNode.properties, ts.isJsxSpreadAttribute);
|
|
151239
151278
|
var attrs = ts.map(info.attributes, function (attr) {
|
|
151240
|
-
var value =
|
|
151241
|
-
|
|
151279
|
+
var value = tryGetValueFromType(context, checker, importAdder, quotePreference, checker.getTypeOfSymbol(attr));
|
|
151280
|
+
var name = ts.factory.createIdentifier(attr.name);
|
|
151281
|
+
var jsxAttribute = ts.factory.createJsxAttribute(name, ts.factory.createJsxExpression(/*dotDotDotToken*/ undefined, value));
|
|
151282
|
+
// formattingScanner requires the Identifier to have a context for scanning attributes with "-" (data-foo).
|
|
151283
|
+
ts.setParent(name, jsxAttribute);
|
|
151284
|
+
return jsxAttribute;
|
|
151242
151285
|
});
|
|
151243
151286
|
var jsxAttributes = ts.factory.createJsxAttributes(hasSpreadAttribute ? __spreadArray(__spreadArray([], attrs, true), jsxAttributesNode.properties, true) : __spreadArray(__spreadArray([], jsxAttributesNode.properties, true), attrs, true));
|
|
151244
151287
|
var options = { prefix: jsxAttributesNode.pos === jsxAttributesNode.end ? " " : undefined };
|
|
@@ -151247,10 +151290,11 @@ var ts;
|
|
|
151247
151290
|
function addObjectLiteralProperties(changes, context, info) {
|
|
151248
151291
|
var importAdder = codefix.createImportAdder(context.sourceFile, context.program, context.preferences, context.host);
|
|
151249
151292
|
var quotePreference = ts.getQuotePreference(context.sourceFile, context.preferences);
|
|
151293
|
+
var target = ts.getEmitScriptTarget(context.program.getCompilerOptions());
|
|
151250
151294
|
var checker = context.program.getTypeChecker();
|
|
151251
151295
|
var props = ts.map(info.properties, function (prop) {
|
|
151252
|
-
var initializer =
|
|
151253
|
-
return ts.factory.createPropertyAssignment(prop.name, initializer);
|
|
151296
|
+
var initializer = tryGetValueFromType(context, checker, importAdder, quotePreference, checker.getTypeOfSymbol(prop));
|
|
151297
|
+
return ts.factory.createPropertyAssignment(ts.createPropertyNameNodeForIdentifierOrLiteral(prop.name, target, quotePreference === 0 /* Single */), initializer);
|
|
151254
151298
|
});
|
|
151255
151299
|
var options = {
|
|
151256
151300
|
leadingTriviaOption: ts.textChanges.LeadingTriviaOption.Exclude,
|
|
@@ -151337,7 +151381,7 @@ var ts;
|
|
|
151337
151381
|
return (type.flags & 524288 /* Object */) &&
|
|
151338
151382
|
((ts.getObjectFlags(type) & 128 /* ObjectLiteral */) || (type.symbol && ts.tryCast(ts.singleOrUndefined(type.symbol.declarations), ts.isTypeLiteralNode)));
|
|
151339
151383
|
}
|
|
151340
|
-
function getUnmatchedAttributes(checker, source) {
|
|
151384
|
+
function getUnmatchedAttributes(checker, target, source) {
|
|
151341
151385
|
var attrsType = checker.getContextualType(source.attributes);
|
|
151342
151386
|
if (attrsType === undefined)
|
|
151343
151387
|
return ts.emptyArray;
|
|
@@ -151359,7 +151403,7 @@ var ts;
|
|
|
151359
151403
|
}
|
|
151360
151404
|
}
|
|
151361
151405
|
return ts.filter(targetProps, function (targetProp) {
|
|
151362
|
-
return !((targetProp.flags & 16777216 /* Optional */ || ts.getCheckFlags(targetProp) & 48 /* Partial */) || seenNames.has(targetProp.escapedName));
|
|
151406
|
+
return ts.isIdentifierText(targetProp.name, target, 1 /* JSX */) && !((targetProp.flags & 16777216 /* Optional */ || ts.getCheckFlags(targetProp) & 48 /* Partial */) || seenNames.has(targetProp.escapedName));
|
|
151363
151407
|
});
|
|
151364
151408
|
}
|
|
151365
151409
|
})(codefix = ts.codefix || (ts.codefix = {}));
|