Skip to content

Commit

Permalink
Add actual baseline for a problem with global namespace being preferr…
Browse files Browse the repository at this point in the history
…ed over config implicit one
  • Loading branch information
Andarist committed Nov 12, 2020
1 parent d728297 commit e5d648c
Show file tree
Hide file tree
Showing 8 changed files with 781 additions and 0 deletions.
@@ -0,0 +1,55 @@
//// [tests/cases/compiler/jsxNamespaceImplicitImportJSXNamespace2.tsx] ////

//// [index.d.ts]
export { EmotionJSX as JSX } from './jsx-namespace'

//// [jsx-namespace.d.ts]
import 'react'

type WithConditionalCSSProp<P> = 'className' extends keyof P
? (P extends { className?: string } ? P & { css?: string } : P)
: P

type ReactJSXElement = JSX.Element
type ReactJSXElementClass = JSX.ElementClass
type ReactJSXElementAttributesProperty = JSX.ElementAttributesProperty
type ReactJSXElementChildrenAttribute = JSX.ElementChildrenAttribute
type ReactJSXLibraryManagedAttributes<C, P> = JSX.LibraryManagedAttributes<C, P>
type ReactJSXIntrinsicAttributes = JSX.IntrinsicAttributes
type ReactJSXIntrinsicClassAttributes<T> = JSX.IntrinsicClassAttributes<T>
type ReactJSXIntrinsicElements = JSX.IntrinsicElements

export namespace EmotionJSX {
interface Element extends ReactJSXElement {}
interface ElementClass extends ReactJSXElementClass {}
interface ElementAttributesProperty
extends ReactJSXElementAttributesProperty {}
interface ElementChildrenAttribute extends ReactJSXElementChildrenAttribute {}

type LibraryManagedAttributes<C, P> = WithConditionalCSSProp<P> &
ReactJSXLibraryManagedAttributes<C, P>

interface IntrinsicAttributes extends ReactJSXIntrinsicAttributes {}
interface IntrinsicClassAttributes<T>
extends ReactJSXIntrinsicClassAttributes<T> {}

type IntrinsicElements = {
[K in keyof ReactJSXIntrinsicElements]: ReactJSXIntrinsicElements[K] & {
css?: string
}
}
}

//// [index.tsx]
/// <reference path="/.lib/react16.d.ts" />
export const Comp = () => <div css="color: hotpink;"></div>;


//// [index.js]
"use strict";
exports.__esModule = true;
exports.Comp = void 0;
var jsx_runtime_1 = require("@emotion/react/jsx-runtime");
/// <reference path="react16.d.ts" />
var Comp = function () { return jsx_runtime_1.jsx("div", { css: "color: hotpink;" }, void 0); };
exports.Comp = Comp;
@@ -0,0 +1,137 @@
=== /index.tsx ===
/// <reference path="react16.d.ts" />
export const Comp = () => <div css="color: hotpink;"></div>;
>Comp : Symbol(Comp, Decl(index.tsx, 1, 12))
>div : Symbol(div, Decl(react16.d.ts, 2420, 114))
>css : Symbol(css, Decl(index.tsx, 1, 30))
>div : Symbol(div, Decl(react16.d.ts, 2420, 114))

=== /node_modules/@emotion/react/jsx-runtime/index.d.ts ===
export { EmotionJSX as JSX } from './jsx-namespace'
>EmotionJSX : Symbol(EmotionJSX, Decl(jsx-namespace.d.ts, 13, 54))
>JSX : Symbol(JSX, Decl(index.d.ts, 0, 8))

=== /node_modules/@emotion/react/jsx-runtime/jsx-namespace.d.ts ===
import 'react'

type WithConditionalCSSProp<P> = 'className' extends keyof P
>WithConditionalCSSProp : Symbol(WithConditionalCSSProp, Decl(jsx-namespace.d.ts, 0, 14))
>P : Symbol(P, Decl(jsx-namespace.d.ts, 2, 28))
>P : Symbol(P, Decl(jsx-namespace.d.ts, 2, 28))

? (P extends { className?: string } ? P & { css?: string } : P)
>P : Symbol(P, Decl(jsx-namespace.d.ts, 2, 28))
>className : Symbol(className, Decl(jsx-namespace.d.ts, 3, 16))
>P : Symbol(P, Decl(jsx-namespace.d.ts, 2, 28))
>css : Symbol(css, Decl(jsx-namespace.d.ts, 3, 45))
>P : Symbol(P, Decl(jsx-namespace.d.ts, 2, 28))

: P
>P : Symbol(P, Decl(jsx-namespace.d.ts, 2, 28))

type ReactJSXElement = JSX.Element
>ReactJSXElement : Symbol(ReactJSXElement, Decl(jsx-namespace.d.ts, 4, 5))
>JSX : Symbol(JSX, Decl(react16.d.ts, 2367, 12))
>Element : Symbol(JSX.Element, Decl(react16.d.ts, 2368, 23))

type ReactJSXElementClass = JSX.ElementClass
>ReactJSXElementClass : Symbol(ReactJSXElementClass, Decl(jsx-namespace.d.ts, 6, 34))
>JSX : Symbol(JSX, Decl(react16.d.ts, 2367, 12))
>ElementClass : Symbol(JSX.ElementClass, Decl(react16.d.ts, 2370, 65))

type ReactJSXElementAttributesProperty = JSX.ElementAttributesProperty
>ReactJSXElementAttributesProperty : Symbol(ReactJSXElementAttributesProperty, Decl(jsx-namespace.d.ts, 7, 44))
>JSX : Symbol(JSX, Decl(react16.d.ts, 2367, 12))
>ElementAttributesProperty : Symbol(JSX.ElementAttributesProperty, Decl(react16.d.ts, 2373, 13))

type ReactJSXElementChildrenAttribute = JSX.ElementChildrenAttribute
>ReactJSXElementChildrenAttribute : Symbol(ReactJSXElementChildrenAttribute, Decl(jsx-namespace.d.ts, 8, 70))
>JSX : Symbol(JSX, Decl(react16.d.ts, 2367, 12))
>ElementChildrenAttribute : Symbol(JSX.ElementChildrenAttribute, Decl(react16.d.ts, 2374, 62))

type ReactJSXLibraryManagedAttributes<C, P> = JSX.LibraryManagedAttributes<C, P>
>ReactJSXLibraryManagedAttributes : Symbol(ReactJSXLibraryManagedAttributes, Decl(jsx-namespace.d.ts, 9, 68))
>C : Symbol(C, Decl(jsx-namespace.d.ts, 10, 38))
>P : Symbol(P, Decl(jsx-namespace.d.ts, 10, 40))
>JSX : Symbol(JSX, Decl(react16.d.ts, 2367, 12))
>LibraryManagedAttributes : Symbol(JSX.LibraryManagedAttributes, Decl(react16.d.ts, 2375, 64))
>C : Symbol(C, Decl(jsx-namespace.d.ts, 10, 38))
>P : Symbol(P, Decl(jsx-namespace.d.ts, 10, 40))

type ReactJSXIntrinsicAttributes = JSX.IntrinsicAttributes
>ReactJSXIntrinsicAttributes : Symbol(ReactJSXIntrinsicAttributes, Decl(jsx-namespace.d.ts, 10, 80))
>JSX : Symbol(JSX, Decl(react16.d.ts, 2367, 12))
>IntrinsicAttributes : Symbol(JSX.IntrinsicAttributes, Decl(react16.d.ts, 2383, 20))

type ReactJSXIntrinsicClassAttributes<T> = JSX.IntrinsicClassAttributes<T>
>ReactJSXIntrinsicClassAttributes : Symbol(ReactJSXIntrinsicClassAttributes, Decl(jsx-namespace.d.ts, 11, 58))
>T : Symbol(T, Decl(jsx-namespace.d.ts, 12, 38))
>JSX : Symbol(JSX, Decl(react16.d.ts, 2367, 12))
>IntrinsicClassAttributes : Symbol(JSX.IntrinsicClassAttributes, Decl(react16.d.ts, 2386, 70))
>T : Symbol(T, Decl(jsx-namespace.d.ts, 12, 38))

type ReactJSXIntrinsicElements = JSX.IntrinsicElements
>ReactJSXIntrinsicElements : Symbol(ReactJSXIntrinsicElements, Decl(jsx-namespace.d.ts, 12, 74))
>JSX : Symbol(JSX, Decl(react16.d.ts, 2367, 12))
>IntrinsicElements : Symbol(JSX.IntrinsicElements, Decl(react16.d.ts, 2388, 86))

export namespace EmotionJSX {
>EmotionJSX : Symbol(EmotionJSX, Decl(jsx-namespace.d.ts, 13, 54))

interface Element extends ReactJSXElement {}
>Element : Symbol(Element, Decl(jsx-namespace.d.ts, 15, 29))
>ReactJSXElement : Symbol(ReactJSXElement, Decl(jsx-namespace.d.ts, 4, 5))

interface ElementClass extends ReactJSXElementClass {}
>ElementClass : Symbol(ElementClass, Decl(jsx-namespace.d.ts, 16, 46))
>ReactJSXElementClass : Symbol(ReactJSXElementClass, Decl(jsx-namespace.d.ts, 6, 34))

interface ElementAttributesProperty
>ElementAttributesProperty : Symbol(ElementAttributesProperty, Decl(jsx-namespace.d.ts, 17, 56))

extends ReactJSXElementAttributesProperty {}
>ReactJSXElementAttributesProperty : Symbol(ReactJSXElementAttributesProperty, Decl(jsx-namespace.d.ts, 7, 44))

interface ElementChildrenAttribute extends ReactJSXElementChildrenAttribute {}
>ElementChildrenAttribute : Symbol(ElementChildrenAttribute, Decl(jsx-namespace.d.ts, 19, 48))
>ReactJSXElementChildrenAttribute : Symbol(ReactJSXElementChildrenAttribute, Decl(jsx-namespace.d.ts, 8, 70))

type LibraryManagedAttributes<C, P> = WithConditionalCSSProp<P> &
>LibraryManagedAttributes : Symbol(LibraryManagedAttributes, Decl(jsx-namespace.d.ts, 20, 80))
>C : Symbol(C, Decl(jsx-namespace.d.ts, 22, 32))
>P : Symbol(P, Decl(jsx-namespace.d.ts, 22, 34))
>WithConditionalCSSProp : Symbol(WithConditionalCSSProp, Decl(jsx-namespace.d.ts, 0, 14))
>P : Symbol(P, Decl(jsx-namespace.d.ts, 22, 34))

ReactJSXLibraryManagedAttributes<C, P>
>ReactJSXLibraryManagedAttributes : Symbol(ReactJSXLibraryManagedAttributes, Decl(jsx-namespace.d.ts, 9, 68))
>C : Symbol(C, Decl(jsx-namespace.d.ts, 22, 32))
>P : Symbol(P, Decl(jsx-namespace.d.ts, 22, 34))

interface IntrinsicAttributes extends ReactJSXIntrinsicAttributes {}
>IntrinsicAttributes : Symbol(IntrinsicAttributes, Decl(jsx-namespace.d.ts, 23, 42))
>ReactJSXIntrinsicAttributes : Symbol(ReactJSXIntrinsicAttributes, Decl(jsx-namespace.d.ts, 10, 80))

interface IntrinsicClassAttributes<T>
>IntrinsicClassAttributes : Symbol(IntrinsicClassAttributes, Decl(jsx-namespace.d.ts, 25, 70))
>T : Symbol(T, Decl(jsx-namespace.d.ts, 26, 37))

extends ReactJSXIntrinsicClassAttributes<T> {}
>ReactJSXIntrinsicClassAttributes : Symbol(ReactJSXIntrinsicClassAttributes, Decl(jsx-namespace.d.ts, 11, 58))
>T : Symbol(T, Decl(jsx-namespace.d.ts, 26, 37))

type IntrinsicElements = {
>IntrinsicElements : Symbol(IntrinsicElements, Decl(jsx-namespace.d.ts, 27, 50))

[K in keyof ReactJSXIntrinsicElements]: ReactJSXIntrinsicElements[K] & {
>K : Symbol(K, Decl(jsx-namespace.d.ts, 30, 5))
>ReactJSXIntrinsicElements : Symbol(ReactJSXIntrinsicElements, Decl(jsx-namespace.d.ts, 12, 74))
>ReactJSXIntrinsicElements : Symbol(ReactJSXIntrinsicElements, Decl(jsx-namespace.d.ts, 12, 74))
>K : Symbol(K, Decl(jsx-namespace.d.ts, 30, 5))

css?: string
>css : Symbol(css, Decl(jsx-namespace.d.ts, 30, 76))
}
}
}

@@ -0,0 +1,85 @@
=== /index.tsx ===
/// <reference path="react16.d.ts" />
export const Comp = () => <div css="color: hotpink;"></div>;
>Comp : () => import("/node_modules/@emotion/react/jsx-runtime/jsx-namespace").EmotionJSX.Element
>() => <div css="color: hotpink;"></div> : () => import("/node_modules/@emotion/react/jsx-runtime/jsx-namespace").EmotionJSX.Element
><div css="color: hotpink;"></div> : import("/node_modules/@emotion/react/jsx-runtime/jsx-namespace").EmotionJSX.Element
>div : any
>css : string
>div : any

=== /node_modules/@emotion/react/jsx-runtime/index.d.ts ===
export { EmotionJSX as JSX } from './jsx-namespace'
>EmotionJSX : any
>JSX : any

=== /node_modules/@emotion/react/jsx-runtime/jsx-namespace.d.ts ===
import 'react'

type WithConditionalCSSProp<P> = 'className' extends keyof P
>WithConditionalCSSProp : WithConditionalCSSProp<P>

? (P extends { className?: string } ? P & { css?: string } : P)
>className : string | undefined
>css : string | undefined

: P

type ReactJSXElement = JSX.Element
>ReactJSXElement : JSX.Element
>JSX : any

type ReactJSXElementClass = JSX.ElementClass
>ReactJSXElementClass : JSX.ElementClass
>JSX : any

type ReactJSXElementAttributesProperty = JSX.ElementAttributesProperty
>ReactJSXElementAttributesProperty : JSX.ElementAttributesProperty
>JSX : any

type ReactJSXElementChildrenAttribute = JSX.ElementChildrenAttribute
>ReactJSXElementChildrenAttribute : JSX.ElementChildrenAttribute
>JSX : any

type ReactJSXLibraryManagedAttributes<C, P> = JSX.LibraryManagedAttributes<C, P>
>ReactJSXLibraryManagedAttributes : JSX.LibraryManagedAttributes<C, P>
>JSX : any

type ReactJSXIntrinsicAttributes = JSX.IntrinsicAttributes
>ReactJSXIntrinsicAttributes : JSX.IntrinsicAttributes
>JSX : any

type ReactJSXIntrinsicClassAttributes<T> = JSX.IntrinsicClassAttributes<T>
>ReactJSXIntrinsicClassAttributes : ReactJSXIntrinsicClassAttributes<T>
>JSX : any

type ReactJSXIntrinsicElements = JSX.IntrinsicElements
>ReactJSXIntrinsicElements : JSX.IntrinsicElements
>JSX : any

export namespace EmotionJSX {
interface Element extends ReactJSXElement {}
interface ElementClass extends ReactJSXElementClass {}
interface ElementAttributesProperty
extends ReactJSXElementAttributesProperty {}
interface ElementChildrenAttribute extends ReactJSXElementChildrenAttribute {}

type LibraryManagedAttributes<C, P> = WithConditionalCSSProp<P> &
>LibraryManagedAttributes : LibraryManagedAttributes<C, P>

ReactJSXLibraryManagedAttributes<C, P>

interface IntrinsicAttributes extends ReactJSXIntrinsicAttributes {}
interface IntrinsicClassAttributes<T>
extends ReactJSXIntrinsicClassAttributes<T> {}

type IntrinsicElements = {
>IntrinsicElements : IntrinsicElements

[K in keyof ReactJSXIntrinsicElements]: ReactJSXIntrinsicElements[K] & {
css?: string
>css : string | undefined
}
}
}

@@ -0,0 +1,70 @@
/index.tsx(1,32): error TS2322: Type '{ css: string; }' is not assignable to type '{}'.
Property 'css' does not exist on type '{}'.


==== /node_modules/react/index.d.ts (0 errors) ====
export = React;
export as namespace React;

declare namespace React {}

declare global {
namespace JSX {
interface Element {}
interface ElementClass {}
interface ElementAttributesProperty {}
interface ElementChildrenAttribute {}
type LibraryManagedAttributes<C, P> = {}
interface IntrinsicAttributes {}
interface IntrinsicClassAttributes<T> {}
interface IntrinsicElements {
div: {}
}
}
}
==== /node_modules/@emotion/react/jsx-runtime/index.d.ts (0 errors) ====
export { EmotionJSX as JSX } from './jsx-namespace'

==== /node_modules/@emotion/react/jsx-runtime/jsx-namespace.d.ts (0 errors) ====
import 'react'

type WithConditionalCSSProp<P> = 'className' extends keyof P
? (P extends { className?: string } ? P & { css?: string } : P)
: P

type ReactJSXElement = JSX.Element
type ReactJSXElementClass = JSX.ElementClass
type ReactJSXElementAttributesProperty = JSX.ElementAttributesProperty
type ReactJSXElementChildrenAttribute = JSX.ElementChildrenAttribute
type ReactJSXLibraryManagedAttributes<C, P> = JSX.LibraryManagedAttributes<C, P>
type ReactJSXIntrinsicAttributes = JSX.IntrinsicAttributes
type ReactJSXIntrinsicClassAttributes<T> = JSX.IntrinsicClassAttributes<T>
type ReactJSXIntrinsicElements = JSX.IntrinsicElements

export namespace EmotionJSX {
interface Element extends ReactJSXElement {}
interface ElementClass extends ReactJSXElementClass {}
interface ElementAttributesProperty
extends ReactJSXElementAttributesProperty {}
interface ElementChildrenAttribute extends ReactJSXElementChildrenAttribute {}

type LibraryManagedAttributes<C, P> = WithConditionalCSSProp<P> &
ReactJSXLibraryManagedAttributes<C, P>

interface IntrinsicAttributes extends ReactJSXIntrinsicAttributes {}
interface IntrinsicClassAttributes<T>
extends ReactJSXIntrinsicClassAttributes<T> {}

type IntrinsicElements = {
[K in keyof ReactJSXIntrinsicElements]: ReactJSXIntrinsicElements[K] & {
css?: string
}
}
}

==== /index.tsx (1 errors) ====
export const Comp = () => <div css="color: hotpink;"></div>;
~~~
!!! error TS2322: Type '{ css: string; }' is not assignable to type '{}'.
!!! error TS2322: Property 'css' does not exist on type '{}'.

0 comments on commit e5d648c

Please sign in to comment.