Skip to content

Fix babel-ts to emit a proper syntax error for (a:b)#8046

Merged
thorn0 merged 1 commit intoprettier:masterfrom
thorn0:TSTypeCastExpression
May 15, 2020
Merged

Fix babel-ts to emit a proper syntax error for (a:b)#8046
thorn0 merged 1 commit intoprettier:masterfrom
thorn0:TSTypeCastExpression

Conversation

@thorn0
Copy link
Copy Markdown
Member

@thorn0 thorn0 commented Apr 13, 2020

Show a proper syntax error instead.

Fixes #8041

  • I’ve added tests to confirm my change works.
  • (If changing the API or CLI) I’ve documented the changes I’ve made (in the docs/ directory)
  • (If the change is user-facing) I’ve added my changes to changelog_unreleased/*/pr-XXXX.md file following changelog_unreleased/TEMPLATE.md.
  • I’ve read the contributing guidelines.

Try the playground for this PR

@thorn0 thorn0 force-pushed the TSTypeCastExpression branch from e11d7f7 to a46bf82 Compare May 10, 2020 22:03
@thorn0 thorn0 changed the title fix babel-ts so that it doesn't crash on (a:b) Fix babel-ts to emit a proper syntax error for (a:b) May 10, 2020
@thorn0 thorn0 marked this pull request as ready for review May 10, 2020 22:04
@fisker
Copy link
Copy Markdown
Member

fisker commented May 13, 2020

Is it possible to access this TSErrors?

@thorn0
Copy link
Copy Markdown
Member Author

thorn0 commented May 13, 2020

No, they aren't exported.

@fisker
Copy link
Copy Markdown
Member

fisker commented May 13, 2020

function getTSUnexpectedTypeAnnotation() {
	try{
	  parser('(a:b)');
	} catch({message}){
	  return message;
	}
}

Too hacky? 😄

@thorn0
Copy link
Copy Markdown
Member Author

thorn0 commented May 13, 2020

We have it under control. The test will fail if the message suddenly changes.

@thorn0 thorn0 merged commit 5dcadf4 into prettier:master May 15, 2020
@thorn0 thorn0 deleted the TSTypeCastExpression branch July 8, 2020 22:29
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 9, 2021
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.

babel-ts crashes on (a:b)

2 participants