suggest primitives instead of wrappers
This commit is contained in:
parent
a734b84ed0
commit
8fd16baba1
|
@ -2115,16 +2115,23 @@ namespace ts {
|
||||||
suggestion = undefined;
|
suggestion = undefined;
|
||||||
}
|
}
|
||||||
if (suggestion) {
|
if (suggestion) {
|
||||||
const suggestionName = symbolToString(suggestion);
|
let suggestionName = symbolToString(suggestion);
|
||||||
|
let elaborate = !!suggestion.valueDeclaration
|
||||||
|
if ((suggestionName === "String" || suggestionName === "Object" || suggestionName === "Number" || suggestionName === "BigInt" || suggestionName === "Symbol")
|
||||||
|
&& name !== suggestionName.toLowerCase()
|
||||||
|
&& name === (name as string).toLowerCase()) {
|
||||||
|
suggestionName = suggestionName.toLowerCase()
|
||||||
|
elaborate = false
|
||||||
|
}
|
||||||
const isUncheckedJS = isUncheckedJSSuggestion(originalLocation, suggestion, /*excludeClasses*/ false);
|
const isUncheckedJS = isUncheckedJSSuggestion(originalLocation, suggestion, /*excludeClasses*/ false);
|
||||||
const message = isUncheckedJS ? Diagnostics.Could_not_find_name_0_Did_you_mean_1 : Diagnostics.Cannot_find_name_0_Did_you_mean_1;
|
const message = isUncheckedJS ? Diagnostics.Could_not_find_name_0_Did_you_mean_1 : Diagnostics.Cannot_find_name_0_Did_you_mean_1;
|
||||||
const diagnostic = createError(errorLocation, message, diagnosticName(nameArg!), suggestionName);
|
const diagnostic = createError(errorLocation, message, diagnosticName(nameArg!), suggestionName);
|
||||||
addErrorOrSuggestion(!isUncheckedJS, diagnostic);
|
addErrorOrSuggestion(!isUncheckedJS, diagnostic);
|
||||||
|
|
||||||
if (suggestion.valueDeclaration) {
|
if (elaborate) {
|
||||||
addRelatedInfo(
|
addRelatedInfo(
|
||||||
diagnostic,
|
diagnostic,
|
||||||
createDiagnosticForNode(suggestion.valueDeclaration, Diagnostics._0_is_declared_here, suggestionName)
|
createDiagnosticForNode(suggestion.valueDeclaration!, Diagnostics._0_is_declared_here, suggestionName)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/a.js(3,15): error TS2552: Cannot find name 'sting'. Did you mean 'String'?
|
/a.js(3,15): error TS2552: Cannot find name 'sting'. Did you mean 'string'?
|
||||||
|
|
||||||
|
|
||||||
==== /a.js (1 errors) ====
|
==== /a.js (1 errors) ====
|
||||||
|
@ -6,8 +6,7 @@
|
||||||
* @typedef MyType
|
* @typedef MyType
|
||||||
* @property {sting} [x]
|
* @property {sting} [x]
|
||||||
~~~~~
|
~~~~~
|
||||||
!!! error TS2552: Cannot find name 'sting'. Did you mean 'String'?
|
!!! error TS2552: Cannot find name 'sting'. Did you mean 'string'?
|
||||||
!!! related TS2728 /.ts/lib.es5.d.ts:530:13: 'String' is declared here.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** @param {MyType} p */
|
/** @param {MyType} p */
|
||||||
|
|
Loading…
Reference in a new issue