Skip to content

getDeclarationOfKind: Improve type safety#15880

Merged
2 commits merged into
masterfrom
getDeclarationOfKind
May 16, 2017
Merged

getDeclarationOfKind: Improve type safety#15880
2 commits merged into
masterfrom
getDeclarationOfKind

Conversation

@ghost
Copy link
Copy Markdown

@ghost ghost commented May 16, 2017

No need for a cast as this function checks the type of its return value.

Comment thread src/services/symbolDisplay.ts Outdated
else {
// Method/function type parameter
let declaration = <Node>getDeclarationOfKind(symbol, SyntaxKind.TypeParameter);
let declaration: Node = getDeclarationOfKind(symbol, SyntaxKind.TypeParameter);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

getDeclarationOfKind<Node> for consistency

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The problem is that it's typed with <T extends Declaration>. The : Node was just there so that declaration could be reassigned later. Fixed by using two separate const declarations instead of the let.

@ghost ghost merged commit ed7ae80 into master May 16, 2017
@ghost ghost deleted the getDeclarationOfKind branch May 16, 2017 22:02
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
This pull request was closed.
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.

2 participants