Skip to content

Salsa: declaring function types using @typedef is not working #23722

New issue

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

Closed
mohsen1 opened this issue Apr 26, 2018 · 2 comments
Closed

Salsa: declaring function types using @typedef is not working #23722

mohsen1 opened this issue Apr 26, 2018 · 2 comments

Comments

@mohsen1
Copy link
Contributor

mohsen1 commented Apr 26, 2018

Not sure if this is the right syntax for declaring a function in JSDoc but if it is, it's not working.

TypeScript Version: 2.9

Search Terms:
@typedef function Salsa
Code

/**
 * @typedef {Function} SortCallback
 * @param {number} a
 * @param {number} b
 * @returns {number}
 */

 /** @type {SortCallback} */
 var fn = function(a, b) { return 1};

 [1,2,3,5].sort(fn);

Expected behavior:
No Error

Actual behavior:


index.js(11,17): error TS2345: Argument of type 'Function' is not assignable to parameter of type '((a: number, b: number) => number) | undefined'.
  Type 'Function' is not assignable to type '(a: number, b: number) => number'.
    Type 'Function' provides no match for the signature '(a: number, b: number): number'.
error An unexpected error occurred: "Command failed.
Exit code: 2
Command: sh
Arguments: -c /Users/mazimi/Projects/ts-bug/node_modules/.bin/tsc
Directory: /Users/mazimi/Projects/ts-bug
Output:
".
info If you think this is a bug, please open a bug report with the information provided in "/Users/mazimi/Projects/ts-bug/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
@mhegazy
Copy link
Contributor

mhegazy commented Apr 26, 2018

I do not think this is a supported use of typedef. we should just support @callback for such cases, that is tracked by #7515

@mohsen1
Copy link
Contributor Author

mohsen1 commented Apr 27, 2018

Thanks! I think @callback is the right syntax as well

@mohsen1 mohsen1 closed this as completed Apr 27, 2018
@microsoft microsoft locked and limited conversation to collaborators Jul 31, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants