Skip to content

Signatures use JSDoc to determine optionality#9303

Merged
sandersn merged 2 commits into
masterfrom
signatures-use-jsdoc-for-minArgumentCount
Jun 22, 2016
Merged

Signatures use JSDoc to determine optionality#9303
sandersn merged 2 commits into
masterfrom
signatures-use-jsdoc-for-minArgumentCount

Conversation

@sandersn
Copy link
Copy Markdown
Member

Fixes #9228

Comment thread src/compiler/checker.ts Outdated

if (hasQuestionToken(node)) {
function isOptionalParameter(node: ParameterDeclaration) {
if (isJSDocOptionalParameter(node) || hasQuestionToken(node)) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Swap this check around so that the TS check is faster for the positive case.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe. Isn't flags & NodeFlags.JavaScriptFile faster than switch(node.kind) with 7 cases? In other words, I think the speed gain will be absolutely tiny. And the code was originally written in this order, although that's (apparently) not meaningful.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regardless of performance, I think I like the way it reads better to flip it.

@mhegazy
Copy link
Copy Markdown
Contributor

mhegazy commented Jun 22, 2016

👍

@sandersn sandersn merged commit 9134ed3 into master Jun 22, 2016
@sandersn sandersn deleted the signatures-use-jsdoc-for-minArgumentCount branch June 22, 2016 22:04
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 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

Successfully merging this pull request may close these issues.

4 participants