microsoft / vscode-typescript-tslint-plugin

VS Code extension that provides TSLint support using the typescript-tslint-plugin
https://marketplace.visualstudio.com/items?itemName=ms-vscode.vscode-typescript-tslint-plugin
MIT License
188 stars 35 forks source link

TSLint does not recognize a union type problem (unless I cause another) #133

Closed johndoe457 closed 3 years ago

johndoe457 commented 4 years ago

Here is an intuitive simplification, the minimal code needed to produce the problem:

type User =
    { isMale: true }
    | ({ isMale: false } & (
          { isPregnant: true;}
          | { isPregnant: false;}
      ));

const johnDoe: User = {
    isMale: true,
    isPregnant: true,
};

I should, of course, get a ts(2322) error, as johnDoe somehow went against nature and is now pregnant, but it doesn't show it as a problem.

Now, what's interesting, is that if I cause another error, for example:

const johnDoe: User = {
    isMale: true,
    isPregnant: true,
    pi: 3.14,
};

Now I get the ts(2322) error for the isPregnant property, doesn't matter if the new wrong property (pi) is declared before or after the isPregnant property.

mjbvz commented 3 years ago

Without more context, this sounds like a general TypeScript error and not a tslint problem. Please file this against TypeScript