Skip to content

Commit 4c89376

Browse files
authored
Fix JSX contextual types to not eagerly become apparent, use 2-pass inference for JSX (#21383) (#21749)
* Fix JSX contextual types to not eagerly become apparent * Apply changes from code review, unify common code * Fix jsx children contextual typing * Light code review feedback * Use fillMissingTypeArguments * Accept nonliteral jsx child type * Add test for the fillMissingTypeArguments case
1 parent d68eba7 commit 4c89376

19 files changed

+1033
-152
lines changed

src/compiler/checker.ts

+209-142
Large diffs are not rendered by default.

src/compiler/types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -3851,6 +3851,7 @@ namespace ts {
38513851
}
38523852

38533853
export const enum InferenceFlags {
3854+
None = 0, // No special inference behaviors
38543855
InferUnionTypes = 1 << 0, // Infer union types for disjoint candidates (otherwise unknownType)
38553856
NoDefault = 1 << 1, // Infer unknownType for no inferences (otherwise anyType or emptyObjectType)
38563857
AnyDefault = 1 << 2, // Infer anyType for no inferences (otherwise emptyObjectType)

tests/baselines/reference/api/tsserverlibrary.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -2192,6 +2192,7 @@ declare namespace ts {
21922192
isFixed: boolean;
21932193
}
21942194
enum InferenceFlags {
2195+
None = 0,
21952196
InferUnionTypes = 1,
21962197
NoDefault = 2,
21972198
AnyDefault = 4,

tests/baselines/reference/api/typescript.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -2192,6 +2192,7 @@ declare namespace ts {
21922192
isFixed: boolean;
21932193
}
21942194
enum InferenceFlags {
2195+
None = 0,
21952196
InferUnionTypes = 1,
21962197
NoDefault = 2,
21972198
AnyDefault = 4,

tests/baselines/reference/checkJsxChildrenProperty2.errors.txt

+10-10
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ tests/cases/conformance/jsx/file.tsx(31,11): error TS2322: Type '{ children: (El
88
Type '(Element | ((name: string) => Element))[]' is not assignable to type 'string | Element'.
99
Type '(Element | ((name: string) => Element))[]' is not assignable to type 'Element'.
1010
Property 'type' is missing in type '(Element | ((name: string) => Element))[]'.
11-
tests/cases/conformance/jsx/file.tsx(37,11): error TS2322: Type '{ children: (Element | 1000000)[]; a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & Prop'.
12-
Type '{ children: (Element | 1000000)[]; a: number; b: string; }' is not assignable to type 'Prop'.
11+
tests/cases/conformance/jsx/file.tsx(37,11): error TS2322: Type '{ children: (number | Element)[]; a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & Prop'.
12+
Type '{ children: (number | Element)[]; a: number; b: string; }' is not assignable to type 'Prop'.
1313
Types of property 'children' are incompatible.
14-
Type '(Element | 1000000)[]' is not assignable to type 'string | Element'.
15-
Type '(Element | 1000000)[]' is not assignable to type 'Element'.
16-
Property 'type' is missing in type '(Element | 1000000)[]'.
14+
Type '(number | Element)[]' is not assignable to type 'string | Element'.
15+
Type '(number | Element)[]' is not assignable to type 'Element'.
16+
Property 'type' is missing in type '(number | Element)[]'.
1717
tests/cases/conformance/jsx/file.tsx(43,11): error TS2322: Type '{ children: (string | Element)[]; a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & Prop'.
1818
Type '{ children: (string | Element)[]; a: number; b: string; }' is not assignable to type 'Prop'.
1919
Types of property 'children' are incompatible.
@@ -80,12 +80,12 @@ tests/cases/conformance/jsx/file.tsx(49,11): error TS2322: Type '{ children: Ele
8080
let k3 =
8181
<Comp a={10} b="hi">
8282
~~~~~~~~~~~~~
83-
!!! error TS2322: Type '{ children: (Element | 1000000)[]; a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & Prop'.
84-
!!! error TS2322: Type '{ children: (Element | 1000000)[]; a: number; b: string; }' is not assignable to type 'Prop'.
83+
!!! error TS2322: Type '{ children: (number | Element)[]; a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & Prop'.
84+
!!! error TS2322: Type '{ children: (number | Element)[]; a: number; b: string; }' is not assignable to type 'Prop'.
8585
!!! error TS2322: Types of property 'children' are incompatible.
86-
!!! error TS2322: Type '(Element | 1000000)[]' is not assignable to type 'string | Element'.
87-
!!! error TS2322: Type '(Element | 1000000)[]' is not assignable to type 'Element'.
88-
!!! error TS2322: Property 'type' is missing in type '(Element | 1000000)[]'.
86+
!!! error TS2322: Type '(number | Element)[]' is not assignable to type 'string | Element'.
87+
!!! error TS2322: Type '(number | Element)[]' is not assignable to type 'Element'.
88+
!!! error TS2322: Property 'type' is missing in type '(number | Element)[]'.
8989
<div> My Div </div>
9090
{1000000}
9191
</Comp>;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
tests/cases/conformance/jsx/file.tsx(13,27): error TS2322: Type '{ initialValues: { x: string; }; nextValues: (a: { x: string; }) => string; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<GenericComponent<{ initialValues: { x: string; }; nextValues: {}; }, { x: string; }>> & { initialValues: { x: string; }; nextValues: {}; } & BaseProps<{ x: string; }> & { children?: ReactNode; }'.
2+
Type '{ initialValues: { x: string; }; nextValues: (a: { x: string; }) => string; }' is not assignable to type 'BaseProps<{ x: string; }>'.
3+
Types of property 'nextValues' are incompatible.
4+
Type '(a: { x: string; }) => string' is not assignable to type '(cur: { x: string; }) => { x: string; }'.
5+
Type 'string' is not assignable to type '{ x: string; }'.
6+
7+
8+
==== tests/cases/conformance/jsx/file.tsx (1 errors) ====
9+
import * as React from "react";
10+
interface BaseProps<T> {
11+
initialValues: T;
12+
nextValues: (cur: T) => T;
13+
}
14+
declare class GenericComponent<Props = {}, Values = object> extends React.Component<Props & BaseProps<Values>, {}> {
15+
iv: Values;
16+
}
17+
18+
let a = <GenericComponent initialValues={{ x: "y" }} nextValues={a => a} />; // No error
19+
let b = <GenericComponent initialValues={12} nextValues={a => a} />; // No error - Values should be reinstantiated with `number` (since `object` is a default, not a constraint)
20+
let c = <GenericComponent initialValues={{ x: "y" }} nextValues={a => ({ x: a.x })} />; // No Error
21+
let d = <GenericComponent initialValues={{ x: "y" }} nextValues={a => a.x} />; // Error - `string` is not assignable to `{x: string}`
22+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
23+
!!! error TS2322: Type '{ initialValues: { x: string; }; nextValues: (a: { x: string; }) => string; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<GenericComponent<{ initialValues: { x: string; }; nextValues: {}; }, { x: string; }>> & { initialValues: { x: string; }; nextValues: {}; } & BaseProps<{ x: string; }> & { children?: ReactNode; }'.
24+
!!! error TS2322: Type '{ initialValues: { x: string; }; nextValues: (a: { x: string; }) => string; }' is not assignable to type 'BaseProps<{ x: string; }>'.
25+
!!! error TS2322: Types of property 'nextValues' are incompatible.
26+
!!! error TS2322: Type '(a: { x: string; }) => string' is not assignable to type '(cur: { x: string; }) => { x: string; }'.
27+
!!! error TS2322: Type 'string' is not assignable to type '{ x: string; }'.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//// [file.tsx]
2+
import * as React from "react";
3+
interface BaseProps<T> {
4+
initialValues: T;
5+
nextValues: (cur: T) => T;
6+
}
7+
declare class GenericComponent<Props = {}, Values = object> extends React.Component<Props & BaseProps<Values>, {}> {
8+
iv: Values;
9+
}
10+
11+
let a = <GenericComponent initialValues={{ x: "y" }} nextValues={a => a} />; // No error
12+
let b = <GenericComponent initialValues={12} nextValues={a => a} />; // No error - Values should be reinstantiated with `number` (since `object` is a default, not a constraint)
13+
let c = <GenericComponent initialValues={{ x: "y" }} nextValues={a => ({ x: a.x })} />; // No Error
14+
let d = <GenericComponent initialValues={{ x: "y" }} nextValues={a => a.x} />; // Error - `string` is not assignable to `{x: string}`
15+
16+
//// [file.jsx]
17+
"use strict";
18+
exports.__esModule = true;
19+
var React = require("react");
20+
var a = <GenericComponent initialValues={{ x: "y" }} nextValues={function (a) { return a; }}/>; // No error
21+
var b = <GenericComponent initialValues={12} nextValues={function (a) { return a; }}/>; // No error - Values should be reinstantiated with `number` (since `object` is a default, not a constraint)
22+
var c = <GenericComponent initialValues={{ x: "y" }} nextValues={function (a) { return ({ x: a.x }); }}/>; // No Error
23+
var d = <GenericComponent initialValues={{ x: "y" }} nextValues={function (a) { return a.x; }}/>; // Error - `string` is not assignable to `{x: string}`
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
=== tests/cases/conformance/jsx/file.tsx ===
2+
import * as React from "react";
3+
>React : Symbol(React, Decl(file.tsx, 0, 6))
4+
5+
interface BaseProps<T> {
6+
>BaseProps : Symbol(BaseProps, Decl(file.tsx, 0, 31))
7+
>T : Symbol(T, Decl(file.tsx, 1, 20))
8+
9+
initialValues: T;
10+
>initialValues : Symbol(BaseProps.initialValues, Decl(file.tsx, 1, 24))
11+
>T : Symbol(T, Decl(file.tsx, 1, 20))
12+
13+
nextValues: (cur: T) => T;
14+
>nextValues : Symbol(BaseProps.nextValues, Decl(file.tsx, 2, 19))
15+
>cur : Symbol(cur, Decl(file.tsx, 3, 15))
16+
>T : Symbol(T, Decl(file.tsx, 1, 20))
17+
>T : Symbol(T, Decl(file.tsx, 1, 20))
18+
}
19+
declare class GenericComponent<Props = {}, Values = object> extends React.Component<Props & BaseProps<Values>, {}> {
20+
>GenericComponent : Symbol(GenericComponent, Decl(file.tsx, 4, 1))
21+
>Props : Symbol(Props, Decl(file.tsx, 5, 31))
22+
>Values : Symbol(Values, Decl(file.tsx, 5, 42))
23+
>React.Component : Symbol(React.Component, Decl(react.d.ts, 158, 55), Decl(react.d.ts, 161, 66))
24+
>React : Symbol(React, Decl(file.tsx, 0, 6))
25+
>Component : Symbol(React.Component, Decl(react.d.ts, 158, 55), Decl(react.d.ts, 161, 66))
26+
>Props : Symbol(Props, Decl(file.tsx, 5, 31))
27+
>BaseProps : Symbol(BaseProps, Decl(file.tsx, 0, 31))
28+
>Values : Symbol(Values, Decl(file.tsx, 5, 42))
29+
30+
iv: Values;
31+
>iv : Symbol(GenericComponent.iv, Decl(file.tsx, 5, 116))
32+
>Values : Symbol(Values, Decl(file.tsx, 5, 42))
33+
}
34+
35+
let a = <GenericComponent initialValues={{ x: "y" }} nextValues={a => a} />; // No error
36+
>a : Symbol(a, Decl(file.tsx, 9, 3))
37+
>GenericComponent : Symbol(GenericComponent, Decl(file.tsx, 4, 1))
38+
>initialValues : Symbol(initialValues, Decl(file.tsx, 9, 25))
39+
>x : Symbol(x, Decl(file.tsx, 9, 42))
40+
>nextValues : Symbol(nextValues, Decl(file.tsx, 9, 52))
41+
>a : Symbol(a, Decl(file.tsx, 9, 65))
42+
>a : Symbol(a, Decl(file.tsx, 9, 65))
43+
44+
let b = <GenericComponent initialValues={12} nextValues={a => a} />; // No error - Values should be reinstantiated with `number` (since `object` is a default, not a constraint)
45+
>b : Symbol(b, Decl(file.tsx, 10, 3))
46+
>GenericComponent : Symbol(GenericComponent, Decl(file.tsx, 4, 1))
47+
>initialValues : Symbol(initialValues, Decl(file.tsx, 10, 25))
48+
>nextValues : Symbol(nextValues, Decl(file.tsx, 10, 44))
49+
>a : Symbol(a, Decl(file.tsx, 10, 57))
50+
>a : Symbol(a, Decl(file.tsx, 10, 57))
51+
52+
let c = <GenericComponent initialValues={{ x: "y" }} nextValues={a => ({ x: a.x })} />; // No Error
53+
>c : Symbol(c, Decl(file.tsx, 11, 3))
54+
>GenericComponent : Symbol(GenericComponent, Decl(file.tsx, 4, 1))
55+
>initialValues : Symbol(initialValues, Decl(file.tsx, 11, 25))
56+
>x : Symbol(x, Decl(file.tsx, 11, 42))
57+
>nextValues : Symbol(nextValues, Decl(file.tsx, 11, 52))
58+
>a : Symbol(a, Decl(file.tsx, 11, 65))
59+
>x : Symbol(x, Decl(file.tsx, 11, 72))
60+
>a.x : Symbol(x, Decl(file.tsx, 11, 42))
61+
>a : Symbol(a, Decl(file.tsx, 11, 65))
62+
>x : Symbol(x, Decl(file.tsx, 11, 42))
63+
64+
let d = <GenericComponent initialValues={{ x: "y" }} nextValues={a => a.x} />; // Error - `string` is not assignable to `{x: string}`
65+
>d : Symbol(d, Decl(file.tsx, 12, 3))
66+
>GenericComponent : Symbol(GenericComponent, Decl(file.tsx, 4, 1))
67+
>initialValues : Symbol(initialValues, Decl(file.tsx, 12, 25))
68+
>x : Symbol(x, Decl(file.tsx, 12, 42))
69+
>nextValues : Symbol(nextValues, Decl(file.tsx, 12, 52))
70+
>a : Symbol(a, Decl(file.tsx, 12, 65))
71+
>a.x : Symbol(x, Decl(file.tsx, 12, 42))
72+
>a : Symbol(a, Decl(file.tsx, 12, 65))
73+
>x : Symbol(x, Decl(file.tsx, 12, 42))
74+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
=== tests/cases/conformance/jsx/file.tsx ===
2+
import * as React from "react";
3+
>React : typeof React
4+
5+
interface BaseProps<T> {
6+
>BaseProps : BaseProps<T>
7+
>T : T
8+
9+
initialValues: T;
10+
>initialValues : T
11+
>T : T
12+
13+
nextValues: (cur: T) => T;
14+
>nextValues : (cur: T) => T
15+
>cur : T
16+
>T : T
17+
>T : T
18+
}
19+
declare class GenericComponent<Props = {}, Values = object> extends React.Component<Props & BaseProps<Values>, {}> {
20+
>GenericComponent : GenericComponent<Props, Values>
21+
>Props : Props
22+
>Values : Values
23+
>React.Component : React.Component<Props & BaseProps<Values>, {}>
24+
>React : typeof React
25+
>Component : typeof React.Component
26+
>Props : Props
27+
>BaseProps : BaseProps<T>
28+
>Values : Values
29+
30+
iv: Values;
31+
>iv : Values
32+
>Values : Values
33+
}
34+
35+
let a = <GenericComponent initialValues={{ x: "y" }} nextValues={a => a} />; // No error
36+
>a : JSX.Element
37+
><GenericComponent initialValues={{ x: "y" }} nextValues={a => a} /> : JSX.Element
38+
>GenericComponent : typeof GenericComponent
39+
>initialValues : { x: string; }
40+
>{ x: "y" } : { x: string; }
41+
>x : string
42+
>"y" : "y"
43+
>nextValues : (a: { x: string; }) => { x: string; }
44+
>a => a : (a: { x: string; }) => { x: string; }
45+
>a : { x: string; }
46+
>a : { x: string; }
47+
48+
let b = <GenericComponent initialValues={12} nextValues={a => a} />; // No error - Values should be reinstantiated with `number` (since `object` is a default, not a constraint)
49+
>b : JSX.Element
50+
><GenericComponent initialValues={12} nextValues={a => a} /> : JSX.Element
51+
>GenericComponent : typeof GenericComponent
52+
>initialValues : number
53+
>12 : 12
54+
>nextValues : (a: number) => number
55+
>a => a : (a: number) => number
56+
>a : number
57+
>a : number
58+
59+
let c = <GenericComponent initialValues={{ x: "y" }} nextValues={a => ({ x: a.x })} />; // No Error
60+
>c : JSX.Element
61+
><GenericComponent initialValues={{ x: "y" }} nextValues={a => ({ x: a.x })} /> : JSX.Element
62+
>GenericComponent : typeof GenericComponent
63+
>initialValues : { x: string; }
64+
>{ x: "y" } : { x: string; }
65+
>x : string
66+
>"y" : "y"
67+
>nextValues : (a: { x: string; }) => { x: string; }
68+
>a => ({ x: a.x }) : (a: { x: string; }) => { x: string; }
69+
>a : { x: string; }
70+
>({ x: a.x }) : { x: string; }
71+
>{ x: a.x } : { x: string; }
72+
>x : string
73+
>a.x : string
74+
>a : { x: string; }
75+
>x : string
76+
77+
let d = <GenericComponent initialValues={{ x: "y" }} nextValues={a => a.x} />; // Error - `string` is not assignable to `{x: string}`
78+
>d : JSX.Element
79+
><GenericComponent initialValues={{ x: "y" }} nextValues={a => a.x} /> : JSX.Element
80+
>GenericComponent : typeof GenericComponent
81+
>initialValues : { x: string; }
82+
>{ x: "y" } : { x: string; }
83+
>x : string
84+
>"y" : "y"
85+
>nextValues : (a: { x: string; }) => string
86+
>a => a.x : (a: { x: string; }) => string
87+
>a : { x: string; }
88+
>a.x : string
89+
>a : { x: string; }
90+
>x : string
91+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
tests/cases/compiler/jsxChildrenGenericContextualTypes.tsx(20,22): error TS2322: Type '{ prop: "x"; children: (p: IntrinsicAttributes & LitProps<"x">) => "y"; }' is not assignable to type 'IntrinsicAttributes & LitProps<"x">'.
2+
Type '{ prop: "x"; children: (p: IntrinsicAttributes & LitProps<"x">) => "y"; }' is not assignable to type 'LitProps<"x">'.
3+
Types of property 'children' are incompatible.
4+
Type '(p: IntrinsicAttributes & LitProps<"x">) => "y"' is not assignable to type '(x: LitProps<"x">) => "x"'.
5+
Type '"y"' is not assignable to type '"x"'.
6+
tests/cases/compiler/jsxChildrenGenericContextualTypes.tsx(21,27): error TS2322: Type '{ children: (p: IntrinsicAttributes & LitProps<"x">) => "y"; prop: "x"; }' is not assignable to type 'IntrinsicAttributes & LitProps<"x" | "y">'.
7+
Type '{ children: (p: IntrinsicAttributes & LitProps<"x">) => "y"; prop: "x"; }' is not assignable to type 'LitProps<"x" | "y">'.
8+
Types of property 'children' are incompatible.
9+
Type '(p: IntrinsicAttributes & LitProps<"x">) => "y"' is not assignable to type '(x: LitProps<"x" | "y">) => "x" | "y"'.
10+
Types of parameters 'p' and 'x' are incompatible.
11+
Type 'LitProps<"x" | "y">' is not assignable to type 'IntrinsicAttributes & LitProps<"x">'.
12+
Type 'LitProps<"x" | "y">' is not assignable to type 'LitProps<"x">'.
13+
Types of property 'prop' are incompatible.
14+
Type '"x" | "y"' is not assignable to type '"x"'.
15+
Type '"y"' is not assignable to type '"x"'.
16+
tests/cases/compiler/jsxChildrenGenericContextualTypes.tsx(22,29): error TS2322: Type '{ children: () => number; prop: "x"; }' is not assignable to type 'IntrinsicAttributes & LitProps<"x">'.
17+
Type '{ children: () => number; prop: "x"; }' is not assignable to type 'LitProps<"x">'.
18+
Types of property 'children' are incompatible.
19+
Type '() => number' is not assignable to type '(x: LitProps<"x">) => "x"'.
20+
Type 'number' is not assignable to type '"x"'.
21+
22+
23+
==== tests/cases/compiler/jsxChildrenGenericContextualTypes.tsx (3 errors) ====
24+
namespace JSX {
25+
export interface Element {}
26+
export interface ElementAttributesProperty { props: {}; }
27+
export interface ElementChildrenAttribute { children: {}; }
28+
export interface IntrinsicAttributes {}
29+
export interface IntrinsicElements { [key: string]: Element }
30+
}
31+
const Elem = <T,U=never>(p: { prop: T, children: (t: T) => T }) => <div></div>;
32+
Elem({prop: {a: "x"}, children: i => ({a: "z"})});
33+
const q = <Elem prop={{a: "x"}} children={i => ({a: "z"})} />
34+
const qq = <Elem prop={{a: "x"}}>{i => ({a: "z"})}</Elem>
35+
36+
interface LitProps<T> { prop: T, children: (x: this) => T }
37+
const ElemLit = <T extends string>(p: LitProps<T>) => <div></div>;
38+
ElemLit({prop: "x", children: () => "x"});
39+
const j = <ElemLit prop="x" children={() => "x"} />
40+
const jj = <ElemLit prop="x">{() => "x"}</ElemLit>
41+
42+
// Should error
43+
const arg = <ElemLit prop="x" children={p => "y"} />
44+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
45+
!!! error TS2322: Type '{ prop: "x"; children: (p: IntrinsicAttributes & LitProps<"x">) => "y"; }' is not assignable to type 'IntrinsicAttributes & LitProps<"x">'.
46+
!!! error TS2322: Type '{ prop: "x"; children: (p: IntrinsicAttributes & LitProps<"x">) => "y"; }' is not assignable to type 'LitProps<"x">'.
47+
!!! error TS2322: Types of property 'children' are incompatible.
48+
!!! error TS2322: Type '(p: IntrinsicAttributes & LitProps<"x">) => "y"' is not assignable to type '(x: LitProps<"x">) => "x"'.
49+
!!! error TS2322: Type '"y"' is not assignable to type '"x"'.
50+
const argchild = <ElemLit prop="x">{p => "y"}</ElemLit>
51+
~~~~~~~~
52+
!!! error TS2322: Type '{ children: (p: IntrinsicAttributes & LitProps<"x">) => "y"; prop: "x"; }' is not assignable to type 'IntrinsicAttributes & LitProps<"x" | "y">'.
53+
!!! error TS2322: Type '{ children: (p: IntrinsicAttributes & LitProps<"x">) => "y"; prop: "x"; }' is not assignable to type 'LitProps<"x" | "y">'.
54+
!!! error TS2322: Types of property 'children' are incompatible.
55+
!!! error TS2322: Type '(p: IntrinsicAttributes & LitProps<"x">) => "y"' is not assignable to type '(x: LitProps<"x" | "y">) => "x" | "y"'.
56+
!!! error TS2322: Types of parameters 'p' and 'x' are incompatible.
57+
!!! error TS2322: Type 'LitProps<"x" | "y">' is not assignable to type 'IntrinsicAttributes & LitProps<"x">'.
58+
!!! error TS2322: Type 'LitProps<"x" | "y">' is not assignable to type 'LitProps<"x">'.
59+
!!! error TS2322: Types of property 'prop' are incompatible.
60+
!!! error TS2322: Type '"x" | "y"' is not assignable to type '"x"'.
61+
!!! error TS2322: Type '"y"' is not assignable to type '"x"'.
62+
const mismatched = <ElemLit prop="x">{() => 12}</ElemLit>
63+
~~~~~~~~
64+
!!! error TS2322: Type '{ children: () => number; prop: "x"; }' is not assignable to type 'IntrinsicAttributes & LitProps<"x">'.
65+
!!! error TS2322: Type '{ children: () => number; prop: "x"; }' is not assignable to type 'LitProps<"x">'.
66+
!!! error TS2322: Types of property 'children' are incompatible.
67+
!!! error TS2322: Type '() => number' is not assignable to type '(x: LitProps<"x">) => "x"'.
68+
!!! error TS2322: Type 'number' is not assignable to type '"x"'.

0 commit comments

Comments
 (0)