Relative Content

Tag Archive for typescripttypescript-generics

How to specify specific key in Generic type?

type Wrapper<P extends string> = { [P]: string; }; type Wrapped = Wrapper<‘key’>; // valid const wrapped: Wrapped = { key: ‘string’ }; // invalid const wrapped: Wrapped = { k: ‘string’ }; Here we have wrapper with type param P that I want to use to specify a specific key. But it doesn’t looks […]