-
Notifications
You must be signed in to change notification settings - Fork 12.3k
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
Type guard annotations don't work in jsdoc #25127
Comments
On TypeScript 3.0rc I cannot guard function parameters:
|
Based on the above, you should write: - * @return {options is MyOptions}
+ * @return {this is MyOptions} |
Assert
|
@spiffytech try using |
For anyone Googling, this has been fixed by #26297. Use the name of the argument in the // @ts-check
/**
* @param {any} value
* @return {value is boolean}
*/
function isBoolean(value) {
return typeof value === "boolean";
} |
Expected behavior:
Should be equivalent to
And narrow upon calling
isInit
.Actual behavior:
No narrowing, and
Entry.isInit
's return type is just boolean.The text was updated successfully, but these errors were encountered: