#How to preserve stirng union inside of an object

6 messages · Page 1 of 1 (latest)

abstract saddleBOT
#
autumnlight#0

Preview:```ts
class Extension<T extends string> {
name: T
constructor(args: T) {
this.name = args
}
}

const g = new Extension("f")
g.name
// ^?

class _Extension<T extends {test: string}> {
name: T
constructor(args: T) {
this.name = args
}
}

const g2 = new _Extension({test: "f"})
...```

round tartan
gray pumice
round tartan
#

FacePalm you saved my day

#

Thank you @gray pumice

gray pumice
#

You're welcome
Please !close the thread if you have no follow-up questions