Skip to content

Commit c36fe23

Browse files
committed
chore: make isJsxAttr required
1 parent d38096a commit c36fe23

File tree

6 files changed

+18
-18
lines changed

6 files changed

+18
-18
lines changed

src/compiler/checker.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13245,7 +13245,7 @@ namespace ts {
1324513245
}
1324613246
else {
1324713247
let suggestion: string | undefined;
13248-
if (propName !== undefined && (suggestion = getSuggestionForNonexistentProperty(propName as string, objectType))) {
13248+
if (propName !== undefined && (suggestion = getSuggestionForNonexistentProperty(propName as string, objectType, false))) {
1324913249
if (suggestion !== undefined) {
1325013250
error(accessExpression.argumentExpression, Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, propName as string, typeToString(objectType), suggestion);
1325113251
}
@@ -16335,7 +16335,7 @@ namespace ts {
1633516335

1633616336
const name = propDeclaration.name!;
1633716337
if (isIdentifier(name)) {
16338-
suggestion = getSuggestionForNonexistentProperty(name, errorTarget);
16338+
suggestion = getSuggestionForNonexistentProperty(name, errorTarget, false);
1633916339
}
1634016340
}
1634116341
if (suggestion !== undefined) {
@@ -24852,7 +24852,7 @@ namespace ts {
2485224852
relatedInfo = createDiagnosticForNode(propNode, Diagnostics.Did_you_forget_to_use_await);
2485324853
}
2485424854
else {
24855-
const suggestion = getSuggestedSymbolForNonexistentProperty(propNode, containingType);
24855+
const suggestion = getSuggestedSymbolForNonexistentProperty(propNode, containingType, false);
2485624856
if (suggestion !== undefined) {
2485724857
const suggestedName = symbolName(suggestion);
2485824858
errorInfo = chainDiagnosticMessages(errorInfo, Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, declarationNameToString(propNode), typeToString(containingType), suggestedName);
@@ -24875,12 +24875,12 @@ namespace ts {
2487524875
return prop !== undefined && prop.valueDeclaration && hasSyntacticModifier(prop.valueDeclaration, ModifierFlags.Static);
2487624876
}
2487724877

24878-
function getSuggestedSymbolForNonexistentProperty(name: Identifier | PrivateIdentifier | string, containingType: Type, isJSX = false): Symbol | undefined {
24879-
return getSpellingSuggestionForName(isString(name) ? name : idText(name), getPropertiesOfType(containingType), SymbolFlags.Value, isJSX);
24878+
function getSuggestedSymbolForNonexistentProperty(name: Identifier | PrivateIdentifier | string, containingType: Type, isJsxAttr: boolean): Symbol | undefined {
24879+
return getSpellingSuggestionForName(isString(name) ? name : idText(name), getPropertiesOfType(containingType), SymbolFlags.Value, isJsxAttr);
2488024880
}
2488124881

24882-
function getSuggestionForNonexistentProperty(name: Identifier | PrivateIdentifier | string, containingType: Type, isJSX = false): string | undefined {
24883-
const suggestion = getSuggestedSymbolForNonexistentProperty(name, containingType, isJSX);
24882+
function getSuggestionForNonexistentProperty(name: Identifier | PrivateIdentifier | string, containingType: Type, isJsxAttr: boolean): string | undefined {
24883+
const suggestion = getSuggestedSymbolForNonexistentProperty(name, containingType, isJsxAttr);
2488424884
return suggestion && symbolName(suggestion);
2488524885
}
2488624886

@@ -24892,7 +24892,7 @@ namespace ts {
2489224892
// Sometimes the symbol is found when location is a return type of a function: `typeof x` and `x` is declared in the body of the function
2489324893
// So the table *contains* `x` but `x` isn't actually in scope.
2489424894
// However, resolveNameHelper will continue and call this callback again, so we'll eventually get a correct suggestion.
24895-
return symbol || getSpellingSuggestionForName(unescapeLeadingUnderscores(name), arrayFrom(symbols.values()), meaning);
24895+
return symbol || getSpellingSuggestionForName(unescapeLeadingUnderscores(name), arrayFrom(symbols.values()), meaning, false);
2489624896
});
2489724897
return result;
2489824898
}
@@ -24903,7 +24903,7 @@ namespace ts {
2490324903
}
2490424904

2490524905
function getSuggestedSymbolForNonexistentModule(name: Identifier, targetModule: Symbol): Symbol | undefined {
24906-
return targetModule.exports && getSpellingSuggestionForName(idText(name), getExportsOfModuleAsArray(targetModule), SymbolFlags.ModuleMember);
24906+
return targetModule.exports && getSpellingSuggestionForName(idText(name), getExportsOfModuleAsArray(targetModule), SymbolFlags.ModuleMember, false);
2490724907
}
2490824908

2490924909
function getSuggestionForNonexistentExport(name: Identifier, targetModule: Symbol): string | undefined {
@@ -24953,8 +24953,8 @@ namespace ts {
2495324953
* (0.4 allows 1 substitution/transposition for every 5 characters,
2495424954
* and 1 insertion/deletion at 3 characters)
2495524955
*/
24956-
function getSpellingSuggestionForName(name: string, symbols: Symbol[], meaning: SymbolFlags, isJSX = false): Symbol | undefined {
24957-
return getSpellingSuggestion(name, symbols, getCandidateName, isJSX);
24956+
function getSpellingSuggestionForName(name: string, symbols: Symbol[], meaning: SymbolFlags, isJsxAttr: boolean): Symbol | undefined {
24957+
return getSpellingSuggestion(name, symbols, getCandidateName, isJsxAttr);
2495824958
function getCandidateName(candidate: Symbol) {
2495924959
const candidateName = symbolName(candidate);
2496024960
if (startsWith(candidateName, "\"")) {

src/compiler/commandLineParser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1194,7 +1194,7 @@ namespace ts {
11941194
createDiagnostics: (message: DiagnosticMessage, arg0: string, arg1?: string) => Diagnostic,
11951195
unknownOptionErrorText?: string
11961196
) {
1197-
const possibleOption = getSpellingSuggestion(unknownOption, diagnostics.optionDeclarations, getOptionName);
1197+
const possibleOption = getSpellingSuggestion(unknownOption, diagnostics.optionDeclarations, getOptionName, false);
11981198
return possibleOption ?
11991199
createDiagnostics(diagnostics.unknownDidYouMeanDiagnostic, unknownOptionErrorText || unknownOption, possibleOption.name) :
12001200
createDiagnostics(diagnostics.unknownOptionDiagnostic, unknownOptionErrorText || unknownOption);

src/compiler/core.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1817,15 +1817,15 @@ namespace ts {
18171817
* (0.4 allows 1 substitution/transposition for every 5 characters,
18181818
* and 1 insertion/deletion at 3 characters)
18191819
*/
1820-
export function getSpellingSuggestion<T>(name: string, candidates: T[], getName: (candidate: T) => string | undefined, isJSX = false): T | undefined {
1820+
export function getSpellingSuggestion<T>(name: string, candidates: T[], getName: (candidate: T) => string | undefined, isJsxAttr: boolean): T | undefined {
18211821
const maximumLengthDifference = Math.min(2, Math.floor(name.length * 0.34));
18221822
let bestDistance = Math.floor(name.length * 0.4) + 1; // If the best result isn't better than this, don't bother.
18231823
let bestCandidate: T | undefined;
18241824
let justCheckExactMatches = false;
18251825
const nameLowerCase = name.toLowerCase();
18261826
for (const candidate of candidates) {
18271827
const candidateName = getName(candidate);
1828-
if (isJSX) {
1828+
if (isJsxAttr) {
18291829
const htmlFor = name === "for" && candidateName === "htmlFor";
18301830
const className = name === "class" && candidateName === "className";
18311831
if (htmlFor || className) {

src/compiler/program.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2784,7 +2784,7 @@ namespace ts {
27842784
}
27852785
else {
27862786
const unqualifiedLibName = removeSuffix(removePrefix(libName, "lib."), ".d.ts");
2787-
const suggestion = getSpellingSuggestion(unqualifiedLibName, libs, identity);
2787+
const suggestion = getSpellingSuggestion(unqualifiedLibName, libs, identity, false);
27882788
const message = suggestion ? Diagnostics.Cannot_find_lib_definition_for_0_Did_you_mean_1 : Diagnostics.Cannot_find_lib_definition_for_0;
27892789
fileProcessingDiagnostics.add(createFileDiagnostic(
27902790
file,

src/compiler/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4009,8 +4009,8 @@ namespace ts {
40094009
*/
40104010
/* @internal */ tryGetMemberInModuleExportsAndProperties(memberName: string, moduleSymbol: Symbol): Symbol | undefined;
40114011
getApparentType(type: Type): Type;
4012-
/* @internal */ getSuggestedSymbolForNonexistentProperty(name: Identifier | PrivateIdentifier | string, containingType: Type, isJSX?: boolean): Symbol | undefined;
4013-
/* @internal */ getSuggestionForNonexistentProperty(name: Identifier | PrivateIdentifier | string, containingType: Type): string | undefined;
4012+
/* @internal */ getSuggestedSymbolForNonexistentProperty(name: Identifier | PrivateIdentifier | string, containingType: Type, isJsxAttr: boolean): Symbol | undefined;
4013+
/* @internal */ getSuggestionForNonexistentProperty(name: Identifier | PrivateIdentifier | string, containingType: Type, isJsxAttr: boolean): string | undefined;
40144014
/* @internal */ getSuggestedSymbolForNonexistentSymbol(location: Node, name: string, meaning: SymbolFlags): Symbol | undefined;
40154015
/* @internal */ getSuggestionForNonexistentSymbol(location: Node, name: string, meaning: SymbolFlags): string | undefined;
40164016
/* @internal */ getSuggestedSymbolForNonexistentModule(node: Identifier, target: Symbol): Symbol | undefined;

src/services/codefixes/fixSpelling.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ namespace ts.codefix {
5151
if (parent.flags & NodeFlags.OptionalChain) {
5252
containingType = checker.getNonNullableType(containingType);
5353
}
54-
suggestedSymbol = checker.getSuggestedSymbolForNonexistentProperty(node, containingType);
54+
suggestedSymbol = checker.getSuggestedSymbolForNonexistentProperty(node, containingType, false);
5555
}
5656
else if (isImportSpecifier(parent) && parent.name === node) {
5757
Debug.assertNode(node, isIdentifier, "Expected an identifier for spelling (import)");

0 commit comments

Comments
 (0)