Skip to content

Update baselines missed in PR #53281

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 115 additions & 0 deletions tests/baselines/reference/intraExpressionInferencesJsx.errors.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
tests/cases/conformance/types/typeRelationships/typeInference/intraExpressionInferencesJsx.tsx(107,17): error TS18046: 'arg' is of type 'unknown'.


==== tests/cases/conformance/types/typeRelationships/typeInference/intraExpressionInferencesJsx.tsx (1 errors) ====
/// <reference path="/.lib/react16.d.ts" />

// repro from #52798

type A = {
a: boolean;
};

type B = {
b: string;
};

type C = {
c: number;
};

type Animations = {
[key: string]: { value: number } & (
| ({ kind: "a"; func?(): Partial<A> } & A)
| ({ kind: "b"; func?(): Partial<B> } & B)
| ({ kind: "c"; func?(): Partial<C> } & C)
);
};

type StyleParam<T extends Animations> = Record<keyof T, string>;

type AnimatedViewProps<T extends Animations> = {
style: (animationsValues: StyleParam<T>) => string;
animations: T;
};

const Component = <T extends Animations>({
animations,
style,
}: AnimatedViewProps<T>) => <></>;

<Component
animations={{
test: {
kind: "a",
value: 1,
a: true,
},
}}
style={(anim) => {
return "";
}}
/>;
<Component
animations={{
test: {
kind: "a",
value: 1,
a: true,
func() {
return {
a: true,
};
},
},
}}
style={(anim) => {
return "";
}}
/>;
<Component
animations={{
test: {
kind: "a",
value: 1,
a: true,
func: () => {
return {
a: true,
};
},
},
}}
style={(anim) => {
return "";
}}
/>;

// repro from #52786

interface Props<T> {
a: (x: string) => T;
b: (arg: T) => void;
}

function Foo<T>(props: Props<T>) {
return <div />;
}

<Foo
a={() => 10}
b={(arg) => { arg.toString(); }}
/>;

<Foo
a={(x) => 10}
b={(arg) => { arg.toString(); }}
/>;

<Foo {...{
a: (x) => 10,
b: (arg) => { arg.toString(); },
~~~
!!! error TS18046: 'arg' is of type 'unknown'.
}} />;
Comment on lines +109 to +114
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I see this is the only "unwanted" change that has been found on main. However... this is exactly how regular call expressions work: TS playground. So perhaps... this was just working accidentally before. I feel like this should be a separate issue to make it work for both JSX and regular calls (if that's desired)


Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,7 @@ function Foo<T>(props: Props<T>) {
b: (arg) => { arg.toString(); },
>b : Symbol(b, Decl(intraExpressionInferencesJsx.tsx, 105, 15))
>arg : Symbol(arg, Decl(intraExpressionInferencesJsx.tsx, 106, 6))
>arg.toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --))
>arg : Symbol(arg, Decl(intraExpressionInferencesJsx.tsx, 106, 6))
>toString : Symbol(Number.toString, Decl(lib.es5.d.ts, --, --))

}} />;

16 changes: 8 additions & 8 deletions tests/baselines/reference/intraExpressionInferencesJsx.types
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ function Foo<T>(props: Props<T>) {
<Foo {...{
><Foo {...{ a: (x) => 10, b: (arg) => { arg.toString(); },}} /> : JSX.Element
>Foo : <T>(props: Props<T>) => JSX.Element
>{ a: (x) => 10, b: (arg) => { arg.toString(); },} : { a: (x: string) => number; b: (arg: number) => void; }
>{ a: (x) => 10, b: (arg) => { arg.toString(); },} : { a: (x: string) => number; b: (arg: unknown) => void; }

a: (x) => 10,
>a : (x: string) => number
Expand All @@ -285,13 +285,13 @@ function Foo<T>(props: Props<T>) {
>10 : 10

b: (arg) => { arg.toString(); },
>b : (arg: number) => void
>(arg) => { arg.toString(); } : (arg: number) => void
>arg : number
>arg.toString() : string
>arg.toString : (radix?: number | undefined) => string
>arg : number
>toString : (radix?: number | undefined) => string
>b : (arg: unknown) => void
>(arg) => { arg.toString(); } : (arg: unknown) => void
>arg : unknown
>arg.toString() : any
>arg.toString : any
>arg : unknown
>toString : any

}} />;

Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ declare const otherProps: { bar: string, qwe: boolean }
declare function GenericComponent<T>(props: T): null
>GenericComponent : <T>(props: T) => null
>props : T
>null : null

<GenericComponent {...omit(['bar'], otherProps)} />; // no error
><GenericComponent {...omit(['bar'], otherProps)} /> : JSX.Element
Expand Down