Allow JSXAttribute to be IdentifierName (#17466)

* Add test

* Fix #17452 - Allow JSXAttribute names to be IdentifierNames

* Move check into isIdentifierName
This commit is contained in:
Wesley Wigham 2017-07-31 13:03:26 -07:00 committed by GitHub
parent 32d9292a83
commit c73fdc87d0
5 changed files with 78 additions and 1 deletions

View File

@ -1781,7 +1781,8 @@ namespace ts {
// Property name in binding element or import specifier
return (<BindingElement | ImportSpecifier>parent).propertyName === node;
case SyntaxKind.ExportSpecifier:
// Any name in an export specifier
case SyntaxKind.JsxAttribute:
// Any name in an export specifier or JSX Attribute
return true;
}
return false;

View File

@ -0,0 +1,16 @@
//// [index.tsx]
declare namespace JSX {
interface Element { }
interface IntrinsicElements {
div: {
static?: boolean;
};
}
}
export default <div static={true} />;
//// [index.jsx]
"use strict";
exports.__esModule = true;
exports["default"] = <div static={true}/>;

View File

@ -0,0 +1,23 @@
=== tests/cases/compiler/index.tsx ===
declare namespace JSX {
>JSX : Symbol(JSX, Decl(index.tsx, 0, 0))
interface Element { }
>Element : Symbol(Element, Decl(index.tsx, 0, 23))
interface IntrinsicElements {
>IntrinsicElements : Symbol(IntrinsicElements, Decl(index.tsx, 1, 25))
div: {
>div : Symbol(IntrinsicElements.div, Decl(index.tsx, 2, 33))
static?: boolean;
>static : Symbol(static, Decl(index.tsx, 3, 14))
};
}
}
export default <div static={true} />;
>div : Symbol(unknown)
>static : Symbol(static, Decl(index.tsx, 8, 19))

View File

@ -0,0 +1,25 @@
=== tests/cases/compiler/index.tsx ===
declare namespace JSX {
>JSX : any
interface Element { }
>Element : Element
interface IntrinsicElements {
>IntrinsicElements : IntrinsicElements
div: {
>div : { static?: boolean; }
static?: boolean;
>static : boolean
};
}
}
export default <div static={true} />;
><div static={true} /> : any
>div : any
>static : boolean
>true : true

View File

@ -0,0 +1,12 @@
// @jsx: preserve
// @filename: index.tsx
declare namespace JSX {
interface Element { }
interface IntrinsicElements {
div: {
static?: boolean;
};
}
}
export default <div static={true} />;