Typescript doesn't infer correct type with Generic extending string union type?
06:03 13 Feb 2020
type Test = 'a' | 'b' | 'c';

function foo(arg: T) {
  if (arg === 'a') {
    console.log(arg);
  }
}

like this.. I expect arg inferred 'a' in if block.

but ts infer as just T.

why this situation?

I think that extends keyword has something...

typescript typescript-typings