mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-18 13:59:04 -05:00
Blacklist some built-ins and improve max cutoff
The maximum distance cutoff was being checked after the close-enough early exit. Now it's checked before. Note that `null` doesn't show up in the globals list, so it's not part of the blacklist either.
This commit is contained in:
@@ -1236,7 +1236,7 @@ namespace ts {
|
||||
|
||||
function checkAndReportErrorForUsingTypeAsValue(errorLocation: Node, name: string, meaning: SymbolFlags): boolean {
|
||||
if (meaning & (SymbolFlags.Value & ~SymbolFlags.NamespaceModule)) {
|
||||
if (name === "any" || name === "string" || name === "number" || name === "boolean" || name === "void" || name === "never") {
|
||||
if (name === "any" || name === "string" || name === "number" || name === "boolean" || name === "never") {
|
||||
error(errorLocation, Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, name);
|
||||
return true;
|
||||
}
|
||||
@@ -14224,14 +14224,24 @@ namespace ts {
|
||||
if (candidateName === name) {
|
||||
return candidate;
|
||||
}
|
||||
if (candidateName.length < 3 || name.length < 3) {
|
||||
if (candidateName.length < 3 ||
|
||||
name.length < 3 ||
|
||||
candidateName === "eval" ||
|
||||
candidateName === "Intl" ||
|
||||
candidateName === "undefined" ||
|
||||
candidateName === "Map" ||
|
||||
candidateName === "NaN" ||
|
||||
candidateName === "Set") {
|
||||
continue;
|
||||
}
|
||||
const distance = levenshtein(candidateName, name);
|
||||
if (distance > worstDistance) {
|
||||
continue;
|
||||
}
|
||||
if (distance < 3) {
|
||||
return candidate;
|
||||
}
|
||||
else if (distance < bestDistance && distance < worstDistance) {
|
||||
else if (distance < bestDistance) {
|
||||
bestDistance = distance;
|
||||
bestCandidate = candidate;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user