Skip to content
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

Improve error message in types assert #7001

Merged
merged 1 commit into from
Dec 11, 2017
Merged

Conversation

existentialism
Copy link
Member

Q                       A
Fixed Issues?
Patch: Bug Fix? n
Major: Breaking Change? n
Minor: New Feature? n
Tests Added + Pass? y/y
Documentation PR
Any Dependency Changes?
License MIT

From our slack convo, minor but improves the error message a bit.

@existentialism existentialism added the PR: Polish 💅 A type of pull request used for our changelog categories label Dec 8, 2017
@babel-bot
Copy link
Collaborator

babel-bot commented Dec 8, 2017

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/6144/

@@ -18,7 +18,7 @@ import is from "../../validators/is";
function assert(type: string, node: Object, opts?: Object): void {
if (!is(type, node, opts)) {
throw new Error(
\`Expected type "\${type}" with option \${JSON.stringify(opts)}\`,
\`Expected type "\${type}" with option \${JSON.stringify(opts)}, but instead got "\${node.type}".\`,
Copy link
Member

Choose a reason for hiding this comment

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

Can you break this line like in the generated file? Otherwise we will need to make fix every time that it is recreated.

Copy link
Member Author

Choose a reason for hiding this comment

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

I can for consistency sake, but the generated files are auto "prettified" via:
https://github.com/babel/babel/blob/master/packages/babel-types/scripts/utils/formatCode.js

Copy link
Member

Choose a reason for hiding this comment

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

Ah ok, nevermind then

@existentialism existentialism merged commit 42f6678 into master Dec 11, 2017
@existentialism existentialism deleted the improve-assert-error branch December 11, 2017 15:32
@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Oct 5, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Polish 💅 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants