Skip to content
Merged
Prev Previous commit
Next Next commit
Remove originalKeywordKind and jsDocCache from Identifier
  • Loading branch information
rbuckton committed Jan 9, 2023
commit a93401949baecbfe96307d54db635da474880a0b
10 changes: 6 additions & 4 deletions src/compiler/binder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ import {
SpreadElement,
Statement,
StringLiteral,
stringToToken,
SuperExpression,
SwitchStatement,
Symbol,
Expand Down Expand Up @@ -2421,13 +2422,14 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
!isIdentifierName(node)) {

// strict mode identifiers
const originalKeywordKind = stringToToken(node.escapedText as string);
if (inStrictMode &&
node.originalKeywordKind! >= SyntaxKind.FirstFutureReservedWord &&
node.originalKeywordKind! <= SyntaxKind.LastFutureReservedWord) {
originalKeywordKind! >= SyntaxKind.FirstFutureReservedWord &&
originalKeywordKind! <= SyntaxKind.LastFutureReservedWord) {
file.bindDiagnostics.push(createDiagnosticForNode(node,
getStrictModeIdentifierMessage(node), declarationNameToString(node)));
}
else if (node.originalKeywordKind === SyntaxKind.AwaitKeyword) {
else if (originalKeywordKind === SyntaxKind.AwaitKeyword) {
if (isExternalModule(file) && isInTopLevelContext(node)) {
file.bindDiagnostics.push(createDiagnosticForNode(node,
Diagnostics.Identifier_expected_0_is_a_reserved_word_at_the_top_level_of_a_module,
Expand All @@ -2439,7 +2441,7 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
declarationNameToString(node)));
}
}
else if (node.originalKeywordKind === SyntaxKind.YieldKeyword && node.flags & NodeFlags.YieldContext) {
else if (originalKeywordKind === SyntaxKind.YieldKeyword && node.flags & NodeFlags.YieldContext) {
file.bindDiagnostics.push(createDiagnosticForNode(node,
Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here,
declarationNameToString(node)));
Expand Down
23 changes: 13 additions & 10 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -925,6 +925,7 @@ import {
StringLiteralLike,
StringLiteralType,
StringMappingType,
stringToToken,
stripQuotes,
StructuredType,
SubstitutionType,
Expand Down Expand Up @@ -23209,15 +23210,17 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
break;
case SyntaxKind.Parameter:
const param = declaration as ParameterDeclaration;
if (isIdentifier(param.name) &&
(isCallSignatureDeclaration(param.parent) || isMethodSignature(param.parent) || isFunctionTypeNode(param.parent)) &&
param.parent.parameters.indexOf(param) > -1 &&
(resolveName(param, param.name.escapedText, SymbolFlags.Type, undefined, param.name.escapedText, /*isUse*/ true) ||
param.name.originalKeywordKind && isTypeNodeKind(param.name.originalKeywordKind))) {
const newName = "arg" + param.parent.parameters.indexOf(param);
const typeName = declarationNameToString(param.name) + (param.dotDotDotToken ? "[]" : "");
errorOrSuggestion(noImplicitAny, declaration, Diagnostics.Parameter_has_a_name_but_no_type_Did_you_mean_0_Colon_1, newName, typeName);
return;
if (isIdentifier(param.name)) {
const originalKeywordKind = stringToToken(param.name.escapedText as string);1
if ((isCallSignatureDeclaration(param.parent) || isMethodSignature(param.parent) || isFunctionTypeNode(param.parent)) &&
param.parent.parameters.indexOf(param) > -1 &&
(resolveName(param, param.name.escapedText, SymbolFlags.Type, undefined, param.name.escapedText, /*isUse*/ true) ||
originalKeywordKind && isTypeNodeKind(originalKeywordKind))) {
const newName = "arg" + param.parent.parameters.indexOf(param);
const typeName = declarationNameToString(param.name) + (param.dotDotDotToken ? "[]" : "");
errorOrSuggestion(noImplicitAny, declaration, Diagnostics.Parameter_has_a_name_but_no_type_Did_you_mean_0_Colon_1, newName, typeName);
return;
}
}
diagnostic = (declaration as ParameterDeclaration).dotDotDotToken ?
noImplicitAny ? Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : Diagnostics.Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage :
Expand Down Expand Up @@ -46867,7 +46870,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {

function checkGrammarNameInLetOrConstDeclarations(name: Identifier | BindingPattern): boolean {
if (name.kind === SyntaxKind.Identifier) {
if (name.originalKeywordKind === SyntaxKind.LetKeyword) {
if (name.escapedText === "let") {
return grammarErrorOnNode(name, Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations);
}
}
Expand Down
Loading