From ac87e82f086a919b272e30432dfddadc608804d3 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Mon, 22 Jun 2020 15:11:30 -0700 Subject: [PATCH] inline local functions --- src/compiler/checker.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 43df261edc0..464d30ee813 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -24884,13 +24884,10 @@ namespace ts { function getSuggestedSymbolForNonexistentJSXAttribute(name: Identifier | PrivateIdentifier | string, containingType: Type): Symbol | undefined { const strName = isString(name) ? name : idText(name); const properties = getPropertiesOfType(containingType); - const defaultSuggestion = () => getSpellingSuggestionForName(strName, properties, SymbolFlags.Value); - const getCandidate = (expectedName: string) => properties.find(x => symbolName(x) === expectedName); - switch (strName) { - case "for": return getCandidate("htmlFor") || defaultSuggestion(); - case "class": return getCandidate("className") || defaultSuggestion(); - } - return defaultSuggestion(); + const jsxSpecific = strName === "for" ? properties.find(x => symbolName(x) === "htmlFor") + : strName === "class" ? properties.find(x => symbolName(x) === "className") + : undefined; + return jsxSpecific ?? getSpellingSuggestionForName(strName, properties, SymbolFlags.Value); } function getSuggestionForNonexistentProperty(name: Identifier | PrivateIdentifier | string, containingType: Type): string | undefined {