Skip to content

Fix completion and quick info crash in type parameter in function in type alias #5781

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

Merged
merged 6 commits into from
Nov 30, 2015

Conversation

yuit
Copy link
Contributor

@yuit yuit commented Nov 25, 2015

Fix #4715 and #4616

// For example
// type list<T> = T[]; // Both T will go through same code path
let declaration = <TypeAliasDeclaration>getDeclarationOfKind(symbol, SyntaxKind.TypeParameter).parent;
displayParts.push(keywordPart(SyntaxKind.TypeKeyword));
displayParts.push(spacePart());
addFullSymbolName(declaration.symbol);
Copy link
Member

Choose a reason for hiding this comment

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

declaration may not be defined here with the new if clause

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that is a good point. I will have to come up with different test case when that can happen. My first intuition is that that case should not happen since when we get type parameter, it must be in a declaration. Regardless I will handle the behavior.

if (signatureDeclaration.kind === SyntaxKind.ConstructSignature) {
displayParts.push(keywordPart(SyntaxKind.NewKeyword));
displayParts.push(spacePart());
let declaration = <Node>getDeclarationOfKind(symbol, SyntaxKind.TypeParameter);
Copy link
Member

Choose a reason for hiding this comment

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

When can declaration be undefined? Would it suffice to assert instead ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree that it probably should be assert instead. I will update it

@mhegazy mhegazy changed the title Fix completion and quick info crush in type parameter in function in type alias Fix completion and quick info crash in type parameter in function in type alias Nov 26, 2015
@mhegazy
Copy link
Contributor

mhegazy commented Nov 26, 2015

👍

@weswigham
Copy link
Member

@yuit the failing status on this PR was due to the issue in master - it's fixed now, however to update the status on your PR you'll need to refresh it.


if (declaration) {
if (isFunctionLikeKind(declaration.kind)) {
let signature = typeChecker.getSignatureFromDeclaration(<SignatureDeclaration>declaration);
Copy link
Member

Choose a reason for hiding this comment

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

This should probably be const

@yuit
Copy link
Contributor Author

yuit commented Nov 30, 2015

@weswigham Thanks for the head up!

yuit added a commit that referenced this pull request Nov 30, 2015
Fix completion and quick info crash in type parameter in function in type alias
@yuit yuit merged commit 78ba4b2 into master Nov 30, 2015
@yuit yuit deleted the fix4715 branch November 30, 2015 17:45
@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.

6 participants