mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-08 08:14:51 -06:00
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:
parent
32d9292a83
commit
c73fdc87d0
@ -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;
|
||||
|
||||
16
tests/baselines/reference/jsxPropsAsIdentifierNames.js
Normal file
16
tests/baselines/reference/jsxPropsAsIdentifierNames.js
Normal 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}/>;
|
||||
23
tests/baselines/reference/jsxPropsAsIdentifierNames.symbols
Normal file
23
tests/baselines/reference/jsxPropsAsIdentifierNames.symbols
Normal 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))
|
||||
|
||||
25
tests/baselines/reference/jsxPropsAsIdentifierNames.types
Normal file
25
tests/baselines/reference/jsxPropsAsIdentifierNames.types
Normal 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
|
||||
|
||||
12
tests/cases/compiler/jsxPropsAsIdentifierNames.tsx
Normal file
12
tests/cases/compiler/jsxPropsAsIdentifierNames.tsx
Normal 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} />;
|
||||
Loading…
x
Reference in New Issue
Block a user