Skip to content

Commit 4dc85dc

Browse files
Accepted baselines.
1 parent 64c9632 commit 4dc85dc

2 files changed

Lines changed: 62 additions & 0 deletions

File tree

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
tests/cases/conformance/types/contextualTypes/jsxAttributes/contextuallyTypedStringLiteralsInJsxAttributes01.tsx(11,15): error TS2322: Type 'string' is not assignable to type '"A" | "B" | "C"'.
2+
Type 'string' is not assignable to type '"C"'.
3+
tests/cases/conformance/types/contextualTypes/jsxAttributes/contextuallyTypedStringLiteralsInJsxAttributes01.tsx(13,15): error TS2322: Type '"f"' is not assignable to type '"A" | "B" | "C"'.
4+
Type '"f"' is not assignable to type '"C"'.
5+
tests/cases/conformance/types/contextualTypes/jsxAttributes/contextuallyTypedStringLiteralsInJsxAttributes01.tsx(14,15): error TS2322: Type 'string' is not assignable to type '"A" | "B" | "C"'.
6+
Type 'string' is not assignable to type '"C"'.
7+
8+
9+
==== tests/cases/conformance/types/contextualTypes/jsxAttributes/contextuallyTypedStringLiteralsInJsxAttributes01.tsx (3 errors) ====
10+
11+
namespace JSX {
12+
interface IntrinsicElements {
13+
span: {};
14+
}
15+
}
16+
17+
const FooComponent = (props: { foo: "A" | "B" | "C" }) => <span>{props.foo}</span>;
18+
19+
<FooComponent foo={"A"} />;
20+
<FooComponent foo="A" />;
21+
~~~~~~~
22+
!!! error TS2322: Type 'string' is not assignable to type '"A" | "B" | "C"'.
23+
!!! error TS2322: Type 'string' is not assignable to type '"C"'.
24+
25+
<FooComponent foo={"f"} />;
26+
~~~~~~~~~
27+
!!! error TS2322: Type '"f"' is not assignable to type '"A" | "B" | "C"'.
28+
!!! error TS2322: Type '"f"' is not assignable to type '"C"'.
29+
<FooComponent foo="f" />;
30+
~~~~~~~
31+
!!! error TS2322: Type 'string' is not assignable to type '"A" | "B" | "C"'.
32+
!!! error TS2322: Type 'string' is not assignable to type '"C"'.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//// [contextuallyTypedStringLiteralsInJsxAttributes01.tsx]
2+
3+
namespace JSX {
4+
interface IntrinsicElements {
5+
span: {};
6+
}
7+
}
8+
9+
const FooComponent = (props: { foo: "A" | "B" | "C" }) => <span>{props.foo}</span>;
10+
11+
<FooComponent foo={"A"} />;
12+
<FooComponent foo="A" />;
13+
14+
<FooComponent foo={"f"} />;
15+
<FooComponent foo="f" />;
16+
17+
//// [contextuallyTypedStringLiteralsInJsxAttributes01.jsx]
18+
var FooComponent = function (props) { return <span>{props.foo}</span>; };
19+
<FooComponent foo={"A"}/>;
20+
<FooComponent foo="A"/>;
21+
<FooComponent foo={"f"}/>;
22+
<FooComponent foo="f"/>;
23+
24+
25+
//// [contextuallyTypedStringLiteralsInJsxAttributes01.d.ts]
26+
declare namespace JSX {
27+
}
28+
declare const FooComponent: (props: {
29+
foo: "A" | "B" | "C";
30+
}) => any;

0 commit comments

Comments
 (0)