Microsoft/TypeScript
GitHub ã§èŠãEmpty types and types with `never` as a key behave differently
Open
#56,691 opened on 2023幎12æ6æ¥
BugDomain: Mapped TypesHelp Wanted
Repository metrics
- Stars
- Â (48,455 stars)
- PR merge metrics
-  (å¹³åããŒãž 6d 17h) (30d ã§ 9 merged PRs)
説æ
ð Search Terms
Mapped type unknown
ð Version & Regression Information
- This changed between versions 4.7.4 and 4.8.4
⯠Playground Link
ð» Code
declare const u: unknown;
type A = {[K in never]: any}
// ^?
// No Error
const a: null | undefined | {} = u;
// ^?
// Error
const b: null | undefined | A = u;
// ^?
ð Actual behavior
The types a and b appear to be the same, but only the assignment to b causes an error.
ð Expected behavior
I'm not sure which is better, I think it's either no error or both errors.
Additional information about the issue
Both were errors in version 4.7.4