Skip to content

Check for parse errors in emitted JS #32009

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
merged 1 commit into from
Jul 1, 2019

Conversation

weswigham
Copy link
Member

(When the input is error-free)

Fixes #2818

We have two tests which produce output JS with errors, which probably indicate bugs which need fixing.

There is a small cost to doing this validation, but not too much in aggregate since our parser is fast - only about 5% longer test times. (ofc, if a test is marked @noEmit: true we won't be doing it for that test - so tests where the emit doesn't matter should probably use that option more aggressively). And it already found some bugs, so clearly it is a good thing to check.

==== tests/cases/compiler/emitBOM.js (2 errors) ====
// JS and d.ts output should have a BOM but not the sourcemap

!!! error TS1127: Invalid character.
Copy link
Member Author

Choose a reason for hiding this comment

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

@rbuckton you know what's up with the BOM here? I suspect it's actually an issue with the test harness not roundtripping the BOM correctly (maybe by not reading the output string with the correct encoding) and not a parse/emit bug, but I can't be sure.

@weswigham weswigham force-pushed the validate-JS-output branch from efe76c0 to 3fc4d8b Compare July 1, 2019 20:44
@weswigham weswigham merged commit 055a07e into microsoft:master Jul 1, 2019
@weswigham weswigham deleted the validate-JS-output branch July 1, 2019 21:15
@weswigham
Copy link
Member Author

I've merged this so we catch future failure-to-roundtrip bugs. I still don't know what's up with that BOM roundtrip, though.

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.

Add a step to verify the JS emitted by the tests is valid
1 participant