We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
There are multiple ways to do it, for example:
/** * @type {{ * (a: number, b: number): number; * (a: string, b: string): string; * }} */ const add = function(a, b) { return a + b; } const addString = add("a", "b"); const addNumber = add(1, 2); /** * @type {{ * (input: number): number; * (input: string): string; * }} */ const double = (input) => { if (typeof input === 'number') { return input * 2 } return input + input; } const doubleString = double("test"); const doubleNumber = double(123);
TS Playground
But it looks very strange and even shows errors in TS Playground... personally I think this would be nice:
/** * @typedef {(a: number, b: number) => number} AddNumber * @typedef {(a: string, b: string) => string} AddString * @type {AddNumber | AddString} */ function add(a, b) { return a + b; }
(but that style isn't supported by TS so far)
The text was updated successfully, but these errors were encountered:
kungfooman
No branches or pull requests
There are multiple ways to do it, for example:
TS Playground
But it looks very strange and even shows errors in TS Playground... personally I think this would be nice:
(but that style isn't supported by TS so far)
The text was updated successfully, but these errors were encountered: