Preview:```ts
type Foobar = {
foo?: "bar"
}
const test = "whatever" as unknown as Foobar["foo"]
//^?```
You can choose specific lines to embed by selecting them before copying the link.
10 messages · Page 1 of 1 (latest)
Preview:```ts
type Foobar = {
foo?: "bar"
}
const test = "whatever" as unknown as Foobar["foo"]
//^?```
test shows it can be "bar" | undefined how can I make it be just "bar" ?
my only solution i could find is to put Foobar into Required, like this:
const test = "whatever" as unknown as Required<Foobar>["foo"];
is this the right way?
NonNullable<> works too
NonNullable over the nullable thing, NonNullable<FooBar["foo"]>