Skip to content

Commit e5d648c

Browse files
committed
Add actual baseline for a problem with global namespace being preferred over config implicit one
1 parent d728297 commit e5d648c

8 files changed

+781
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
//// [tests/cases/compiler/jsxNamespaceImplicitImportJSXNamespace2.tsx] ////
2+
3+
//// [index.d.ts]
4+
export { EmotionJSX as JSX } from './jsx-namespace'
5+
6+
//// [jsx-namespace.d.ts]
7+
import 'react'
8+
9+
type WithConditionalCSSProp<P> = 'className' extends keyof P
10+
? (P extends { className?: string } ? P & { css?: string } : P)
11+
: P
12+
13+
type ReactJSXElement = JSX.Element
14+
type ReactJSXElementClass = JSX.ElementClass
15+
type ReactJSXElementAttributesProperty = JSX.ElementAttributesProperty
16+
type ReactJSXElementChildrenAttribute = JSX.ElementChildrenAttribute
17+
type ReactJSXLibraryManagedAttributes<C, P> = JSX.LibraryManagedAttributes<C, P>
18+
type ReactJSXIntrinsicAttributes = JSX.IntrinsicAttributes
19+
type ReactJSXIntrinsicClassAttributes<T> = JSX.IntrinsicClassAttributes<T>
20+
type ReactJSXIntrinsicElements = JSX.IntrinsicElements
21+
22+
export namespace EmotionJSX {
23+
interface Element extends ReactJSXElement {}
24+
interface ElementClass extends ReactJSXElementClass {}
25+
interface ElementAttributesProperty
26+
extends ReactJSXElementAttributesProperty {}
27+
interface ElementChildrenAttribute extends ReactJSXElementChildrenAttribute {}
28+
29+
type LibraryManagedAttributes<C, P> = WithConditionalCSSProp<P> &
30+
ReactJSXLibraryManagedAttributes<C, P>
31+
32+
interface IntrinsicAttributes extends ReactJSXIntrinsicAttributes {}
33+
interface IntrinsicClassAttributes<T>
34+
extends ReactJSXIntrinsicClassAttributes<T> {}
35+
36+
type IntrinsicElements = {
37+
[K in keyof ReactJSXIntrinsicElements]: ReactJSXIntrinsicElements[K] & {
38+
css?: string
39+
}
40+
}
41+
}
42+
43+
//// [index.tsx]
44+
/// <reference path="/.lib/react16.d.ts" />
45+
export const Comp = () => <div css="color: hotpink;"></div>;
46+
47+
48+
//// [index.js]
49+
"use strict";
50+
exports.__esModule = true;
51+
exports.Comp = void 0;
52+
var jsx_runtime_1 = require("@emotion/react/jsx-runtime");
53+
/// <reference path="react16.d.ts" />
54+
var Comp = function () { return jsx_runtime_1.jsx("div", { css: "color: hotpink;" }, void 0); };
55+
exports.Comp = Comp;
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
=== /index.tsx ===
2+
/// <reference path="react16.d.ts" />
3+
export const Comp = () => <div css="color: hotpink;"></div>;
4+
>Comp : Symbol(Comp, Decl(index.tsx, 1, 12))
5+
>div : Symbol(div, Decl(react16.d.ts, 2420, 114))
6+
>css : Symbol(css, Decl(index.tsx, 1, 30))
7+
>div : Symbol(div, Decl(react16.d.ts, 2420, 114))
8+
9+
=== /node_modules/@emotion/react/jsx-runtime/index.d.ts ===
10+
export { EmotionJSX as JSX } from './jsx-namespace'
11+
>EmotionJSX : Symbol(EmotionJSX, Decl(jsx-namespace.d.ts, 13, 54))
12+
>JSX : Symbol(JSX, Decl(index.d.ts, 0, 8))
13+
14+
=== /node_modules/@emotion/react/jsx-runtime/jsx-namespace.d.ts ===
15+
import 'react'
16+
17+
type WithConditionalCSSProp<P> = 'className' extends keyof P
18+
>WithConditionalCSSProp : Symbol(WithConditionalCSSProp, Decl(jsx-namespace.d.ts, 0, 14))
19+
>P : Symbol(P, Decl(jsx-namespace.d.ts, 2, 28))
20+
>P : Symbol(P, Decl(jsx-namespace.d.ts, 2, 28))
21+
22+
? (P extends { className?: string } ? P & { css?: string } : P)
23+
>P : Symbol(P, Decl(jsx-namespace.d.ts, 2, 28))
24+
>className : Symbol(className, Decl(jsx-namespace.d.ts, 3, 16))
25+
>P : Symbol(P, Decl(jsx-namespace.d.ts, 2, 28))
26+
>css : Symbol(css, Decl(jsx-namespace.d.ts, 3, 45))
27+
>P : Symbol(P, Decl(jsx-namespace.d.ts, 2, 28))
28+
29+
: P
30+
>P : Symbol(P, Decl(jsx-namespace.d.ts, 2, 28))
31+
32+
type ReactJSXElement = JSX.Element
33+
>ReactJSXElement : Symbol(ReactJSXElement, Decl(jsx-namespace.d.ts, 4, 5))
34+
>JSX : Symbol(JSX, Decl(react16.d.ts, 2367, 12))
35+
>Element : Symbol(JSX.Element, Decl(react16.d.ts, 2368, 23))
36+
37+
type ReactJSXElementClass = JSX.ElementClass
38+
>ReactJSXElementClass : Symbol(ReactJSXElementClass, Decl(jsx-namespace.d.ts, 6, 34))
39+
>JSX : Symbol(JSX, Decl(react16.d.ts, 2367, 12))
40+
>ElementClass : Symbol(JSX.ElementClass, Decl(react16.d.ts, 2370, 65))
41+
42+
type ReactJSXElementAttributesProperty = JSX.ElementAttributesProperty
43+
>ReactJSXElementAttributesProperty : Symbol(ReactJSXElementAttributesProperty, Decl(jsx-namespace.d.ts, 7, 44))
44+
>JSX : Symbol(JSX, Decl(react16.d.ts, 2367, 12))
45+
>ElementAttributesProperty : Symbol(JSX.ElementAttributesProperty, Decl(react16.d.ts, 2373, 13))
46+
47+
type ReactJSXElementChildrenAttribute = JSX.ElementChildrenAttribute
48+
>ReactJSXElementChildrenAttribute : Symbol(ReactJSXElementChildrenAttribute, Decl(jsx-namespace.d.ts, 8, 70))
49+
>JSX : Symbol(JSX, Decl(react16.d.ts, 2367, 12))
50+
>ElementChildrenAttribute : Symbol(JSX.ElementChildrenAttribute, Decl(react16.d.ts, 2374, 62))
51+
52+
type ReactJSXLibraryManagedAttributes<C, P> = JSX.LibraryManagedAttributes<C, P>
53+
>ReactJSXLibraryManagedAttributes : Symbol(ReactJSXLibraryManagedAttributes, Decl(jsx-namespace.d.ts, 9, 68))
54+
>C : Symbol(C, Decl(jsx-namespace.d.ts, 10, 38))
55+
>P : Symbol(P, Decl(jsx-namespace.d.ts, 10, 40))
56+
>JSX : Symbol(JSX, Decl(react16.d.ts, 2367, 12))
57+
>LibraryManagedAttributes : Symbol(JSX.LibraryManagedAttributes, Decl(react16.d.ts, 2375, 64))
58+
>C : Symbol(C, Decl(jsx-namespace.d.ts, 10, 38))
59+
>P : Symbol(P, Decl(jsx-namespace.d.ts, 10, 40))
60+
61+
type ReactJSXIntrinsicAttributes = JSX.IntrinsicAttributes
62+
>ReactJSXIntrinsicAttributes : Symbol(ReactJSXIntrinsicAttributes, Decl(jsx-namespace.d.ts, 10, 80))
63+
>JSX : Symbol(JSX, Decl(react16.d.ts, 2367, 12))
64+
>IntrinsicAttributes : Symbol(JSX.IntrinsicAttributes, Decl(react16.d.ts, 2383, 20))
65+
66+
type ReactJSXIntrinsicClassAttributes<T> = JSX.IntrinsicClassAttributes<T>
67+
>ReactJSXIntrinsicClassAttributes : Symbol(ReactJSXIntrinsicClassAttributes, Decl(jsx-namespace.d.ts, 11, 58))
68+
>T : Symbol(T, Decl(jsx-namespace.d.ts, 12, 38))
69+
>JSX : Symbol(JSX, Decl(react16.d.ts, 2367, 12))
70+
>IntrinsicClassAttributes : Symbol(JSX.IntrinsicClassAttributes, Decl(react16.d.ts, 2386, 70))
71+
>T : Symbol(T, Decl(jsx-namespace.d.ts, 12, 38))
72+
73+
type ReactJSXIntrinsicElements = JSX.IntrinsicElements
74+
>ReactJSXIntrinsicElements : Symbol(ReactJSXIntrinsicElements, Decl(jsx-namespace.d.ts, 12, 74))
75+
>JSX : Symbol(JSX, Decl(react16.d.ts, 2367, 12))
76+
>IntrinsicElements : Symbol(JSX.IntrinsicElements, Decl(react16.d.ts, 2388, 86))
77+
78+
export namespace EmotionJSX {
79+
>EmotionJSX : Symbol(EmotionJSX, Decl(jsx-namespace.d.ts, 13, 54))
80+
81+
interface Element extends ReactJSXElement {}
82+
>Element : Symbol(Element, Decl(jsx-namespace.d.ts, 15, 29))
83+
>ReactJSXElement : Symbol(ReactJSXElement, Decl(jsx-namespace.d.ts, 4, 5))
84+
85+
interface ElementClass extends ReactJSXElementClass {}
86+
>ElementClass : Symbol(ElementClass, Decl(jsx-namespace.d.ts, 16, 46))
87+
>ReactJSXElementClass : Symbol(ReactJSXElementClass, Decl(jsx-namespace.d.ts, 6, 34))
88+
89+
interface ElementAttributesProperty
90+
>ElementAttributesProperty : Symbol(ElementAttributesProperty, Decl(jsx-namespace.d.ts, 17, 56))
91+
92+
extends ReactJSXElementAttributesProperty {}
93+
>ReactJSXElementAttributesProperty : Symbol(ReactJSXElementAttributesProperty, Decl(jsx-namespace.d.ts, 7, 44))
94+
95+
interface ElementChildrenAttribute extends ReactJSXElementChildrenAttribute {}
96+
>ElementChildrenAttribute : Symbol(ElementChildrenAttribute, Decl(jsx-namespace.d.ts, 19, 48))
97+
>ReactJSXElementChildrenAttribute : Symbol(ReactJSXElementChildrenAttribute, Decl(jsx-namespace.d.ts, 8, 70))
98+
99+
type LibraryManagedAttributes<C, P> = WithConditionalCSSProp<P> &
100+
>LibraryManagedAttributes : Symbol(LibraryManagedAttributes, Decl(jsx-namespace.d.ts, 20, 80))
101+
>C : Symbol(C, Decl(jsx-namespace.d.ts, 22, 32))
102+
>P : Symbol(P, Decl(jsx-namespace.d.ts, 22, 34))
103+
>WithConditionalCSSProp : Symbol(WithConditionalCSSProp, Decl(jsx-namespace.d.ts, 0, 14))
104+
>P : Symbol(P, Decl(jsx-namespace.d.ts, 22, 34))
105+
106+
ReactJSXLibraryManagedAttributes<C, P>
107+
>ReactJSXLibraryManagedAttributes : Symbol(ReactJSXLibraryManagedAttributes, Decl(jsx-namespace.d.ts, 9, 68))
108+
>C : Symbol(C, Decl(jsx-namespace.d.ts, 22, 32))
109+
>P : Symbol(P, Decl(jsx-namespace.d.ts, 22, 34))
110+
111+
interface IntrinsicAttributes extends ReactJSXIntrinsicAttributes {}
112+
>IntrinsicAttributes : Symbol(IntrinsicAttributes, Decl(jsx-namespace.d.ts, 23, 42))
113+
>ReactJSXIntrinsicAttributes : Symbol(ReactJSXIntrinsicAttributes, Decl(jsx-namespace.d.ts, 10, 80))
114+
115+
interface IntrinsicClassAttributes<T>
116+
>IntrinsicClassAttributes : Symbol(IntrinsicClassAttributes, Decl(jsx-namespace.d.ts, 25, 70))
117+
>T : Symbol(T, Decl(jsx-namespace.d.ts, 26, 37))
118+
119+
extends ReactJSXIntrinsicClassAttributes<T> {}
120+
>ReactJSXIntrinsicClassAttributes : Symbol(ReactJSXIntrinsicClassAttributes, Decl(jsx-namespace.d.ts, 11, 58))
121+
>T : Symbol(T, Decl(jsx-namespace.d.ts, 26, 37))
122+
123+
type IntrinsicElements = {
124+
>IntrinsicElements : Symbol(IntrinsicElements, Decl(jsx-namespace.d.ts, 27, 50))
125+
126+
[K in keyof ReactJSXIntrinsicElements]: ReactJSXIntrinsicElements[K] & {
127+
>K : Symbol(K, Decl(jsx-namespace.d.ts, 30, 5))
128+
>ReactJSXIntrinsicElements : Symbol(ReactJSXIntrinsicElements, Decl(jsx-namespace.d.ts, 12, 74))
129+
>ReactJSXIntrinsicElements : Symbol(ReactJSXIntrinsicElements, Decl(jsx-namespace.d.ts, 12, 74))
130+
>K : Symbol(K, Decl(jsx-namespace.d.ts, 30, 5))
131+
132+
css?: string
133+
>css : Symbol(css, Decl(jsx-namespace.d.ts, 30, 76))
134+
}
135+
}
136+
}
137+
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
=== /index.tsx ===
2+
/// <reference path="react16.d.ts" />
3+
export const Comp = () => <div css="color: hotpink;"></div>;
4+
>Comp : () => import("/node_modules/@emotion/react/jsx-runtime/jsx-namespace").EmotionJSX.Element
5+
>() => <div css="color: hotpink;"></div> : () => import("/node_modules/@emotion/react/jsx-runtime/jsx-namespace").EmotionJSX.Element
6+
><div css="color: hotpink;"></div> : import("/node_modules/@emotion/react/jsx-runtime/jsx-namespace").EmotionJSX.Element
7+
>div : any
8+
>css : string
9+
>div : any
10+
11+
=== /node_modules/@emotion/react/jsx-runtime/index.d.ts ===
12+
export { EmotionJSX as JSX } from './jsx-namespace'
13+
>EmotionJSX : any
14+
>JSX : any
15+
16+
=== /node_modules/@emotion/react/jsx-runtime/jsx-namespace.d.ts ===
17+
import 'react'
18+
19+
type WithConditionalCSSProp<P> = 'className' extends keyof P
20+
>WithConditionalCSSProp : WithConditionalCSSProp<P>
21+
22+
? (P extends { className?: string } ? P & { css?: string } : P)
23+
>className : string | undefined
24+
>css : string | undefined
25+
26+
: P
27+
28+
type ReactJSXElement = JSX.Element
29+
>ReactJSXElement : JSX.Element
30+
>JSX : any
31+
32+
type ReactJSXElementClass = JSX.ElementClass
33+
>ReactJSXElementClass : JSX.ElementClass
34+
>JSX : any
35+
36+
type ReactJSXElementAttributesProperty = JSX.ElementAttributesProperty
37+
>ReactJSXElementAttributesProperty : JSX.ElementAttributesProperty
38+
>JSX : any
39+
40+
type ReactJSXElementChildrenAttribute = JSX.ElementChildrenAttribute
41+
>ReactJSXElementChildrenAttribute : JSX.ElementChildrenAttribute
42+
>JSX : any
43+
44+
type ReactJSXLibraryManagedAttributes<C, P> = JSX.LibraryManagedAttributes<C, P>
45+
>ReactJSXLibraryManagedAttributes : JSX.LibraryManagedAttributes<C, P>
46+
>JSX : any
47+
48+
type ReactJSXIntrinsicAttributes = JSX.IntrinsicAttributes
49+
>ReactJSXIntrinsicAttributes : JSX.IntrinsicAttributes
50+
>JSX : any
51+
52+
type ReactJSXIntrinsicClassAttributes<T> = JSX.IntrinsicClassAttributes<T>
53+
>ReactJSXIntrinsicClassAttributes : ReactJSXIntrinsicClassAttributes<T>
54+
>JSX : any
55+
56+
type ReactJSXIntrinsicElements = JSX.IntrinsicElements
57+
>ReactJSXIntrinsicElements : JSX.IntrinsicElements
58+
>JSX : any
59+
60+
export namespace EmotionJSX {
61+
interface Element extends ReactJSXElement {}
62+
interface ElementClass extends ReactJSXElementClass {}
63+
interface ElementAttributesProperty
64+
extends ReactJSXElementAttributesProperty {}
65+
interface ElementChildrenAttribute extends ReactJSXElementChildrenAttribute {}
66+
67+
type LibraryManagedAttributes<C, P> = WithConditionalCSSProp<P> &
68+
>LibraryManagedAttributes : LibraryManagedAttributes<C, P>
69+
70+
ReactJSXLibraryManagedAttributes<C, P>
71+
72+
interface IntrinsicAttributes extends ReactJSXIntrinsicAttributes {}
73+
interface IntrinsicClassAttributes<T>
74+
extends ReactJSXIntrinsicClassAttributes<T> {}
75+
76+
type IntrinsicElements = {
77+
>IntrinsicElements : IntrinsicElements
78+
79+
[K in keyof ReactJSXIntrinsicElements]: ReactJSXIntrinsicElements[K] & {
80+
css?: string
81+
>css : string | undefined
82+
}
83+
}
84+
}
85+
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/index.tsx(1,32): error TS2322: Type '{ css: string; }' is not assignable to type '{}'.
2+
Property 'css' does not exist on type '{}'.
3+
4+
5+
==== /node_modules/react/index.d.ts (0 errors) ====
6+
export = React;
7+
export as namespace React;
8+
9+
declare namespace React {}
10+
11+
declare global {
12+
namespace JSX {
13+
interface Element {}
14+
interface ElementClass {}
15+
interface ElementAttributesProperty {}
16+
interface ElementChildrenAttribute {}
17+
type LibraryManagedAttributes<C, P> = {}
18+
interface IntrinsicAttributes {}
19+
interface IntrinsicClassAttributes<T> {}
20+
interface IntrinsicElements {
21+
div: {}
22+
}
23+
}
24+
}
25+
==== /node_modules/@emotion/react/jsx-runtime/index.d.ts (0 errors) ====
26+
export { EmotionJSX as JSX } from './jsx-namespace'
27+
28+
==== /node_modules/@emotion/react/jsx-runtime/jsx-namespace.d.ts (0 errors) ====
29+
import 'react'
30+
31+
type WithConditionalCSSProp<P> = 'className' extends keyof P
32+
? (P extends { className?: string } ? P & { css?: string } : P)
33+
: P
34+
35+
type ReactJSXElement = JSX.Element
36+
type ReactJSXElementClass = JSX.ElementClass
37+
type ReactJSXElementAttributesProperty = JSX.ElementAttributesProperty
38+
type ReactJSXElementChildrenAttribute = JSX.ElementChildrenAttribute
39+
type ReactJSXLibraryManagedAttributes<C, P> = JSX.LibraryManagedAttributes<C, P>
40+
type ReactJSXIntrinsicAttributes = JSX.IntrinsicAttributes
41+
type ReactJSXIntrinsicClassAttributes<T> = JSX.IntrinsicClassAttributes<T>
42+
type ReactJSXIntrinsicElements = JSX.IntrinsicElements
43+
44+
export namespace EmotionJSX {
45+
interface Element extends ReactJSXElement {}
46+
interface ElementClass extends ReactJSXElementClass {}
47+
interface ElementAttributesProperty
48+
extends ReactJSXElementAttributesProperty {}
49+
interface ElementChildrenAttribute extends ReactJSXElementChildrenAttribute {}
50+
51+
type LibraryManagedAttributes<C, P> = WithConditionalCSSProp<P> &
52+
ReactJSXLibraryManagedAttributes<C, P>
53+
54+
interface IntrinsicAttributes extends ReactJSXIntrinsicAttributes {}
55+
interface IntrinsicClassAttributes<T>
56+
extends ReactJSXIntrinsicClassAttributes<T> {}
57+
58+
type IntrinsicElements = {
59+
[K in keyof ReactJSXIntrinsicElements]: ReactJSXIntrinsicElements[K] & {
60+
css?: string
61+
}
62+
}
63+
}
64+
65+
==== /index.tsx (1 errors) ====
66+
export const Comp = () => <div css="color: hotpink;"></div>;
67+
~~~
68+
!!! error TS2322: Type '{ css: string; }' is not assignable to type '{}'.
69+
!!! error TS2322: Property 'css' does not exist on type '{}'.
70+

0 commit comments

Comments
 (0)