Skip to content

getEffectiveTypeParameterDeclarations: Always return a defined result #24251

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
1 commit merged into from
May 18, 2018

Conversation

ghost
Copy link

@ghost ghost commented May 18, 2018

This simplifies most of the uses of this function and helps with --strictNullChecks.

@ghost ghost requested a review from sandersn May 18, 2018 16:56
Copy link
Member

@sandersn sandersn left a comment

Choose a reason for hiding this comment

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

Looks good, just one question about how the old code even worked before.

@@ -28199,8 +28196,8 @@ namespace ts {

function checkGrammarConstructorTypeParameters(node: ConstructorDeclaration) {
const typeParameters = getEffectiveTypeParameterDeclarations(node);
if (typeParameters) {
const { pos, end } = isNodeArray(typeParameters) ? typeParameters : first(typeParameters);
if (isNodeArray(typeParameters)) {
Copy link
Member

Choose a reason for hiding this comment

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

Based on my reading of the new code, isNodeArray is only false when typeParameters is empty. So how did first(typeParameters) ever work? Was it just dead code?

Copy link
Author

Choose a reason for hiding this comment

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

Yep, dead code. Maybe we should be linting that we never call isFoo(x) if x is already Foo, or is a type not assignable to Foo. (E.g. we shouldn't be able to call isIfStatement on an Expression.)

@ghost ghost merged commit 76573c6 into master May 18, 2018
@ghost ghost deleted the getEffectiveTypeParameterDeclarations branch May 18, 2018 17:17
@microsoft microsoft locked and limited conversation to collaborators Jul 31, 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.

1 participant