I'm writing JS with a jsconfig.json
in order to provide extra TS type checking.
The issue is that the TS language server doesn't seem to be smart enough or equipped to handle such situations. I get the following error:
Types of property 'mode' are incompatible.
Type 'string' is not assignable to type '"production" | "development"'.
for the following code:
return {
...
mode: isProd ? 'production' : 'development',
}
I completely understand why this is an error and how to solve it in TS (see https://stackoverflow.com/a/37978675/15388164), but in JS, we don't have type or const assertions.
Is there a good way to deal with this? I use this config in half a dozen spots, so I don't want to //@ts-ignore
every site. If anything, I'd like to disable these 'string is not assignable to other strings' issues altogether as they provide no value in JS as far as I can see. The types will always be inferred incorrectly.