Skip to content

Check for parse errors in emitted JS#32009

Merged
weswigham merged 1 commit into
microsoft:masterfrom
weswigham:validate-JS-output
Jul 1, 2019
Merged

Check for parse errors in emitted JS#32009
weswigham merged 1 commit into
microsoft:masterfrom
weswigham:validate-JS-output

Conversation

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

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

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

1 participant