- Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug
Description
TypeScript Version: 3.9.2
Search Terms:
omit, insection types
Code
interfaceUser{type: 'user';name: string;age: number;occupation: string;}interfaceAdmin{type: 'admin';name: string;age: number;role: string;}typePowerUser=Omit<User&Admin,'type'>&{type: 'powerUser'};letp: PowerUser={type: 'powerUser',name: 'hello',age: 123,occupation: '123',role: '123'}console.log(p)Expected behavior:
no error
Actual behavior:
test.ts:21:3 - error TS2322: Type 'string' is not assignable to type 'never'. 21 name: 'hello', ~~~~ test.ts:22:3 - error TS2322: Type 'number' is not assignable to type 'never'. 22 age: 123, ~~~ test.ts:23:3 - error TS2322: Type 'string' is not assignable to type 'never'. 23 occupation: '123', ~~~~~~~~~~ test.ts:24:3 - error TS2322: Type 'string' is not assignable to type 'never'. 24 role: '123' ~~~~ Metadata
Metadata
Assignees
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug