Skip to content

Commit d6dac6a

Browse files
author
Kanchalai Tanglertsampan
committed
Update LKG 08/25
1 parent 3ed8bca commit d6dac6a

File tree

6 files changed

+121
-33
lines changed

6 files changed

+121
-33
lines changed

lib/tsc.js

+19-3
Original file line numberDiff line numberDiff line change
@@ -2243,6 +2243,7 @@ var ts;
22432243
Cannot_extend_an_interface_0_Did_you_mean_implements: { code: 2689, category: ts.DiagnosticCategory.Error, key: "Cannot_extend_an_interface_0_Did_you_mean_implements_2689", message: "Cannot extend an interface '{0}'. Did you mean 'implements'?" },
22442244
A_class_must_be_declared_after_its_base_class: { code: 2690, category: ts.DiagnosticCategory.Error, key: "A_class_must_be_declared_after_its_base_class_2690", message: "A class must be declared after its base class." },
22452245
An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead: { code: 2691, category: ts.DiagnosticCategory.Error, key: "An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead_2691", message: "An import path cannot end with a '{0}' extension. Consider importing '{1}' instead." },
2246+
_0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible: { code: 2692, category: ts.DiagnosticCategory.Error, key: "_0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible_2692", message: "'{0}' is a primitive, but '{1}' is a wrapper object. Prefer using '{0}' when possible." },
22462247
Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import_declaration_0_is_using_private_name_1_4000", message: "Import declaration '{0}' is using private name '{1}'." },
22472248
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", message: "Type parameter '{0}' of exported class has or is using private name '{1}'." },
22482249
Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", message: "Type parameter '{0}' of exported interface has or is using private name '{1}'." },
@@ -13931,7 +13932,7 @@ var ts;
1393113932
}
1393213933
}
1393313934
function getDeclarationOfAliasSymbol(symbol) {
13934-
return ts.findMap(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; });
13935+
return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; });
1393513936
}
1393613937
function getTargetOfImportEqualsDeclaration(node) {
1393713938
if (node.moduleReference.kind === 240) {
@@ -14063,6 +14064,7 @@ var ts;
1406314064
if (!links.target) {
1406414065
links.target = resolvingSymbol;
1406514066
var node = getDeclarationOfAliasSymbol(symbol);
14067+
ts.Debug.assert(!!node);
1406614068
var target = getTargetOfAliasDeclaration(node);
1406714069
if (links.target === resolvingSymbol) {
1406814070
links.target = target || unknownSymbol;
@@ -14092,6 +14094,7 @@ var ts;
1409214094
if (!links.referenced) {
1409314095
links.referenced = true;
1409414096
var node = getDeclarationOfAliasSymbol(symbol);
14097+
ts.Debug.assert(!!node);
1409514098
if (node.kind === 235) {
1409614099
checkExpressionCached(node.expression);
1409714100
}
@@ -18221,6 +18224,16 @@ var ts;
1822118224
}
1822218225
reportError(message, sourceType, targetType);
1822318226
}
18227+
function tryElaborateErrorsForPrimitivesAndObjects(source, target) {
18228+
var sourceType = typeToString(source);
18229+
var targetType = typeToString(target);
18230+
if ((globalStringType === source && stringType === target) ||
18231+
(globalNumberType === source && numberType === target) ||
18232+
(globalBooleanType === source && booleanType === target) ||
18233+
(getGlobalESSymbolType() === source && esSymbolType === target)) {
18234+
reportError(ts.Diagnostics._0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible, targetType, sourceType);
18235+
}
18236+
}
1822418237
function isRelatedTo(source, target, reportErrors, headMessage) {
1822518238
var result;
1822618239
if (source === target)
@@ -18299,6 +18312,9 @@ var ts;
1829918312
}
1830018313
}
1830118314
if (reportErrors) {
18315+
if (source.flags & 2588672 && target.flags & 8190) {
18316+
tryElaborateErrorsForPrimitivesAndObjects(source, target);
18317+
}
1830218318
reportRelationError(headMessage, source, target);
1830318319
}
1830418320
return 0;
@@ -37334,7 +37350,7 @@ var ts;
3733437350
var classifiableNames;
3733537351
var resolvedTypeReferenceDirectives = ts.createMap();
3733637352
var fileProcessingDiagnostics = ts.createDiagnosticCollection();
37337-
var maxNodeModulesJsDepth = typeof options.maxNodeModuleJsDepth === "number" ? options.maxNodeModuleJsDepth : 2;
37353+
var maxNodeModulesJsDepth = typeof options.maxNodeModuleJsDepth === "number" ? options.maxNodeModuleJsDepth : 0;
3733837354
var currentNodeModulesDepth = 0;
3733937355
var modulesWithElidedImports = ts.createMap();
3734037356
var sourceFilesFoundSearchingNodeModules = ts.createMap();
@@ -39091,7 +39107,7 @@ var ts;
3909139107
}
3909239108
ts.convertTypingOptionsFromJson = convertTypingOptionsFromJson;
3909339109
function convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName) {
39094-
var options = ts.getBaseFileName(configFileName) === "jsconfig.json" ? { allowJs: true } : {};
39110+
var options = ts.getBaseFileName(configFileName) === "jsconfig.json" ? { allowJs: true, maxNodeModuleJsDepth: 2 } : {};
3909539111
convertOptionsFromJson(ts.optionDeclarations, jsonOptions, basePath, options, ts.Diagnostics.Unknown_compiler_option_0, errors);
3909639112
return options;
3909739113
}

