#Adding null or undefined doesn't happen in vscode, but does on tsplayground

5 messages · Page 1 of 1 (latest)

orchid flint
#

I was having an issue and was making a reproducible example in tsplayground, but for some reason it worked. Then I pasted it into my vscode to see that it didn't work there for some reason.

Basically, in tsplayground, the op1 variable has type string | null but on vscode it shows as only string. I can however go ahead and add something like | number on line 23 inside the T[I]["required"] extends false ? HERE : TypeTable[T[I]["type"]] it does show in vscode, just null and undefined don't.

royal flowerBOT
#
Jakob#0130

Preview:```ts
// Library side
enum Types {
A,
B,
C
}

// My code

interface TypeTable {
[Types.A]: string;
[Types.B]: number;
[Types.C]: boolean;
}

type X = {
type: Types;
required: boolean;
}

interface I<T extends readonly X[] = X[]> {
...```

orchid flint
# royal flower

(this isn't showing the entire code but you can click 'playground link' to see it)

#

also adding | null in TypeTable works in playground but not in vscode, maybe this is an issue with the typescript lsp

#

Ok I found a much shorter reproducible:

type Run = (...o: [1 | null]) => null;
const run: Run = (param) => {
  return null;
};```

param is:
in vscode: 1
on tsplayground: 1 | null