@@ -9204,12 +9204,13 @@ namespace ts {
92049204 }
92059205
92069206 function resolveImportSymbolType(node: ImportTypeNode, links: NodeLinks, symbol: Symbol, meaning: SymbolFlags) {
9207- links.resolvedSymbol = symbol;
9207+ const resolvedSymbol = resolveSymbol(symbol);
9208+ links.resolvedSymbol = resolvedSymbol;
92089209 if (meaning === SymbolFlags.Value) {
9209- return links.resolvedType = getTypeOfSymbol(symbol);
9210+ return links.resolvedType = getTypeOfSymbol(symbol); // intentionally doesn't use resolved symbol so type is cached as expected on the alias
92109211 }
92119212 else {
9212- return links.resolvedType = getTypeReferenceType(node, symbol);
9213+ return links.resolvedType = getTypeReferenceType(node, resolvedSymbol); // getTypeReferenceType doesn't handle aliases - it must get the resolved symbol
92139214 }
92149215 }
92159216
@@ -17381,88 +17382,11 @@ namespace ts {
1738117382 * and 1 insertion/deletion at 3 characters)
1738217383 */
1738317384 function getSpellingSuggestionForName(name: string, symbols: Symbol[], meaning: SymbolFlags): Symbol | undefined {
17384- const maximumLengthDifference = Math.min(2, Math.floor(name.length * 0.34));
17385- let bestDistance = Math.floor(name.length * 0.4) + 1; // If the best result isn't better than this, don't bother.
17386- let bestCandidate: Symbol | undefined;
17387- let justCheckExactMatches = false;
17388- const nameLowerCase = name.toLowerCase();
17389- for (const candidate of symbols) {
17385+ return getSpellingSuggestion(name, symbols, getCandidateName);
17386+ function getCandidateName(candidate: Symbol) {
1739017387 const candidateName = symbolName(candidate);
17391- if (candidateName.charCodeAt(0) === CharacterCodes.doubleQuote
17392- || !(candidate.flags & meaning && Math.abs(candidateName.length - nameLowerCase.length) <= maximumLengthDifference)) {
17393- continue;
17394- }
17395- const candidateNameLowerCase = candidateName.toLowerCase();
17396- if (candidateNameLowerCase === nameLowerCase) {
17397- return candidate;
17398- }
17399- if (justCheckExactMatches) {
17400- continue;
17401- }
17402- if (candidateName.length < 3) {
17403- // Don't bother, user would have noticed a 2-character name having an extra character
17404- continue;
17405- }
17406- // Only care about a result better than the best so far.
17407- const distance = levenshteinWithMax(nameLowerCase, candidateNameLowerCase, bestDistance - 1);
17408- if (distance === undefined) {
17409- continue;
17410- }
17411- if (distance < 3) {
17412- justCheckExactMatches = true;
17413- bestCandidate = candidate;
17414- }
17415- else {
17416- Debug.assert(distance < bestDistance); // Else `levenshteinWithMax` should return undefined
17417- bestDistance = distance;
17418- bestCandidate = candidate;
17419- }
17388+ return !startsWith(candidateName, "\"") && candidate.flags & meaning ? candidateName : undefined;
1742017389 }
17421- return bestCandidate;
17422- }
17423-
17424- function levenshteinWithMax(s1: string, s2: string, max: number): number | undefined {
17425- let previous = new Array(s2.length + 1);
17426- let current = new Array(s2.length + 1);
17427- /** Represents any value > max. We don't care about the particular value. */
17428- const big = max + 1;
17429-
17430- for (let i = 0; i <= s2.length; i++) {
17431- previous[i] = i;
17432- }
17433-
17434- for (let i = 1; i <= s1.length; i++) {
17435- const c1 = s1.charCodeAt(i - 1);
17436- const minJ = i > max ? i - max : 1;
17437- const maxJ = s2.length > max + i ? max + i : s2.length;
17438- current[0] = i;
17439- /** Smallest value of the matrix in the ith column. */
17440- let colMin = i;
17441- for (let j = 1; j < minJ; j++) {
17442- current[j] = big;
17443- }
17444- for (let j = minJ; j <= maxJ; j++) {
17445- const dist = c1 === s2.charCodeAt(j - 1)
17446- ? previous[j - 1]
17447- : Math.min(/*delete*/ previous[j] + 1, /*insert*/ current[j - 1] + 1, /*substitute*/ previous[j - 1] + 2);
17448- current[j] = dist;
17449- colMin = Math.min(colMin, dist);
17450- }
17451- for (let j = maxJ + 1; j <= s2.length; j++) {
17452- current[j] = big;
17453- }
17454- if (colMin > max) {
17455- // Give up -- everything in this column is > max and it can't get better in future columns.
17456- return undefined;
17457- }
17458-
17459- const temp = previous;
17460- previous = current;
17461- current = temp;
17462- }
17463-
17464- const res = previous[s2.length];
17465- return res > max ? undefined : res;
1746617390 }
1746717391
1746817392 function markPropertyAsReferenced(prop: Symbol, nodeForCheckWriteOnly: Node | undefined, isThisAccess: boolean) {
0 commit comments