lib/tsserver.js

+24-6
Original file line numberDiff line numberDiff line change
@@ -2248,6 +2248,7 @@ var ts;
22482248
Cannot_extend_an_interface_0_Did_you_mean_implements: { code: 2689, category: ts.DiagnosticCategory.Error, key: "Cannot_extend_an_interface_0_Did_you_mean_implements_2689", message: "Cannot extend an interface '{0}'. Did you mean 'implements'?" },
22492249
A_class_must_be_declared_after_its_base_class: { code: 2690, category: ts.DiagnosticCategory.Error, key: "A_class_must_be_declared_after_its_base_class_2690", message: "A class must be declared after its base class." },
22502250
An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead: { code: 2691, category: ts.DiagnosticCategory.Error, key: "An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead_2691", message: "An import path cannot end with a '{0}' extension. Consider importing '{1}' instead." },
2251+
_0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible: { code: 2692, category: ts.DiagnosticCategory.Error, key: "_0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible_2692", message: "'{0}' is a primitive, but '{1}' is a wrapper object. Prefer using '{0}' when possible." },
22512252
Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import_declaration_0_is_using_private_name_1_4000", message: "Import declaration '{0}' is using private name '{1}'." },
22522253
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", message: "Type parameter '{0}' of exported class has or is using private name '{1}'." },
22532254
Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", message: "Type parameter '{0}' of exported interface has or is using private name '{1}'." },
@@ -4803,7 +4804,7 @@ var ts;
48034804
}
48044805
ts.convertTypingOptionsFromJson = convertTypingOptionsFromJson;
48054806
function convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName) {
4806-
var options = ts.getBaseFileName(configFileName) === "jsconfig.json" ? { allowJs: true } : {};
4807+
var options = ts.getBaseFileName(configFileName) === "jsconfig.json" ? { allowJs: true, maxNodeModuleJsDepth: 2 } : {};
48074808
convertOptionsFromJson(ts.optionDeclarations, jsonOptions, basePath, options, ts.Diagnostics.Unknown_compiler_option_0, errors);
48084809
return options;
48094810
}
@@ -14927,7 +14928,7 @@ var ts;
1492714928
}
1492814929
}
1492914930
function getDeclarationOfAliasSymbol(symbol) {
14930-
return ts.findMap(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; });
14931+
return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; });
1493114932
}
1493214933
function getTargetOfImportEqualsDeclaration(node) {
1493314934
if (node.moduleReference.kind === 240) {
@@ -15059,6 +15060,7 @@ var ts;
1505915060
if (!links.target) {
1506015061
links.target = resolvingSymbol;
1506115062
var node = getDeclarationOfAliasSymbol(symbol);
15063+
ts.Debug.assert(!!node);
1506215064
var target = getTargetOfAliasDeclaration(node);
1506315065
if (links.target === resolvingSymbol) {
1506415066
links.target = target || unknownSymbol;
@@ -15088,6 +15090,7 @@ var ts;
1508815090
if (!links.referenced) {
1508915091
links.referenced = true;
1509015092
var node = getDeclarationOfAliasSymbol(symbol);
15093+
ts.Debug.assert(!!node);
1509115094
if (node.kind === 235) {
1509215095
checkExpressionCached(node.expression);
1509315096
}
@@ -19217,6 +19220,16 @@ var ts;
1921719220
}
1921819221
reportError(message, sourceType, targetType);
1921919222
}
19223+
function tryElaborateErrorsForPrimitivesAndObjects(source, target) {
19224+
var sourceType = typeToString(source);
19225+
var targetType = typeToString(target);
19226+
if ((globalStringType === source && stringType === target) ||
19227+
(globalNumberType === source && numberType === target) ||
19228+
(globalBooleanType === source && booleanType === target) ||
19229+
(getGlobalESSymbolType() === source && esSymbolType === target)) {
19230+
reportError(ts.Diagnostics._0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible, targetType, sourceType);
19231+
}
19232+
}
1922019233
function isRelatedTo(source, target, reportErrors, headMessage) {
1922119234
var result;
1922219235
if (source === target)
@@ -19295,6 +19308,9 @@ var ts;
1929519308
}
1929619309
}
1929719310
if (reportErrors) {
19311+
if (source.flags & 2588672 && target.flags & 8190) {
19312+
tryElaborateErrorsForPrimitivesAndObjects(source, target);
19313+
}
1929819314
reportRelationError(headMessage, source, target);
1929919315
}
1930019316
return 0;
@@ -38330,7 +38346,7 @@ var ts;
3833038346
var classifiableNames;
3833138347
var resolvedTypeReferenceDirectives = ts.createMap();
3833238348
var fileProcessingDiagnostics = ts.createDiagnosticCollection();
38333-
var maxNodeModulesJsDepth = typeof options.maxNodeModuleJsDepth === "number" ? options.maxNodeModuleJsDepth : 2;
38349+
var maxNodeModulesJsDepth = typeof options.maxNodeModuleJsDepth === "number" ? options.maxNodeModuleJsDepth : 0;
3833438350
var currentNodeModulesDepth = 0;
3833538351
var modulesWithElidedImports = ts.createMap();
3833638352
var sourceFilesFoundSearchingNodeModules = ts.createMap();
@@ -44734,11 +44750,14 @@ var ts;
4473444750
var pos_3 = this.pos;
4473544751
var useJSDocScanner_1 = this.kind >= 273 && this.kind <= 285;
4473644752
var processNode = function (node) {
44737-
if (pos_3 < node.pos) {
44753+
var isJSDocTagNode = ts.isJSDocTag(node);
44754+
if (!isJSDocTagNode && pos_3 < node.pos) {
4473844755
pos_3 = _this.addSyntheticNodes(children, pos_3, node.pos, useJSDocScanner_1);
4473944756
}
4474044757
children.push(node);
44741-
pos_3 = node.end;
44758+
if (!isJSDocTagNode) {
44759+
pos_3 = node.end;
44760+
}
4474244761
};
4474344762
var processNodes = function (nodes) {
4474444763
if (pos_3 < nodes.pos) {
@@ -44753,7 +44772,6 @@ var ts;
4475344772
processNode(jsDocComment);
4475444773
}
4475544774
}
44756-
pos_3 = this.pos;
4475744775
ts.forEachChild(this, processNode, processNodes);
4475844776
if (pos_3 < this.end) {
4475944777
this.addSyntheticNodes(children, pos_3, this.end);

lib/tsserverlibrary.d.ts

+6
Original file line numberDiff line numberDiff line change
@@ -5257,6 +5257,12 @@ declare namespace ts {
52575257
key: string;
52585258
message: string;
52595259
};
5260+
_0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible: {
5261+
code: number;
5262+
category: DiagnosticCategory;
5263+
key: string;
5264+
message: string;
5265+
};
52605266
Import_declaration_0_is_using_private_name_1: {
52615267
code: number;
52625268
category: DiagnosticCategory;

lib/tsserverlibrary.js

+24-6
Original file line numberDiff line numberDiff line change
@@ -2248,6 +2248,7 @@ var ts;
22482248
Cannot_extend_an_interface_0_Did_you_mean_implements: { code: 2689, category: ts.DiagnosticCategory.Error, key: "Cannot_extend_an_interface_0_Did_you_mean_implements_2689", message: "Cannot extend an interface '{0}'. Did you mean 'implements'?" },
22492249
A_class_must_be_declared_after_its_base_class: { code: 2690, category: ts.DiagnosticCategory.Error, key: "A_class_must_be_declared_after_its_base_class_2690", message: "A class must be declared after its base class." },
22502250
An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead: { code: 2691, category: ts.DiagnosticCategory.Error, key: "An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead_2691", message: "An import path cannot end with a '{0}' extension. Consider importing '{1}' instead." },
2251+
_0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible: { code: 2692, category: ts.DiagnosticCategory.Error, key: "_0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible_2692", message: "'{0}' is a primitive, but '{1}' is a wrapper object. Prefer using '{0}' when possible." },
22512252
Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import_declaration_0_is_using_private_name_1_4000", message: "Import declaration '{0}' is using private name '{1}'." },
22522253
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", message: "Type parameter '{0}' of exported class has or is using private name '{1}'." },
22532254
Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", message: "Type parameter '{0}' of exported interface has or is using private name '{1}'." },
@@ -4803,7 +4804,7 @@ var ts;
48034804
}
48044805
ts.convertTypingOptionsFromJson = convertTypingOptionsFromJson;
48054806
function convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName) {
4806-
var options = ts.getBaseFileName(configFileName) === "jsconfig.json" ? { allowJs: true } : {};
4807+
var options = ts.getBaseFileName(configFileName) === "jsconfig.json" ? { allowJs: true, maxNodeModuleJsDepth: 2 } : {};
48074808
convertOptionsFromJson(ts.optionDeclarations, jsonOptions, basePath, options, ts.Diagnostics.Unknown_compiler_option_0, errors);
48084809
return options;
48094810
}
@@ -14927,7 +14928,7 @@ var ts;
1492714928
}
1492814929
}
1492914930
function getDeclarationOfAliasSymbol(symbol) {
14930-
return ts.findMap(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; });
14931+
return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; });
1493114932
}
1493214933
function getTargetOfImportEqualsDeclaration(node) {
1493314934
if (node.moduleReference.kind === 240) {
@@ -15059,6 +15060,7 @@ var ts;
1505915060
if (!links.target) {
1506015061
links.target = resolvingSymbol;
1506115062
var node = getDeclarationOfAliasSymbol(symbol);
15063+
ts.Debug.assert(!!node);
1506215064
var target = getTargetOfAliasDeclaration(node);
1506315065
if (links.target === resolvingSymbol) {
1506415066
links.target = target || unknownSymbol;
@@ -15088,6 +15090,7 @@ var ts;
1508815090
if (!links.referenced) {
1508915091
links.referenced = true;
1509015092
var node = getDeclarationOfAliasSymbol(symbol);
15093+
ts.Debug.assert(!!node);
1509115094
if (node.kind === 235) {
1509215095
checkExpressionCached(node.expression);
1509315096
}
@@ -19217,6 +19220,16 @@ var ts;
1921719220
}
1921819221
reportError(message, sourceType, targetType);
1921919222
}
19223+
function tryElaborateErrorsForPrimitivesAndObjects(source, target) {
19224+
var sourceType = typeToString(source);
19225+
var targetType = typeToString(target);
19226+
if ((globalStringType === source && stringType === target) ||
19227+
(globalNumberType === source && numberType === target) ||
19228+
(globalBooleanType === source && booleanType === target) ||
19229+
(getGlobalESSymbolType() === source && esSymbolType === target)) {
19230+
reportError(ts.Diagnostics._0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible, targetType, sourceType);
19231+
}
19232+
}
1922019233
function isRelatedTo(source, target, reportErrors, headMessage) {
1922119234
var result;
1922219235
if (source === target)
@@ -19295,6 +19308,9 @@ var ts;
1929519308
}
1929619309
}
1929719310
if (reportErrors) {
19311+
if (source.flags & 2588672 && target.flags & 8190) {
19312+
tryElaborateErrorsForPrimitivesAndObjects(source, target);
19313+
}
1929819314
reportRelationError(headMessage, source, target);
1929919315
}
1930019316
return 0;
@@ -38330,7 +38346,7 @@ var ts;
3833038346
var classifiableNames;
3833138347
var resolvedTypeReferenceDirectives = ts.createMap();
3833238348
var fileProcessingDiagnostics = ts.createDiagnosticCollection();
38333-
var maxNodeModulesJsDepth = typeof options.maxNodeModuleJsDepth === "number" ? options.maxNodeModuleJsDepth : 2;
38349+
var maxNodeModulesJsDepth = typeof options.maxNodeModuleJsDepth === "number" ? options.maxNodeModuleJsDepth : 0;
3833438350
var currentNodeModulesDepth = 0;
3833538351
var modulesWithElidedImports = ts.createMap();
3833638352
var sourceFilesFoundSearchingNodeModules = ts.createMap();
@@ -44734,11 +44750,14 @@ var ts;
4473444750
var pos_3 = this.pos;
4473544751
var useJSDocScanner_1 = this.kind >= 273 && this.kind <= 285;
4473644752
var processNode = function (node) {
44737-
if (pos_3 < node.pos) {
44753+
var isJSDocTagNode = ts.isJSDocTag(node);
44754+
if (!isJSDocTagNode && pos_3 < node.pos) {
4473844755
pos_3 = _this.addSyntheticNodes(children, pos_3, node.pos, useJSDocScanner_1);
4473944756
}
4474044757
children.push(node);
44741-
pos_3 = node.end;
44758+
if (!isJSDocTagNode) {
44759+
pos_3 = node.end;
44760+
}
4474244761
};
4474344762
var processNodes = function (nodes) {
4474444763
if (pos_3 < nodes.pos) {
@@ -44753,7 +44772,6 @@ var ts;
4475344772
processNode(jsDocComment);
4475444773
}
4475544774
}
44756-
pos_3 = this.pos;
4475744775
ts.forEachChild(this, processNode, processNodes);
4475844776
if (pos_3 < this.end) {
4475944777
this.addSyntheticNodes(children, pos_3, this.end);

0 commit comments

Comments
 (0)