#Generics with prop and param on object

4 messages · Page 1 of 1 (latest)

slow tangle
#

!:screenshot

coarse sequoiaBOT
#
retsam19#0
`!retsam19:screenshot`:

Rather than screenshots, please provide either code formatted as:

```ts
// code here
```
Or even better, as an example on the Typescript playground https://www.typescriptlang.org/play that is as simple as possible and reproduces the issue. This makes it easier to help you and increases the chances of getting an answer.

slow tangle
#

You can use satisfies and change it slightly:

coarse sequoiaBOT
#
type A<T> = {
    b: T
    c: (d: T) => void
}

const a = {
    b: 'a',
    c: (d) => {},
//      ^? - (parameter) d: "a"
} satisfies A<'a'> | A<'b'> | A<'c'>