Skip to content

Add related span for mixin constructor error#28319

Merged
weswigham merged 4 commits intomicrosoft:masterfrom
weswigham:not-a-constructor-function-error
Nov 3, 2018
Merged

Add related span for mixin constructor error#28319
weswigham merged 4 commits intomicrosoft:masterfrom
weswigham:not-a-constructor-function-error

Conversation

@weswigham
Copy link
Copy Markdown
Member

Fixes #17504

Copy link
Copy Markdown
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.

Just one style suggestion.

Comment thread src/compiler/checker.ts Outdated
const err = error(baseTypeNode.expression, Diagnostics.Type_0_is_not_a_constructor_function_type, typeToString(baseConstructorType));
if (baseConstructorType.flags & TypeFlags.TypeParameter) {
const constraint = getConstraintFromTypeParameter(baseConstructorType);
let elaborated = false;
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.

instead of mutating let elaborated = false, I think you can just let ctorReturn = unknownType; and mutate that in the innermost if.

Comment thread src/compiler/checker.ts Outdated
}
}
if (!elaborated) {
addRelatedInfo(err, createDiagnosticForNode(baseConstructorType.symbol.declarations[0], Diagnostics.Did_you_mean_for_0_to_be_constrained_to_type_new_args_Colon_any_1, symbolToString(baseConstructorType.symbol), typeToString(unknownType)));
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.

If you swap mutable elaborated for mutable ctorReturn, you can forgo the if and just say typeToString(ctorReturn)

@DanielRosenwasser
Copy link
Copy Markdown
Member

👍

@weswigham weswigham merged commit eba83f4 into microsoft:master Nov 3, 2018
@weswigham weswigham deleted the not-a-constructor-function-error branch November 3, 2018 00:29
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 21, 2025
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.

3 participants