allow to use keywords as jsx identifiers

This commit is contained in:
Vladimir Matveev
2015-09-08 22:40:16 -07:00
parent 971c777031
commit aa29644c2a
6 changed files with 35 additions and 2 deletions

View File

@@ -12,6 +12,10 @@ namespace ts {
export function createNode(kind: SyntaxKind): Node {
return new (getNodeConstructor(kind))();
}
export function tokenIsIdentifierOrKeyword(token: SyntaxKind): boolean {
return token >= SyntaxKind.Identifier;
}
function visitNode<T>(cbNode: (node: Node) => T, node: Node): T {
if (node) {
@@ -4102,7 +4106,7 @@ namespace ts {
}
function isIdentifierOrKeyword() {
return token >= SyntaxKind.Identifier;
return tokenIsIdentifierOrKeyword(token);
}
function nextTokenIsIdentifierOrKeywordOnSameLine() {

View File

@@ -1590,7 +1590,7 @@ namespace ts {
// Scans a JSX identifier; these differ from normal identifiers in that
// they allow dashes
function scanJsxIdentifier(): SyntaxKind {
if (token === SyntaxKind.Identifier) {
if (tokenIsIdentifierOrKeyword(token)) {
let firstCharPosition = pos;
while (pos < end) {
let ch = text.charCodeAt(pos);