-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Mapped types shouldn't transform unknown type #29793
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
Comments
@falsandtru Doesn't seem to have to do with it being recursive, type Mapped<T> = { [P in keyof T]: T[P] }
type m_unknown = Mapped<unknown> // {}
type m_any = Mapped<any> // { [x: string]: any; }
type m_never = Mapped<never> // never |
This is definitely not a regression, mapped types have behaved this way since the introduction of the |
@ahejlsberg I judged that this is a regression since the following code make an error since 3.4.0-dev.20190207: https://github.com/falsandtru/spica/blob/v0.0.222/src/type.test.ts#L368 |
The essential issue is mapped types replace type Mapped<T> =
{ [P in keyof T]: T[P]; };
type a = Mapped<unknown>; Conditional types are not related. The difference of the behavior since that day is the return type of |
unknown
type with {}
type
unknown
type with {}
type
@ahejlsberg Probably #29740 made this regression.
TypeScript Version: 3.4.0-dev.20190207
Search Terms:
Code
Expected behavior:
i
is{ readonly a: unknown; }
.Actual behavior:
i
is{ readonly a: {}; }
.Playground Link:
Related Issues:
The text was updated successfully, but these errors were encountered: