Skip to content

Add related span for mixin constructor error #28319

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

Conversation

weswigham
Copy link
Member

Fixes #17504

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.

Just one style suggestion.

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
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.

}
}
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
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
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants