Skip to content

Commit 0ce27a0

Browse files
committed
Accept new baselines
1 parent e499213 commit 0ce27a0

File tree

2 files changed

+138
-0
lines changed

2 files changed

+138
-0
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
//// [tests/cases/compiler/jsxFunctionTypeChildren.tsx] ////
2+
3+
=== jsxFunctionTypeChildren.tsx ===
4+
// https://github.com/microsoft/typescript-go/issues/2703
5+
6+
/// <reference path="react.d.ts" />
7+
8+
import * as React from 'react';
9+
>React : Symbol(React, Decl(jsxFunctionTypeChildren.tsx, 4, 6))
10+
11+
type BaseProps = { locale: string };
12+
>BaseProps : Symbol(BaseProps, Decl(jsxFunctionTypeChildren.tsx, 4, 31))
13+
>locale : Symbol(locale, Decl(jsxFunctionTypeChildren.tsx, 6, 18))
14+
15+
type Props<T extends BaseProps> = {
16+
>Props : Symbol(Props, Decl(jsxFunctionTypeChildren.tsx, 6, 36))
17+
>T : Symbol(T, Decl(jsxFunctionTypeChildren.tsx, 8, 11))
18+
>BaseProps : Symbol(BaseProps, Decl(jsxFunctionTypeChildren.tsx, 4, 31))
19+
20+
children: (props: T) => React.ReactNode;
21+
>children : Symbol(children, Decl(jsxFunctionTypeChildren.tsx, 8, 35))
22+
>props : Symbol(props, Decl(jsxFunctionTypeChildren.tsx, 9, 15))
23+
>T : Symbol(T, Decl(jsxFunctionTypeChildren.tsx, 8, 11))
24+
>React : Symbol(React, Decl(jsxFunctionTypeChildren.tsx, 4, 6))
25+
>ReactNode : Symbol(React.ReactNode, Decl(react.d.ts, 91, 66))
26+
27+
} & T;
28+
>T : Symbol(T, Decl(jsxFunctionTypeChildren.tsx, 8, 11))
29+
30+
declare function Comp<T extends BaseProps>(props: Props<T>): JSX.Element;
31+
>Comp : Symbol(Comp, Decl(jsxFunctionTypeChildren.tsx, 10, 6))
32+
>T : Symbol(T, Decl(jsxFunctionTypeChildren.tsx, 12, 22))
33+
>BaseProps : Symbol(BaseProps, Decl(jsxFunctionTypeChildren.tsx, 4, 31))
34+
>props : Symbol(props, Decl(jsxFunctionTypeChildren.tsx, 12, 43))
35+
>Props : Symbol(Props, Decl(jsxFunctionTypeChildren.tsx, 6, 36))
36+
>T : Symbol(T, Decl(jsxFunctionTypeChildren.tsx, 12, 22))
37+
>JSX : Symbol(JSX, Decl(react.d.ts, 2355, 1))
38+
>Element : Symbol(JSX.Element, Decl(react.d.ts, 2358, 27))
39+
40+
const bp: BaseProps = { locale: 'en' };
41+
>bp : Symbol(bp, Decl(jsxFunctionTypeChildren.tsx, 14, 5))
42+
>BaseProps : Symbol(BaseProps, Decl(jsxFunctionTypeChildren.tsx, 4, 31))
43+
>locale : Symbol(locale, Decl(jsxFunctionTypeChildren.tsx, 14, 23))
44+
45+
// Error in ts-go: Type '(props: ...) => Element' is not assignable to
46+
// type '((props: ...) => ReactNode) & {}'.
47+
const el = <Comp {...bp}>{(props) => <div>{props.locale}</div>}</Comp>;
48+
>el : Symbol(el, Decl(jsxFunctionTypeChildren.tsx, 18, 5))
49+
>Comp : Symbol(Comp, Decl(jsxFunctionTypeChildren.tsx, 10, 6))
50+
>bp : Symbol(bp, Decl(jsxFunctionTypeChildren.tsx, 14, 5))
51+
>props : Symbol(props, Decl(jsxFunctionTypeChildren.tsx, 18, 27))
52+
>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2402, 45))
53+
>props.locale : Symbol(locale, Decl(jsxFunctionTypeChildren.tsx, 6, 18))
54+
>props : Symbol(props, Decl(jsxFunctionTypeChildren.tsx, 18, 27))
55+
>locale : Symbol(locale, Decl(jsxFunctionTypeChildren.tsx, 6, 18))
56+
>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2402, 45))
57+
>Comp : Symbol(Comp, Decl(jsxFunctionTypeChildren.tsx, 10, 6))
58+
59+
// But the equivalent non-JSX call works fine:
60+
Comp({ ...bp, children: (props) => <div>{props.locale}</div> });
61+
>Comp : Symbol(Comp, Decl(jsxFunctionTypeChildren.tsx, 10, 6))
62+
>bp : Symbol(bp, Decl(jsxFunctionTypeChildren.tsx, 14, 5))
63+
>children : Symbol(children, Decl(jsxFunctionTypeChildren.tsx, 21, 13))
64+
>props : Symbol(props, Decl(jsxFunctionTypeChildren.tsx, 21, 25))
65+
>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2402, 45))
66+
>props.locale : Symbol(locale, Decl(jsxFunctionTypeChildren.tsx, 6, 18))
67+
>props : Symbol(props, Decl(jsxFunctionTypeChildren.tsx, 21, 25))
68+
>locale : Symbol(locale, Decl(jsxFunctionTypeChildren.tsx, 6, 18))
69+
>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2402, 45))
70+
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
//// [tests/cases/compiler/jsxFunctionTypeChildren.tsx] ////
2+
3+
=== jsxFunctionTypeChildren.tsx ===
4+
// https://github.com/microsoft/typescript-go/issues/2703
5+
6+
/// <reference path="react.d.ts" />
7+
8+
import * as React from 'react';
9+
>React : typeof React
10+
11+
type BaseProps = { locale: string };
12+
>BaseProps : BaseProps
13+
>locale : string
14+
15+
type Props<T extends BaseProps> = {
16+
>Props : Props<T>
17+
18+
children: (props: T) => React.ReactNode;
19+
>children : (props: T) => React.ReactNode
20+
>props : T
21+
>React : any
22+
23+
} & T;
24+
25+
declare function Comp<T extends BaseProps>(props: Props<T>): JSX.Element;
26+
>Comp : <T extends BaseProps>(props: Props<T>) => JSX.Element
27+
>props : Props<T>
28+
>JSX : any
29+
30+
const bp: BaseProps = { locale: 'en' };
31+
>bp : BaseProps
32+
>{ locale: 'en' } : { locale: string; }
33+
>locale : string
34+
>'en' : "en"
35+
36+
// Error in ts-go: Type '(props: ...) => Element' is not assignable to
37+
// type '((props: ...) => ReactNode) & {}'.
38+
const el = <Comp {...bp}>{(props) => <div>{props.locale}</div>}</Comp>;
39+
>el : JSX.Element
40+
><Comp {...bp}>{(props) => <div>{props.locale}</div>}</Comp> : JSX.Element
41+
>Comp : <T extends BaseProps>(props: Props<T>) => JSX.Element
42+
>bp : BaseProps
43+
>(props) => <div>{props.locale}</div> : (props: { locale: string; children: {}; }) => JSX.Element
44+
>props : { locale: string; children: {}; }
45+
><div>{props.locale}</div> : JSX.Element
46+
>div : any
47+
>props.locale : string
48+
>props : { locale: string; children: {}; }
49+
>locale : string
50+
>div : any
51+
>Comp : <T extends BaseProps>(props: Props<T>) => JSX.Element
52+
53+
// But the equivalent non-JSX call works fine:
54+
Comp({ ...bp, children: (props) => <div>{props.locale}</div> });
55+
>Comp({ ...bp, children: (props) => <div>{props.locale}</div> }) : JSX.Element
56+
>Comp : <T extends BaseProps>(props: Props<T>) => JSX.Element
57+
>{ ...bp, children: (props) => <div>{props.locale}</div> } : { locale: string; children: (props: BaseProps) => JSX.Element; }
58+
>bp : BaseProps
59+
>children : (props: BaseProps) => JSX.Element
60+
>(props) => <div>{props.locale}</div> : (props: BaseProps) => JSX.Element
61+
>props : BaseProps
62+
><div>{props.locale}</div> : JSX.Element
63+
>div : any
64+
>props.locale : string
65+
>props : BaseProps
66+
>locale : string
67+
>div : any
68+

0 commit comments

Comments
 (0)