Skip to content

Type alias substitution does not work #31616

New issue

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

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

Already on GitHub? # to your account

Closed
reverofevil opened this issue May 28, 2019 · 3 comments · Fixed by #52742
Closed

Type alias substitution does not work #31616

reverofevil opened this issue May 28, 2019 · 3 comments · Fixed by #52742
Assignees
Labels
Bug A bug in TypeScript Domain: Type Inference Related to type inference performed during signature resolution or `infer` type resolution Fix Available A PR has been opened for this issue Rescheduled This issue was previously scheduled to an earlier milestone

Comments

@reverofevil
Copy link

TypeScript Version: 3.5.0-dev.20190525

Search Terms:
type substitution is incorrect

Code

const v = { test: { smth: 5 } };
type Field<A extends string, R> = { [K in A]: R } | {}
const f = <A extends string, B extends string, R>(x: { [K in A]: Field<B, R> } | {}): R => ({} as any);
const g = <A extends string, B extends string, R>(x: Field<A, Field<B, R>>): R => ({} as any);
const r1 = f(v); // number
const r2 = g(v); // unknown

Expected behavior:
Both should be number.

Actual behavior:
unknown

Playground Link:
Link

Related Issues:
Nope.

@RyanCavanaugh RyanCavanaugh added the Needs Investigation This issue needs a team member to investigate its status. label May 28, 2019
@RyanCavanaugh
Copy link
Member

Regressed between 2.3 and 2.4

Removed suspect | {}:

const v = { test: { smth: 5 } };
type Field<A extends string, R> = { [K in A]: R };
const f = <A extends string, B extends string, R>(x: { [K in A]: Field<B, R> } ): R => ({} as any);
const g = <A extends string, B extends string, R>(x: Field<A, Field<B, R>>): R => ({} as any);
const r1 = f(v); // number
const r2 = g(v); // unknown

@weswigham
Copy link
Member

Regression caused by #15863 - potential fix is up at #31633 - I need to run RWC to validate fp-ts doesn't OOM (which was what originally prompted the original change that caused the regression), since the change introducing the regression didn't come with any baked-in tests ❤️

@weswigham weswigham added Bug A bug in TypeScript Domain: Type Inference Related to type inference performed during signature resolution or `infer` type resolution and removed Needs Investigation This issue needs a team member to investigate its status. labels May 28, 2019
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 3.6.0 milestone Jun 12, 2019
@weswigham weswigham added the Fix Available A PR has been opened for this issue label Jul 15, 2019
@RyanCavanaugh RyanCavanaugh added the Rescheduled This issue was previously scheduled to an earlier milestone label May 20, 2020
@RyanCavanaugh RyanCavanaugh removed this from the TypeScript 4.0 milestone Jun 29, 2020
@RyanCavanaugh
Copy link
Member

These are both number now as expected

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Bug A bug in TypeScript Domain: Type Inference Related to type inference performed during signature resolution or `infer` type resolution Fix Available A PR has been opened for this issue Rescheduled This issue was previously scheduled to an earlier milestone
Projects
None yet
5 participants