jsdoc type union, comparison overlap

41 Views Asked by At

The code:

// @ts-check
/** @type {('standalone' | 'export' | undefined)} */
const output = 'standalone';

output === 'export'; // <-- this generates an `typescript 2367` error

Typescript 2367 Errror: This comparison appears to be unintentional because the types '"standalone"' and '"export"' have no overlap

Using JSDoc, how can I could solve this kind of problem?

I just tried typedef the value first, I tried to follow some cheatsheets, but, I have no idea anymore.

some sources:

0

There are 0 best solutions below