fix(46512): allow to use tag names containing keywords with - (#46546)

This commit is contained in:
Oleksandr T 2021-11-03 00:12:10 +02:00 committed by GitHub
parent 33fe1b6ffc
commit b8f8fd7a3e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 216 additions and 0 deletions

View file

@ -2374,6 +2374,7 @@ namespace ts {
tokenValue = tokenValue.slice(0, -1);
pos--;
}
return getIdentifierToken();
}
return token;
}

View 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));

View file

@ -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))
);

View file

@ -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
);

View file

@ -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.
);

View 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));

View file

@ -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))
);

View file

@ -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
);

View 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>
);