Skip to content

Bracketed @param name doesn't add null | undefined in strict mode #22412

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
sandersn opened this issue Mar 8, 2018 · 1 comment
Closed

Bracketed @param name doesn't add null | undefined in strict mode #22412

sandersn opened this issue Mar 8, 2018 · 1 comment
Assignees
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@sandersn
Copy link
Member

sandersn commented Mar 8, 2018

Code

// @noEmit: true
// @allowJs: true
// @checkJs: true
// @strict: true
// @Filename: a.js

/** @param {number} [p] */
function f(p) {
    p = undefined
    p = null
}

Expected behavior:

The type of p should be number | null | undefined, and should be optional in the signature of f.

Actual behavior:

p is optional but doesn't include null | undefined in its type.

@sandersn
Copy link
Member Author

sandersn commented Mar 8, 2018

Doesn't happen with postfix = types either:

/** @param {number=} p */

@mhegazy mhegazy added Bug A bug in TypeScript Salsa labels Mar 9, 2018
@mhegazy mhegazy added this to the TypeScript 2.8.1 milestone Mar 9, 2018
@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Mar 28, 2018
@microsoft microsoft locked and limited conversation to collaborators Jul 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

2 participants