#Prevent widening using string template

1 messages · Page 1 of 1 (latest)

lone masonBOT
#
evan.trimboli#0

Preview:```ts
type ItemType = "foo" | "bar"

const getType = (): ItemType => "foo"

const t = getType()

const s1 = t === "foo" ? "myapp/foo" : "myapp/bar"
const s2 = `myapp/${t}````

viral plaza
#

Is there a way to make s2 infer the same type as s1?

#

I guess I could just use as const