Skip to content

Commit c73fdc8

Browse files
authored
Allow JSXAttribute to be IdentifierName (microsoft#17466)
* Add test * Fix microsoft#17452 - Allow JSXAttribute names to be IdentifierNames * Move check into isIdentifierName
1 parent 32d9292 commit c73fdc8

File tree

5 files changed

+78
-1
lines changed

5 files changed

+78
-1
lines changed

src/compiler/utilities.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1781,7 +1781,8 @@ namespace ts {
17811781
// Property name in binding element or import specifier
17821782
return (<BindingElement | ImportSpecifier>parent).propertyName === node;
17831783
case SyntaxKind.ExportSpecifier:
1784-
// Any name in an export specifier
1784+
case SyntaxKind.JsxAttribute:
1785+
// Any name in an export specifier or JSX Attribute
17851786
return true;
17861787
}
17871788
return false;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//// [index.tsx]
2+
declare namespace JSX {
3+
interface Element { }
4+
interface IntrinsicElements {
5+
div: {
6+
static?: boolean;
7+
};
8+
}
9+
}
10+
export default <div static={true} />;
11+
12+
13+
//// [index.jsx]
14+
"use strict";
15+
exports.__esModule = true;
16+
exports["default"] = <div static={true}/>;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
=== tests/cases/compiler/index.tsx ===
2+
declare namespace JSX {
3+
>JSX : Symbol(JSX, Decl(index.tsx, 0, 0))
4+
5+
interface Element { }
6+
>Element : Symbol(Element, Decl(index.tsx, 0, 23))
7+
8+
interface IntrinsicElements {
9+
>IntrinsicElements : Symbol(IntrinsicElements, Decl(index.tsx, 1, 25))
10+
11+
div: {
12+
>div : Symbol(IntrinsicElements.div, Decl(index.tsx, 2, 33))
13+
14+
static?: boolean;
15+
>static : Symbol(static, Decl(index.tsx, 3, 14))
16+
17+
};
18+
}
19+
}
20+
export default <div static={true} />;
21+
>div : Symbol(unknown)
22+
>static : Symbol(static, Decl(index.tsx, 8, 19))
23+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
=== tests/cases/compiler/index.tsx ===
2+
declare namespace JSX {
3+
>JSX : any
4+
5+
interface Element { }
6+
>Element : Element
7+
8+
interface IntrinsicElements {
9+
>IntrinsicElements : IntrinsicElements
10+
11+
div: {
12+
>div : { static?: boolean; }
13+
14+
static?: boolean;
15+
>static : boolean
16+
17+
};
18+
}
19+
}
20+
export default <div static={true} />;
21+
><div static={true} /> : any
22+
>div : any
23+
>static : boolean
24+
>true : true
25+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// @jsx: preserve
2+
3+
// @filename: index.tsx
4+
declare namespace JSX {
5+
interface Element { }
6+
interface IntrinsicElements {
7+
div: {
8+
static?: boolean;
9+
};
10+
}
11+
}
12+
export default <div static={true} />;

0 commit comments

Comments
 (0)