You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Search Terms: Omit merged interface, Generic type with declaration merging
Code
interfaceTodoextendsRecord<string,any>{title: stringdescription: stringcompleted: boolean}interfaceTodoextendsRecord<string,any>{tags: string[]}consttodo: Omit<Todo,'description'>={title: 'Todo 1',completed: false,tags: [''],}consttrimedTags=todo.tags.map(tag=>tag.trim())// tags is considered as 'any' here.
Expected behavior:
Using Omit<> on types defining index types ([key: xxx]), the types from merged interface should remain defined and not fallback to the specified index type.
Actual behavior:
Any types from the merged interface are transformed to 'any' or 'unknown', as if they were only part of the index type, but they are actually defined. I expect them to keep their defined type from the merged interface.
TypeScript Version: v4.1.0-dev.20201008
Search Terms: Omit merged interface, Generic type with declaration merging
Code
Expected behavior:
Using
Omit<>
on types defining index types ([key: xxx]
), the types from merged interface should remain defined and not fallback to the specified index type.Actual behavior:
Any types from the merged interface are transformed to 'any' or 'unknown', as if they were only part of the index type, but they are actually defined. I expect them to keep their defined type from the merged interface.
It works well using
Pick<>
though.Playground Link:
Here is a playground showing the error.
Related Issues:
Indexed access operator issue with Omit type #36316
The text was updated successfully, but these errors were encountered: