|
|
|
|
@@ -230,7 +230,7 @@ namespace ts {
|
|
|
|
|
getSuggestionForNonexistentSymbol: (location, name, meaning) => unescapeLeadingUnderscores(getSuggestionForNonexistentSymbol(location, escapeLeadingUnderscores(name), meaning)),
|
|
|
|
|
getBaseConstraintOfType,
|
|
|
|
|
resolveName(name, location, meaning) {
|
|
|
|
|
return resolveName(location, escapeLeadingUnderscores(name), meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined);
|
|
|
|
|
return resolveName(location, escapeLeadingUnderscores(name), meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false);
|
|
|
|
|
},
|
|
|
|
|
getJsxNamespace: () => unescapeLeadingUnderscores(getJsxNamespace()),
|
|
|
|
|
};
|
|
|
|
|
@@ -865,17 +865,22 @@ namespace ts {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Resolve a given name for a given meaning at a given location. An error is reported if the name was not found and
|
|
|
|
|
// the nameNotFoundMessage argument is not undefined. Returns the resolved symbol, or undefined if no symbol with
|
|
|
|
|
// the given name can be found.
|
|
|
|
|
/**
|
|
|
|
|
* Resolve a given name for a given meaning at a given location. An error is reported if the name was not found and
|
|
|
|
|
* the nameNotFoundMessage argument is not undefined. Returns the resolved symbol, or undefined if no symbol with
|
|
|
|
|
* the given name can be found.
|
|
|
|
|
*
|
|
|
|
|
* @param isUse If true, this will count towards --noUnusedLocals / --noUnusedParameters.
|
|
|
|
|
*/
|
|
|
|
|
function resolveName(
|
|
|
|
|
location: Node | undefined,
|
|
|
|
|
name: __String,
|
|
|
|
|
meaning: SymbolFlags,
|
|
|
|
|
nameNotFoundMessage: DiagnosticMessage | undefined,
|
|
|
|
|
nameArg: __String | Identifier,
|
|
|
|
|
isUse: boolean,
|
|
|
|
|
suggestedNameNotFoundMessage?: DiagnosticMessage): Symbol {
|
|
|
|
|
return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, getSymbol, suggestedNameNotFoundMessage);
|
|
|
|
|
return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, getSymbol, suggestedNameNotFoundMessage);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function resolveNameHelper(
|
|
|
|
|
@@ -884,6 +889,7 @@ namespace ts {
|
|
|
|
|
meaning: SymbolFlags,
|
|
|
|
|
nameNotFoundMessage: DiagnosticMessage,
|
|
|
|
|
nameArg: __String | Identifier,
|
|
|
|
|
isUse: boolean,
|
|
|
|
|
lookup: typeof getSymbol,
|
|
|
|
|
suggestedNameNotFoundMessage?: DiagnosticMessage): Symbol {
|
|
|
|
|
const originalLocation = location; // needed for did-you-mean error reporting, which gathers candidates starting from the original location
|
|
|
|
|
@@ -1114,7 +1120,7 @@ namespace ts {
|
|
|
|
|
// We just climbed up parents looking for the name, meaning that we started in a descendant node of `lastLocation`.
|
|
|
|
|
// If `result === lastLocation.symbol`, that means that we are somewhere inside `lastLocation` looking up a name, and resolving to `lastLocation` itself.
|
|
|
|
|
// That means that this is a self-reference of `lastLocation`, and shouldn't count this when considering whether `lastLocation` is used.
|
|
|
|
|
if (result && nameNotFoundMessage && noUnusedIdentifiers && result !== lastLocation.symbol) {
|
|
|
|
|
if (isUse && result && nameNotFoundMessage && noUnusedIdentifiers && result !== lastLocation.symbol) {
|
|
|
|
|
result.isReferenced = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -1267,7 +1273,7 @@ namespace ts {
|
|
|
|
|
|
|
|
|
|
function checkAndReportErrorForUsingTypeAsNamespace(errorLocation: Node, name: __String, meaning: SymbolFlags): boolean {
|
|
|
|
|
if (meaning === SymbolFlags.Namespace) {
|
|
|
|
|
const symbol = resolveSymbol(resolveName(errorLocation, name, SymbolFlags.Type & ~SymbolFlags.Value, /*nameNotFoundMessage*/undefined, /*nameArg*/ undefined));
|
|
|
|
|
const symbol = resolveSymbol(resolveName(errorLocation, name, SymbolFlags.Type & ~SymbolFlags.Value, /*nameNotFoundMessage*/undefined, /*nameArg*/ undefined, /*isUse*/ false));
|
|
|
|
|
const parent = errorLocation.parent;
|
|
|
|
|
if (symbol) {
|
|
|
|
|
if (isQualifiedName(parent)) {
|
|
|
|
|
@@ -1298,7 +1304,7 @@ namespace ts {
|
|
|
|
|
error(errorLocation, Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, unescapeLeadingUnderscores(name));
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
const symbol = resolveSymbol(resolveName(errorLocation, name, SymbolFlags.Type & ~SymbolFlags.Value, /*nameNotFoundMessage*/undefined, /*nameArg*/ undefined));
|
|
|
|
|
const symbol = resolveSymbol(resolveName(errorLocation, name, SymbolFlags.Type & ~SymbolFlags.Value, /*nameNotFoundMessage*/undefined, /*nameArg*/ undefined, /*isUse*/ false));
|
|
|
|
|
if (symbol && !(symbol.flags & SymbolFlags.NamespaceModule)) {
|
|
|
|
|
error(errorLocation, Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, unescapeLeadingUnderscores(name));
|
|
|
|
|
return true;
|
|
|
|
|
@@ -1309,14 +1315,14 @@ namespace ts {
|
|
|
|
|
|
|
|
|
|
function checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation: Node, name: __String, meaning: SymbolFlags): boolean {
|
|
|
|
|
if (meaning & (SymbolFlags.Value & ~SymbolFlags.NamespaceModule & ~SymbolFlags.Type)) {
|
|
|
|
|
const symbol = resolveSymbol(resolveName(errorLocation, name, SymbolFlags.NamespaceModule & ~SymbolFlags.Value, /*nameNotFoundMessage*/undefined, /*nameArg*/ undefined));
|
|
|
|
|
const symbol = resolveSymbol(resolveName(errorLocation, name, SymbolFlags.NamespaceModule & ~SymbolFlags.Value, /*nameNotFoundMessage*/undefined, /*nameArg*/ undefined, /*isUse*/ false));
|
|
|
|
|
if (symbol) {
|
|
|
|
|
error(errorLocation, Diagnostics.Cannot_use_namespace_0_as_a_value, unescapeLeadingUnderscores(name));
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (meaning & (SymbolFlags.Type & ~SymbolFlags.NamespaceModule & ~SymbolFlags.Value)) {
|
|
|
|
|
const symbol = resolveSymbol(resolveName(errorLocation, name, SymbolFlags.NamespaceModule & ~SymbolFlags.Type, /*nameNotFoundMessage*/undefined, /*nameArg*/ undefined));
|
|
|
|
|
const symbol = resolveSymbol(resolveName(errorLocation, name, SymbolFlags.NamespaceModule & ~SymbolFlags.Type, /*nameNotFoundMessage*/undefined, /*nameArg*/ undefined, /*isUse*/ false));
|
|
|
|
|
if (symbol) {
|
|
|
|
|
error(errorLocation, Diagnostics.Cannot_use_namespace_0_as_a_type, unescapeLeadingUnderscores(name));
|
|
|
|
|
return true;
|
|
|
|
|
@@ -1640,7 +1646,7 @@ namespace ts {
|
|
|
|
|
if (name.kind === SyntaxKind.Identifier) {
|
|
|
|
|
const message = meaning === SymbolFlags.Namespace ? Diagnostics.Cannot_find_namespace_0 : Diagnostics.Cannot_find_name_0;
|
|
|
|
|
|
|
|
|
|
symbol = resolveName(location || name, name.escapedText, meaning, ignoreErrors ? undefined : message, name);
|
|
|
|
|
symbol = resolveName(location || name, name.escapedText, meaning, ignoreErrors ? undefined : message, name, /*isUse*/ true);
|
|
|
|
|
if (!symbol) {
|
|
|
|
|
return undefined;
|
|
|
|
|
}
|
|
|
|
|
@@ -2314,7 +2320,7 @@ namespace ts {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const firstIdentifier = getFirstIdentifier(entityName);
|
|
|
|
|
const symbol = resolveName(enclosingDeclaration, firstIdentifier.escapedText, meaning, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined);
|
|
|
|
|
const symbol = resolveName(enclosingDeclaration, firstIdentifier.escapedText, meaning, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false);
|
|
|
|
|
|
|
|
|
|
// Verify if the symbol is accessible
|
|
|
|
|
return (symbol && hasVisibleDeclarations(symbol, /*shouldComputeAliasToMakeVisible*/ true)) || {
|
|
|
|
|
@@ -3971,7 +3977,7 @@ namespace ts {
|
|
|
|
|
function collectLinkedAliases(node: Identifier): Node[] {
|
|
|
|
|
let exportSymbol: Symbol;
|
|
|
|
|
if (node.parent && node.parent.kind === SyntaxKind.ExportAssignment) {
|
|
|
|
|
exportSymbol = resolveName(node.parent, node.escapedText, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias, Diagnostics.Cannot_find_name_0, node);
|
|
|
|
|
exportSymbol = resolveName(node.parent, node.escapedText, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias, Diagnostics.Cannot_find_name_0, node, /*isUse*/ false);
|
|
|
|
|
}
|
|
|
|
|
else if (node.parent.kind === SyntaxKind.ExportSpecifier) {
|
|
|
|
|
exportSymbol = getTargetOfExportSpecifier(<ExportSpecifier>node.parent, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias);
|
|
|
|
|
@@ -3993,7 +3999,7 @@ namespace ts {
|
|
|
|
|
const internalModuleReference = <Identifier | QualifiedName>(<ImportEqualsDeclaration>declaration).moduleReference;
|
|
|
|
|
const firstIdentifier = getFirstIdentifier(internalModuleReference);
|
|
|
|
|
const importSymbol = resolveName(declaration, firstIdentifier.escapedText, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace,
|
|
|
|
|
undefined, undefined);
|
|
|
|
|
undefined, undefined, /*isUse*/ false);
|
|
|
|
|
if (importSymbol) {
|
|
|
|
|
buildVisibleNodeList(importSymbol.declarations);
|
|
|
|
|
}
|
|
|
|
|
@@ -6408,7 +6414,7 @@ namespace ts {
|
|
|
|
|
let paramSymbol = param.symbol;
|
|
|
|
|
// Include parameter symbol instead of property symbol in the signature
|
|
|
|
|
if (paramSymbol && !!(paramSymbol.flags & SymbolFlags.Property) && !isBindingPattern(param.name)) {
|
|
|
|
|
const resolvedSymbol = resolveName(param, paramSymbol.escapedName, SymbolFlags.Value, undefined, undefined);
|
|
|
|
|
const resolvedSymbol = resolveName(param, paramSymbol.escapedName, SymbolFlags.Value, undefined, undefined, /*isUse*/ false);
|
|
|
|
|
paramSymbol = resolvedSymbol;
|
|
|
|
|
}
|
|
|
|
|
if (i === 0 && paramSymbol.escapedName === "this") {
|
|
|
|
|
@@ -7085,7 +7091,8 @@ namespace ts {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getGlobalSymbol(name: __String, meaning: SymbolFlags, diagnostic: DiagnosticMessage): Symbol {
|
|
|
|
|
return resolveName(undefined, name, meaning, diagnostic, name);
|
|
|
|
|
// Don't track references for global symbols anyway, so value if `isReference` is arbitrary
|
|
|
|
|
return resolveName(undefined, name, meaning, diagnostic, name, /*isUse*/ false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getGlobalType(name: __String, arity: 0, reportErrors: boolean): ObjectType;
|
|
|
|
|
@@ -10832,7 +10839,15 @@ namespace ts {
|
|
|
|
|
function getResolvedSymbol(node: Identifier): Symbol {
|
|
|
|
|
const links = getNodeLinks(node);
|
|
|
|
|
if (!links.resolvedSymbol) {
|
|
|
|
|
links.resolvedSymbol = !nodeIsMissing(node) && resolveName(node, node.escapedText, SymbolFlags.Value | SymbolFlags.ExportValue, Diagnostics.Cannot_find_name_0, node, Diagnostics.Cannot_find_name_0_Did_you_mean_1) || unknownSymbol;
|
|
|
|
|
links.resolvedSymbol = !nodeIsMissing(node) &&
|
|
|
|
|
resolveName(
|
|
|
|
|
node,
|
|
|
|
|
node.escapedText,
|
|
|
|
|
SymbolFlags.Value | SymbolFlags.ExportValue,
|
|
|
|
|
Diagnostics.Cannot_find_name_0,
|
|
|
|
|
node,
|
|
|
|
|
!isWriteOnlyAccess(node),
|
|
|
|
|
Diagnostics.Cannot_find_name_0_Did_you_mean_1) || unknownSymbol;
|
|
|
|
|
}
|
|
|
|
|
return links.resolvedSymbol;
|
|
|
|
|
}
|
|
|
|
|
@@ -14428,7 +14443,7 @@ namespace ts {
|
|
|
|
|
// And if there is no reactNamespace/jsxFactory's symbol in scope when targeting React emit, we should issue an error.
|
|
|
|
|
const reactRefErr = diagnostics && compilerOptions.jsx === JsxEmit.React ? Diagnostics.Cannot_find_name_0 : undefined;
|
|
|
|
|
const reactNamespace = getJsxNamespace();
|
|
|
|
|
const reactSym = resolveName(node.tagName, reactNamespace, SymbolFlags.Value, reactRefErr, reactNamespace);
|
|
|
|
|
const reactSym = resolveName(node.tagName, reactNamespace, SymbolFlags.Value, reactRefErr, reactNamespace, /*isUse*/ true);
|
|
|
|
|
if (reactSym) {
|
|
|
|
|
// Mark local symbol as referenced here because it might not have been marked
|
|
|
|
|
// if jsx emit was not react as there wont be error being emitted
|
|
|
|
|
@@ -14704,7 +14719,7 @@ namespace ts {
|
|
|
|
|
|
|
|
|
|
checkPropertyNotUsedBeforeDeclaration(prop, node, right);
|
|
|
|
|
|
|
|
|
|
markPropertyAsReferenced(prop);
|
|
|
|
|
markPropertyAsReferenced(prop, node);
|
|
|
|
|
|
|
|
|
|
getNodeLinks(node).resolvedSymbol = prop;
|
|
|
|
|
|
|
|
|
|
@@ -14804,7 +14819,7 @@ namespace ts {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getSuggestionForNonexistentSymbol(location: Node, name: __String, meaning: SymbolFlags): __String {
|
|
|
|
|
const result = resolveNameHelper(location, name, meaning, /*nameNotFoundMessage*/ undefined, name, (symbols, name, meaning) => {
|
|
|
|
|
const result = resolveNameHelper(location, name, meaning, /*nameNotFoundMessage*/ undefined, name, /*isUse*/ false, (symbols, name, meaning) => {
|
|
|
|
|
const symbol = getSymbol(symbols, name, meaning);
|
|
|
|
|
if (symbol) {
|
|
|
|
|
// 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
|
|
|
|
|
@@ -14884,11 +14899,12 @@ namespace ts {
|
|
|
|
|
return bestCandidate;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function markPropertyAsReferenced(prop: Symbol) {
|
|
|
|
|
function markPropertyAsReferenced(prop: Symbol, nodeForCheckWriteOnly: Node | undefined) {
|
|
|
|
|
if (prop &&
|
|
|
|
|
noUnusedIdentifiers &&
|
|
|
|
|
(prop.flags & SymbolFlags.ClassMember) &&
|
|
|
|
|
prop.valueDeclaration && hasModifier(prop.valueDeclaration, ModifierFlags.Private)) {
|
|
|
|
|
prop.valueDeclaration && hasModifier(prop.valueDeclaration, ModifierFlags.Private)
|
|
|
|
|
&& !(nodeForCheckWriteOnly && isWriteOnlyAccess(nodeForCheckWriteOnly))) {
|
|
|
|
|
if (getCheckFlags(prop) & CheckFlags.Instantiated) {
|
|
|
|
|
getSymbolLinks(prop).target.isReferenced = true;
|
|
|
|
|
}
|
|
|
|
|
@@ -15153,7 +15169,6 @@ namespace ts {
|
|
|
|
|
let argCount: number; // Apparent number of arguments we will have in this call
|
|
|
|
|
let typeArguments: NodeArray<TypeNode>; // Type arguments (undefined if none)
|
|
|
|
|
let callIsIncomplete: boolean; // In incomplete call we want to be lenient when we have too few arguments
|
|
|
|
|
let isDecorator: boolean;
|
|
|
|
|
let spreadArgIndex = -1;
|
|
|
|
|
|
|
|
|
|
if (isJsxOpeningLikeElement(node)) {
|
|
|
|
|
@@ -15187,7 +15202,6 @@ namespace ts {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (node.kind === SyntaxKind.Decorator) {
|
|
|
|
|
isDecorator = true;
|
|
|
|
|
typeArguments = undefined;
|
|
|
|
|
argCount = getEffectiveArgumentCount(node, /*args*/ undefined, signature);
|
|
|
|
|
}
|
|
|
|
|
@@ -16582,7 +16596,7 @@ namespace ts {
|
|
|
|
|
}
|
|
|
|
|
// Make sure require is not a local function
|
|
|
|
|
if (!isIdentifier(node.expression)) throw Debug.fail();
|
|
|
|
|
const resolvedRequire = resolveName(node.expression, node.expression.escapedText, SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined);
|
|
|
|
|
const resolvedRequire = resolveName(node.expression, node.expression.escapedText, SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true);
|
|
|
|
|
if (!resolvedRequire) {
|
|
|
|
|
// project does not contain symbol named 'require' - assume commonjs require
|
|
|
|
|
return true;
|
|
|
|
|
@@ -19579,8 +19593,11 @@ namespace ts {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function markEntityNameOrEntityExpressionAsReference(typeName: EntityNameOrEntityNameExpression) {
|
|
|
|
|
const rootName = typeName && getFirstIdentifier(typeName);
|
|
|
|
|
const rootSymbol = rootName && resolveName(rootName, rootName.escapedText, (typeName.kind === SyntaxKind.Identifier ? SymbolFlags.Type : SymbolFlags.Namespace) | SymbolFlags.Alias, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined);
|
|
|
|
|
if (!typeName) return;
|
|
|
|
|
|
|
|
|
|
const rootName = getFirstIdentifier(typeName);
|
|
|
|
|
const meaning = (typeName.kind === SyntaxKind.Identifier ? SymbolFlags.Type : SymbolFlags.Namespace) | SymbolFlags.Alias;
|
|
|
|
|
const rootSymbol = resolveName(rootName, rootName.escapedText, meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isRefernce*/ true);
|
|
|
|
|
if (rootSymbol
|
|
|
|
|
&& rootSymbol.flags & SymbolFlags.Alias
|
|
|
|
|
&& symbolIsValue(rootSymbol)
|
|
|
|
|
@@ -19874,7 +19891,7 @@ namespace ts {
|
|
|
|
|
!isParameterPropertyDeclaration(parameter) &&
|
|
|
|
|
!parameterIsThisKeyword(parameter) &&
|
|
|
|
|
!parameterNameStartsWithUnderscore(name)) {
|
|
|
|
|
error(name, Diagnostics._0_is_declared_but_never_used, unescapeLeadingUnderscores(local.escapedName));
|
|
|
|
|
error(name, Diagnostics._0_is_declared_but_its_value_is_never_read, unescapeLeadingUnderscores(local.escapedName));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (compilerOptions.noUnusedLocals) {
|
|
|
|
|
@@ -19903,7 +19920,7 @@ namespace ts {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!isRemovedPropertyFromObjectSpread(node.kind === SyntaxKind.Identifier ? node.parent : node)) {
|
|
|
|
|
error(node, Diagnostics._0_is_declared_but_never_used, name);
|
|
|
|
|
error(node, Diagnostics._0_is_declared_but_its_value_is_never_read, name);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -19921,13 +19938,13 @@ namespace ts {
|
|
|
|
|
for (const member of node.members) {
|
|
|
|
|
if (member.kind === SyntaxKind.MethodDeclaration || member.kind === SyntaxKind.PropertyDeclaration) {
|
|
|
|
|
if (!member.symbol.isReferenced && hasModifier(member, ModifierFlags.Private)) {
|
|
|
|
|
error(member.name, Diagnostics._0_is_declared_but_never_used, unescapeLeadingUnderscores(member.symbol.escapedName));
|
|
|
|
|
error(member.name, Diagnostics._0_is_declared_but_its_value_is_never_read, unescapeLeadingUnderscores(member.symbol.escapedName));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (member.kind === SyntaxKind.Constructor) {
|
|
|
|
|
for (const parameter of (<ConstructorDeclaration>member).parameters) {
|
|
|
|
|
if (!parameter.symbol.isReferenced && hasModifier(parameter, ModifierFlags.Private)) {
|
|
|
|
|
error(parameter.name, Diagnostics.Property_0_is_declared_but_never_used, unescapeLeadingUnderscores(parameter.symbol.escapedName));
|
|
|
|
|
error(parameter.name, Diagnostics.Property_0_is_declared_but_its_value_is_never_read, unescapeLeadingUnderscores(parameter.symbol.escapedName));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@@ -19948,7 +19965,7 @@ namespace ts {
|
|
|
|
|
}
|
|
|
|
|
for (const typeParameter of node.typeParameters) {
|
|
|
|
|
if (!getMergedSymbol(typeParameter.symbol).isReferenced) {
|
|
|
|
|
error(typeParameter.name, Diagnostics._0_is_declared_but_never_used, unescapeLeadingUnderscores(typeParameter.symbol.escapedName));
|
|
|
|
|
error(typeParameter.name, Diagnostics._0_is_declared_but_its_value_is_never_read, unescapeLeadingUnderscores(typeParameter.symbol.escapedName));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@@ -20179,7 +20196,7 @@ namespace ts {
|
|
|
|
|
const symbol = getSymbolOfNode(node);
|
|
|
|
|
if (symbol.flags & SymbolFlags.FunctionScopedVariable) {
|
|
|
|
|
if (!isIdentifier(node.name)) throw Debug.fail();
|
|
|
|
|
const localDeclarationSymbol = resolveName(node, node.name.escapedText, SymbolFlags.Variable, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined);
|
|
|
|
|
const localDeclarationSymbol = resolveName(node, node.name.escapedText, SymbolFlags.Variable, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false);
|
|
|
|
|
if (localDeclarationSymbol &&
|
|
|
|
|
localDeclarationSymbol !== symbol &&
|
|
|
|
|
localDeclarationSymbol.flags & SymbolFlags.BlockScopedVariable) {
|
|
|
|
|
@@ -20234,7 +20251,7 @@ namespace ts {
|
|
|
|
|
else if (n.kind === SyntaxKind.Identifier) {
|
|
|
|
|
// check FunctionLikeDeclaration.locals (stores parameters\function local variable)
|
|
|
|
|
// if it contains entry with a specified name
|
|
|
|
|
const symbol = resolveName(n, (<Identifier>n).escapedText, SymbolFlags.Value | SymbolFlags.Alias, /*nameNotFoundMessage*/undefined, /*nameArg*/undefined);
|
|
|
|
|
const symbol = resolveName(n, (<Identifier>n).escapedText, SymbolFlags.Value | SymbolFlags.Alias, /*nameNotFoundMessage*/undefined, /*nameArg*/undefined, /*isUse*/ false);
|
|
|
|
|
if (!symbol || symbol === unknownSymbol || !symbol.valueDeclaration) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
@@ -20318,7 +20335,7 @@ namespace ts {
|
|
|
|
|
const parentType = getTypeForBindingElementParent(parent);
|
|
|
|
|
const name = node.propertyName || <Identifier>node.name;
|
|
|
|
|
const property = getPropertyOfType(parentType, getTextOfPropertyName(name));
|
|
|
|
|
markPropertyAsReferenced(property);
|
|
|
|
|
markPropertyAsReferenced(property, /*nodeForCheckWriteOnly*/ undefined); // A destructuring is never a write-only reference.
|
|
|
|
|
if (parent.initializer && property) {
|
|
|
|
|
checkPropertyAccessibility(parent, parent.initializer, parentType, property);
|
|
|
|
|
}
|
|
|
|
|
@@ -22254,7 +22271,7 @@ namespace ts {
|
|
|
|
|
const exportedName = node.propertyName || node.name;
|
|
|
|
|
// find immediate value referenced by exported name (SymbolFlags.Alias is set so we don't chase down aliases)
|
|
|
|
|
const symbol = resolveName(exportedName, exportedName.escapedText, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias,
|
|
|
|
|
/*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined);
|
|
|
|
|
/*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true);
|
|
|
|
|
if (symbol && (symbol === undefinedSymbol || isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0])))) {
|
|
|
|
|
error(exportedName, Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, unescapeLeadingUnderscores(exportedName.escapedText));
|
|
|
|
|
}
|
|
|
|
|
@@ -23359,7 +23376,7 @@ namespace ts {
|
|
|
|
|
const container = getEnclosingBlockScopeContainer(symbol.valueDeclaration);
|
|
|
|
|
if (isStatementWithLocals(container)) {
|
|
|
|
|
const nodeLinks = getNodeLinks(symbol.valueDeclaration);
|
|
|
|
|
if (!!resolveName(container.parent, symbol.escapedName, SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined)) {
|
|
|
|
|
if (resolveName(container.parent, symbol.escapedName, SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)) {
|
|
|
|
|
// redeclaration - always should be renamed
|
|
|
|
|
links.isDeclarationWithCollidingName = true;
|
|
|
|
|
}
|
|
|
|
|
@@ -23669,7 +23686,7 @@ namespace ts {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return resolveName(location, reference.escapedText, SymbolFlags.Value | SymbolFlags.ExportValue | SymbolFlags.Alias, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined);
|
|
|
|
|
return resolveName(location, reference.escapedText, SymbolFlags.Value | SymbolFlags.ExportValue | SymbolFlags.Alias, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getReferencedValueDeclaration(reference: Identifier): Declaration {
|
|
|
|
|
@@ -23992,7 +24009,7 @@ namespace ts {
|
|
|
|
|
return quickResult;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let lastStatic: Node, lastPrivate: Node, lastProtected: Node, lastDeclare: Node, lastAsync: Node, lastReadonly: Node;
|
|
|
|
|
let lastStatic: Node, lastDeclare: Node, lastAsync: Node, lastReadonly: Node;
|
|
|
|
|
let flags = ModifierFlags.None;
|
|
|
|
|
for (const modifier of node.modifiers) {
|
|
|
|
|
if (modifier.kind !== SyntaxKind.ReadonlyKeyword) {
|
|
|
|
|
@@ -24014,13 +24031,6 @@ namespace ts {
|
|
|
|
|
case SyntaxKind.PrivateKeyword:
|
|
|
|
|
const text = visibilityToString(modifierToFlag(modifier.kind));
|
|
|
|
|
|
|
|
|
|
if (modifier.kind === SyntaxKind.ProtectedKeyword) {
|
|
|
|
|
lastProtected = modifier;
|
|
|
|
|
}
|
|
|
|
|
else if (modifier.kind === SyntaxKind.PrivateKeyword) {
|
|
|
|
|
lastPrivate = modifier;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (flags & ModifierFlags.AccessibilityModifier) {
|
|
|
|
|
return grammarErrorOnNode(modifier, Diagnostics.Accessibility_modifier_already_seen);
|
|
|
|
|
}
|
|
|
|
|
|