TypeScript false error message: Argument type not assignable
Given the following TypeScript code:
type Foo = 'foo' | 'fool';
type Boo = 'boo' | 'bool';
interface FooBoo {
foo:Foo;
boo:Boo;
}
function echo(x: Boo | FooBoo): number {
return 42;
}
const n: number = echo( {foo: 'foo', boo: 'boo'} );
console.log(`n: ${n}`);
EXPECTED: there should be no error indicated on the arguments supplied to the invocation of echo().
Indeed, tsc (version 2.6.2) compiles the code correctly, without complaint. And VS Code (version 1.19.1) also has the expected behavior (no error).
ACTUAL: WebStorm 2017.3.2 (Mac OS X) indicates a type error on the invocation of the echo() function, as shown in attached screenshot.

Please sign in to leave a comment.
already fixed in 2018.1; as workaround, please enable typescript service in Settings | Languages & Frameworks | TypeScript
Great news about the coming fix! And thanks for such a prompt response.
I already had enabled the TypeScript service in the dialog you mentioned.
However, when I went back there to double-check those settings, I noticed that one sub-option that was not checked was "Also for projects without tsconfig.json". And it happens to be the case that neither the project where I originally saw this bug, nor the repro I included above, have tsconfig.json files.
After checking the box for that additional sub-option, it now works as expected.
Hi, I still have this error in spite of the fact that I have a much newer Version of WebStorm (2019.2.1). What can I do to get rid of the error?
I have:
- WebStorm version: 2019.2.1
- TypeScript version: 3.2.4
Thanx a lot.
Your issue must be different, I can't recreate the bug using the original code snippet.
Please share files/self-containing code snippets the issue can be reproduced with