fix(46512): allow to use tag names containing keywords with - (#46546)
This commit is contained in:
parent
33fe1b6ffc
commit
b8f8fd7a3e
|
@ -2374,6 +2374,7 @@ namespace ts {
|
|||
tokenValue = tokenValue.slice(0, -1);
|
||||
pos--;
|
||||
}
|
||||
return getIdentifierToken();
|
||||
}
|
||||
return token;
|
||||
}
|
||||
|
|
20
tests/baselines/reference/jsxParsingError4(strict=false).js
Normal file
20
tests/baselines/reference/jsxParsingError4(strict=false).js
Normal file
|
@ -0,0 +1,20 @@
|
|||
//// [a.tsx]
|
||||
declare const React: any
|
||||
declare namespace JSX {
|
||||
interface IntrinsicElements {
|
||||
[k: string]: any
|
||||
}
|
||||
}
|
||||
|
||||
const a = (
|
||||
<public-foo></public-foo>
|
||||
);
|
||||
|
||||
const b = (
|
||||
<public></public>
|
||||
);
|
||||
|
||||
|
||||
//// [a.js]
|
||||
var a = (React.createElement("public-foo", null));
|
||||
var b = (React.createElement("public", null));
|
|
@ -0,0 +1,33 @@
|
|||
=== tests/cases/conformance/jsx/a.tsx ===
|
||||
declare const React: any
|
||||
>React : Symbol(React, Decl(a.tsx, 0, 13))
|
||||
|
||||
declare namespace JSX {
|
||||
>JSX : Symbol(JSX, Decl(a.tsx, 0, 24))
|
||||
|
||||
interface IntrinsicElements {
|
||||
>IntrinsicElements : Symbol(IntrinsicElements, Decl(a.tsx, 1, 23))
|
||||
|
||||
[k: string]: any
|
||||
>k : Symbol(k, Decl(a.tsx, 3, 9))
|
||||
}
|
||||
}
|
||||
|
||||
const a = (
|
||||
>a : Symbol(a, Decl(a.tsx, 7, 5))
|
||||
|
||||
<public-foo></public-foo>
|
||||
>public-foo : Symbol(JSX.IntrinsicElements, Decl(a.tsx, 1, 23))
|
||||
>public-foo : Symbol(JSX.IntrinsicElements, Decl(a.tsx, 1, 23))
|
||||
|
||||
);
|
||||
|
||||
const b = (
|
||||
>b : Symbol(b, Decl(a.tsx, 11, 5))
|
||||
|
||||
<public></public>
|
||||
>public : Symbol(JSX.IntrinsicElements, Decl(a.tsx, 1, 23))
|
||||
>public : Symbol(JSX.IntrinsicElements, Decl(a.tsx, 1, 23))
|
||||
|
||||
);
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
=== tests/cases/conformance/jsx/a.tsx ===
|
||||
declare const React: any
|
||||
>React : any
|
||||
|
||||
declare namespace JSX {
|
||||
interface IntrinsicElements {
|
||||
[k: string]: any
|
||||
>k : string
|
||||
}
|
||||
}
|
||||
|
||||
const a = (
|
||||
>a : error
|
||||
>( <public-foo></public-foo>) : error
|
||||
|
||||
<public-foo></public-foo>
|
||||
><public-foo></public-foo> : error
|
||||
>public-foo : any
|
||||
>public-foo : any
|
||||
|
||||
);
|
||||
|
||||
const b = (
|
||||
>b : error
|
||||
>( <public></public>) : error
|
||||
|
||||
<public></public>
|
||||
><public></public> : error
|
||||
>public : any
|
||||
>public : any
|
||||
|
||||
);
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
tests/cases/conformance/jsx/a.tsx(13,4): error TS1212: Identifier expected. 'public' is a reserved word in strict mode.
|
||||
tests/cases/conformance/jsx/a.tsx(13,13): error TS1212: Identifier expected. 'public' is a reserved word in strict mode.
|
||||
|
||||
|
||||
==== tests/cases/conformance/jsx/a.tsx (2 errors) ====
|
||||
declare const React: any
|
||||
declare namespace JSX {
|
||||
interface IntrinsicElements {
|
||||
[k: string]: any
|
||||
}
|
||||
}
|
||||
|
||||
const a = (
|
||||
<public-foo></public-foo>
|
||||
);
|
||||
|
||||
const b = (
|
||||
<public></public>
|
||||
~~~~~~
|
||||
!!! error TS1212: Identifier expected. 'public' is a reserved word in strict mode.
|
||||
~~~~~~
|
||||
!!! error TS1212: Identifier expected. 'public' is a reserved word in strict mode.
|
||||
);
|
||||
|
21
tests/baselines/reference/jsxParsingError4(strict=true).js
Normal file
21
tests/baselines/reference/jsxParsingError4(strict=true).js
Normal file
|
@ -0,0 +1,21 @@
|
|||
//// [a.tsx]
|
||||
declare const React: any
|
||||
declare namespace JSX {
|
||||
interface IntrinsicElements {
|
||||
[k: string]: any
|
||||
}
|
||||
}
|
||||
|
||||
const a = (
|
||||
<public-foo></public-foo>
|
||||
);
|
||||
|
||||
const b = (
|
||||
<public></public>
|
||||
);
|
||||
|
||||
|
||||
//// [a.js]
|
||||
"use strict";
|
||||
var a = (React.createElement("public-foo", null));
|
||||
var b = (React.createElement("public", null));
|
|
@ -0,0 +1,33 @@
|
|||
=== tests/cases/conformance/jsx/a.tsx ===
|
||||
declare const React: any
|
||||
>React : Symbol(React, Decl(a.tsx, 0, 13))
|
||||
|
||||
declare namespace JSX {
|
||||
>JSX : Symbol(JSX, Decl(a.tsx, 0, 24))
|
||||
|
||||
interface IntrinsicElements {
|
||||
>IntrinsicElements : Symbol(IntrinsicElements, Decl(a.tsx, 1, 23))
|
||||
|
||||
[k: string]: any
|
||||
>k : Symbol(k, Decl(a.tsx, 3, 9))
|
||||
}
|
||||
}
|
||||
|
||||
const a = (
|
||||
>a : Symbol(a, Decl(a.tsx, 7, 5))
|
||||
|
||||
<public-foo></public-foo>
|
||||
>public-foo : Symbol(JSX.IntrinsicElements, Decl(a.tsx, 1, 23))
|
||||
>public-foo : Symbol(JSX.IntrinsicElements, Decl(a.tsx, 1, 23))
|
||||
|
||||
);
|
||||
|
||||
const b = (
|
||||
>b : Symbol(b, Decl(a.tsx, 11, 5))
|
||||
|
||||
<public></public>
|
||||
>public : Symbol(JSX.IntrinsicElements, Decl(a.tsx, 1, 23))
|
||||
>public : Symbol(JSX.IntrinsicElements, Decl(a.tsx, 1, 23))
|
||||
|
||||
);
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
=== tests/cases/conformance/jsx/a.tsx ===
|
||||
declare const React: any
|
||||
>React : any
|
||||
|
||||
declare namespace JSX {
|
||||
interface IntrinsicElements {
|
||||
[k: string]: any
|
||||
>k : string
|
||||
}
|
||||
}
|
||||
|
||||
const a = (
|
||||
>a : any
|
||||
>( <public-foo></public-foo>) : any
|
||||
|
||||
<public-foo></public-foo>
|
||||
><public-foo></public-foo> : any
|
||||
>public-foo : any
|
||||
>public-foo : any
|
||||
|
||||
);
|
||||
|
||||
const b = (
|
||||
>b : any
|
||||
>( <public></public>) : any
|
||||
|
||||
<public></public>
|
||||
><public></public> : any
|
||||
>public : any
|
||||
>public : any
|
||||
|
||||
);
|
||||
|
18
tests/cases/conformance/jsx/jsxParsingError4.tsx
Normal file
18
tests/cases/conformance/jsx/jsxParsingError4.tsx
Normal file
|
@ -0,0 +1,18 @@
|
|||
// @strict: true, false
|
||||
// @jsx: react
|
||||
// @filename: a.tsx
|
||||
|
||||
declare const React: any
|
||||
declare namespace JSX {
|
||||
interface IntrinsicElements {
|
||||
[k: string]: any
|
||||
}
|
||||
}
|
||||
|
||||
const a = (
|
||||
<public-foo></public-foo>
|
||||
);
|
||||
|
||||
const b = (
|
||||
<public></public>
|
||||
);
|
Loading…
Reference in a new issue