Microsoft/TypeScript
在 GitHub 查看Empty types and types with `never` as a key behave differently
Open
#56,691 建立於 2023年12月6日
BugDomain: Mapped TypesHelp Wanted
倉庫指標
- Star
- (48,455 star)
- PR 合併指標
- (平均合併 6天 17小時) (30 天內合併 9 個 PR)
描述
🔎 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