Skip to content

Commit

Permalink
Change certain hasDynamicName checks to check the SyntaxKind instead
Browse files Browse the repository at this point in the history
  • Loading branch information
JsonFreeman committed Feb 7, 2015
1 parent 9cb38fb commit 25fcbe2
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7243,7 +7243,7 @@ module ts {
}

function checkPropertyAssignment(node: PropertyAssignment, contextualMapper?: TypeMapper): Type {
if (hasDynamicName(node)) {
if (node.name.kind === SyntaxKind.ComputedPropertyName) {

This comment has been minimized.

Copy link
@yuit

yuit Feb 10, 2015

Contributor

Why not use hasDynamicName anymore? hasDynamicName seems to do similar functionality

This comment has been minimized.

Copy link
@JsonFreeman

JsonFreeman Feb 10, 2015

Author Contributor

I will leave a comment there. The reason is that hasDynamicName will skip the check if it is a well known symbol. But I want to do this check for all computed properties, including well known symbols.

checkComputedPropertyName(<ComputedPropertyName>node.name);
}

Expand All @@ -7254,7 +7254,7 @@ module ts {
// Grammar checking
checkGrammarMethod(node);

if (hasDynamicName(node)) {
if (node.name.kind === SyntaxKind.ComputedPropertyName) {
checkComputedPropertyName(<ComputedPropertyName>node.name);
}

Expand Down Expand Up @@ -8066,12 +8066,13 @@ module ts {
function checkFunctionLikeDeclaration(node: FunctionLikeDeclaration): void {
checkSignatureDeclaration(node);

if (hasDynamicName(node)) {
if (node.name.kind === SyntaxKind.ComputedPropertyName) {
// This check will account for methods in class/interface declarations,
// as well as accessors in classes/object literals
checkComputedPropertyName(<ComputedPropertyName>node.name);
}
else {

if (!hasDynamicName(node)) {
// first we want to check the local symbol that contain this declaration
// - if node.localSymbol !== undefined - this is current declaration is exported and localSymbol points to the local symbol
// - if node.localSymbol === undefined - this node is non-exported so we can just pick the result of getSymbolOfNode
Expand Down Expand Up @@ -8300,12 +8301,11 @@ module ts {
function checkVariableLikeDeclaration(node: VariableLikeDeclaration) {
checkSourceElement(node.type);
// For a computed property, just check the initializer and exit
if (hasDynamicName(node)) {
if (node.name.kind === SyntaxKind.ComputedPropertyName) {
checkComputedPropertyName(<ComputedPropertyName>node.name);
if (node.initializer) {
checkExpressionCached(node.initializer);
}
return;
}
// For a binding pattern, check contained binding elements
if (isBindingPattern(node.name)) {
Expand Down

0 comments on commit 25fcbe2

Please sign in to comment.