Skip to content

Allowed comment directives to be multiline #38228

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

Conversation

JoshuaKGoldberg
Copy link
Contributor

@JoshuaKGoldberg JoshuaKGoldberg commented Apr 28, 2020

Fixes #37738.

Comment directives still keep track of their start and end lines, but are now keyed by the end instead of the start. The last line of multiline comments can also be parsed now.

@JoshuaKGoldberg JoshuaKGoldberg marked this pull request as ready for review April 28, 2020 09:07
@sandersn sandersn added the For Milestone Bug PRs that fix a bug with a specific milestone label Apr 28, 2020
@DanielRosenwasser
Copy link
Member

@typescript-bot test this
@typescript-bot user test this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Apr 28, 2020

Heya @DanielRosenwasser, I've started to run the extended test suite on this PR at 956ac21. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Apr 28, 2020

Heya @DanielRosenwasser, I've started to run the parallelized community code test suite on this PR at 956ac21. You can monitor the build here.

@DanielRosenwasser
Copy link
Member

@typescript-bot perf test this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Apr 28, 2020

Heya @DanielRosenwasser, I've started to run the perf test suite on this PR at 956ac21. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

The user suite test run you requested has finished and failed. I've opened a PR with the baseline diff from master.

@typescript-bot
Copy link
Collaborator

@DanielRosenwasser
The results of the perf run you requested are in!

Here they are:

Comparison Report - master..38228

Metric master 38228 Delta Best Worst
Angular - node (v10.16.3, x64)
Memory used 327,746k (± 0.02%) 327,175k (± 0.03%) -572k (- 0.17%) 326,988k 327,426k
Parse Time 1.64s (± 0.54%) 1.64s (± 0.56%) +0.00s (+ 0.31%) 1.62s 1.66s
Bind Time 0.89s (± 0.83%) 0.89s (± 0.95%) -0.00s (- 0.11%) 0.87s 0.91s
Check Time 4.79s (± 0.44%) 4.78s (± 0.48%) -0.01s (- 0.25%) 4.72s 4.84s
Emit Time 5.37s (± 0.64%) 5.38s (± 0.50%) +0.00s (+ 0.07%) 5.30s 5.44s
Total Time 12.69s (± 0.34%) 12.68s (± 0.31%) -0.01s (- 0.04%) 12.60s 12.78s
Monaco - node (v10.16.3, x64)
Memory used 327,123k (± 0.01%) 327,194k (± 0.02%) +72k (+ 0.02%) 327,030k 327,324k
Parse Time 1.26s (± 0.58%) 1.27s (± 0.61%) +0.01s (+ 0.55%) 1.25s 1.28s
Bind Time 0.79s (± 0.47%) 0.78s (± 0.86%) -0.01s (- 1.02%) 0.76s 0.79s
Check Time 4.78s (± 0.56%) 4.78s (± 0.57%) +0.00s (+ 0.08%) 4.73s 4.84s
Emit Time 2.95s (± 0.53%) 2.94s (± 0.71%) -0.00s (- 0.14%) 2.88s 2.98s
Total Time 9.77s (± 0.37%) 9.77s (± 0.39%) +0.00s (+ 0.01%) 9.67s 9.86s
TFS - node (v10.16.3, x64)
Memory used 292,132k (± 0.01%) 292,136k (± 0.02%) +3k (+ 0.00%) 292,008k 292,244k
Parse Time 0.96s (± 0.69%) 0.96s (± 0.60%) +0.00s (+ 0.00%) 0.95s 0.97s
Bind Time 0.75s (± 0.89%) 0.75s (± 1.04%) +0.00s (+ 0.27%) 0.74s 0.77s
Check Time 4.31s (± 0.39%) 4.32s (± 0.48%) +0.01s (+ 0.32%) 4.27s 4.37s
Emit Time 3.07s (± 1.16%) 3.08s (± 0.75%) +0.01s (+ 0.36%) 3.03s 3.13s
Total Time 9.09s (± 0.43%) 9.11s (± 0.47%) +0.03s (+ 0.30%) 9.02s 9.21s
material-ui - node (v10.16.3, x64)
Memory used 450,673k (± 0.01%) 450,335k (± 0.01%) -339k (- 0.08%) 450,259k 450,436k
Parse Time 1.79s (± 0.41%) 1.78s (± 0.33%) -0.01s (- 0.62%) 1.77s 1.79s
Bind Time 0.69s (± 0.65%) 0.68s (± 0.72%) -0.00s (- 0.58%) 0.68s 0.70s
Check Time 12.63s (± 0.56%) 12.70s (± 0.79%) +0.07s (+ 0.54%) 12.55s 12.99s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 15.11s (± 0.45%) 15.16s (± 0.66%) +0.05s (+ 0.34%) 15.02s 15.44s
Angular - node (v12.1.0, x64)
Memory used 303,268k (± 0.03%) 302,621k (± 0.09%) -647k (- 0.21%) 301,549k 302,862k
Parse Time 1.59s (± 0.95%) 1.59s (± 0.71%) +0.00s (+ 0.13%) 1.56s 1.62s
Bind Time 0.88s (± 0.91%) 0.87s (± 0.51%) -0.01s (- 0.68%) 0.86s 0.88s
Check Time 4.67s (± 0.56%) 4.68s (± 0.73%) +0.01s (+ 0.26%) 4.60s 4.75s
Emit Time 5.56s (± 0.40%) 5.55s (± 0.97%) -0.01s (- 0.22%) 5.43s 5.67s
Total Time 12.69s (± 0.22%) 12.69s (± 0.71%) -0.01s (- 0.05%) 12.46s 12.88s
Monaco - node (v12.1.0, x64)
Memory used 307,084k (± 0.01%) 307,091k (± 0.02%) +8k (+ 0.00%) 306,977k 307,178k
Parse Time 1.22s (± 0.55%) 1.22s (± 0.55%) +0.01s (+ 0.49%) 1.21s 1.24s
Bind Time 0.75s (± 0.89%) 0.75s (± 1.21%) -0.00s (- 0.13%) 0.73s 0.77s
Check Time 4.59s (± 0.46%) 4.58s (± 0.32%) -0.01s (- 0.22%) 4.54s 4.61s
Emit Time 2.97s (± 0.50%) 2.99s (± 0.69%) +0.02s (+ 0.57%) 2.96s 3.04s
Total Time 9.53s (± 0.28%) 9.54s (± 0.30%) +0.01s (+ 0.14%) 9.48s 9.62s
TFS - node (v12.1.0, x64)
Memory used 274,482k (± 0.01%) 274,430k (± 0.02%) -52k (- 0.02%) 274,300k 274,557k
Parse Time 0.93s (± 0.73%) 0.93s (± 1.17%) -0.00s (- 0.32%) 0.91s 0.96s
Bind Time 0.72s (± 1.85%) 0.72s (± 0.90%) +0.00s (+ 0.28%) 0.71s 0.74s
Check Time 4.23s (± 0.47%) 4.21s (± 0.32%) -0.02s (- 0.54%) 4.18s 4.24s
Emit Time 3.12s (± 0.82%) 3.10s (± 0.76%) -0.02s (- 0.71%) 3.07s 3.17s
Total Time 9.01s (± 0.46%) 8.96s (± 0.34%) -0.04s (- 0.50%) 8.90s 9.03s
material-ui - node (v12.1.0, x64)
Memory used 428,016k (± 0.05%) 427,676k (± 0.05%) -340k (- 0.08%) 426,824k 427,895k
Parse Time 1.76s (± 0.48%) 1.76s (± 0.32%) -0.00s (- 0.06%) 1.75s 1.77s
Bind Time 0.64s (± 0.53%) 0.63s (± 0.88%) -0.00s (- 0.78%) 0.62s 0.65s
Check Time 11.32s (± 0.69%) 11.30s (± 0.70%) -0.02s (- 0.20%) 11.18s 11.54s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 13.72s (± 0.58%) 13.69s (± 0.58%) -0.03s (- 0.22%) 13.56s 13.92s
Angular - node (v8.9.0, x64)
Memory used 322,653k (± 0.02%) 322,218k (± 0.01%) -435k (- 0.13%) 322,121k 322,315k
Parse Time 2.12s (± 0.84%) 2.12s (± 0.32%) -0.01s (- 0.24%) 2.10s 2.13s
Bind Time 0.92s (± 0.39%) 0.92s (± 0.89%) -0.00s (- 0.11%) 0.91s 0.94s
Check Time 5.45s (± 0.98%) 5.42s (± 1.31%) -0.03s (- 0.53%) 5.24s 5.51s
Emit Time 6.27s (± 1.41%) 6.33s (± 1.94%) +0.06s (+ 1.02%) 6.06s 6.63s
Total Time 14.77s (± 0.40%) 14.79s (± 0.54%) +0.03s (+ 0.18%) 14.61s 14.97s
Monaco - node (v8.9.0, x64)
Memory used 325,750k (± 0.02%) 325,736k (± 0.01%) -14k (- 0.00%) 325,652k 325,851k
Parse Time 1.55s (± 0.42%) 1.55s (± 0.52%) +0.00s (+ 0.26%) 1.53s 1.57s
Bind Time 0.90s (± 0.78%) 0.90s (± 0.81%) +0.00s (+ 0.11%) 0.89s 0.92s
Check Time 5.39s (± 0.80%) 5.37s (± 0.34%) -0.02s (- 0.37%) 5.34s 5.43s
Emit Time 3.51s (± 0.51%) 3.51s (± 0.44%) -0.00s (- 0.06%) 3.48s 3.54s
Total Time 11.36s (± 0.42%) 11.34s (± 0.19%) -0.02s (- 0.18%) 11.28s 11.38s
TFS - node (v8.9.0, x64)
Memory used 291,668k (± 0.02%) 291,684k (± 0.01%) +17k (+ 0.01%) 291,568k 291,767k
Parse Time 1.26s (± 0.51%) 1.26s (± 0.54%) +0.00s (+ 0.24%) 1.25s 1.28s
Bind Time 0.75s (± 1.06%) 0.75s (± 0.82%) -0.00s (- 0.40%) 0.74s 0.76s
Check Time 4.95s (± 1.90%) 4.96s (± 1.76%) +0.01s (+ 0.24%) 4.85s 5.13s
Emit Time 3.27s (± 2.84%) 3.26s (± 2.60%) -0.01s (- 0.28%) 3.10s 3.42s
Total Time 10.24s (± 0.83%) 10.23s (± 0.30%) -0.00s (- 0.03%) 10.16s 10.31s
material-ui - node (v8.9.0, x64)
Memory used 453,192k (± 0.01%) 452,924k (± 0.01%) -268k (- 0.06%) 452,856k 452,989k
Parse Time 2.13s (± 0.32%) 2.12s (± 0.78%) -0.01s (- 0.28%) 2.09s 2.17s
Bind Time 0.81s (± 1.16%) 0.81s (± 0.90%) +0.00s (+ 0.25%) 0.80s 0.83s
Check Time 16.74s (± 0.73%) 16.66s (± 0.63%) -0.09s (- 0.51%) 16.44s 16.93s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 19.68s (± 0.65%) 19.59s (± 0.54%) -0.09s (- 0.46%) 19.35s 19.85s
Angular - node (v8.9.0, x86)
Memory used 185,798k (± 0.02%) 185,623k (± 0.03%) -175k (- 0.09%) 185,498k 185,735k
Parse Time 2.06s (± 0.46%) 2.06s (± 0.63%) +0.00s (+ 0.10%) 2.03s 2.09s
Bind Time 1.08s (± 0.81%) 1.07s (± 0.62%) -0.01s (- 0.93%) 1.06s 1.08s
Check Time 4.99s (± 0.43%) 5.00s (± 0.15%) +0.01s (+ 0.14%) 4.98s 5.01s
Emit Time 6.05s (± 1.00%) 6.09s (± 1.05%) +0.04s (+ 0.59%) 5.92s 6.26s
Total Time 14.18s (± 0.48%) 14.22s (± 0.47%) +0.04s (+ 0.28%) 14.03s 14.38s
Monaco - node (v8.9.0, x86)
Memory used 185,579k (± 0.02%) 185,591k (± 0.03%) +11k (+ 0.01%) 185,504k 185,717k
Parse Time 1.59s (± 0.37%) 1.60s (± 0.66%) +0.01s (+ 0.38%) 1.58s 1.62s
Bind Time 0.76s (± 0.62%) 0.77s (± 0.95%) +0.01s (+ 0.66%) 0.76s 0.79s
Check Time 5.41s (± 0.57%) 5.40s (± 0.43%) -0.01s (- 0.13%) 5.36s 5.45s
Emit Time 2.90s (± 0.50%) 2.87s (± 0.59%) -0.03s (- 0.90%) 2.82s 2.91s
Total Time 10.66s (± 0.38%) 10.64s (± 0.31%) -0.02s (- 0.18%) 10.58s 10.74s
TFS - node (v8.9.0, x86)
Memory used 167,069k (± 0.03%) 167,090k (± 0.02%) +22k (+ 0.01%) 167,016k 167,164k
Parse Time 1.29s (± 0.93%) 1.29s (± 0.50%) -0.01s (- 0.39%) 1.27s 1.30s
Bind Time 0.71s (± 1.33%) 0.72s (± 1.26%) +0.00s (+ 0.56%) 0.70s 0.74s
Check Time 4.65s (± 0.51%) 4.65s (± 0.79%) 0.00s ( 0.00%) 4.57s 4.75s
Emit Time 3.03s (± 2.56%) 2.99s (± 1.40%) -0.05s (- 1.52%) 2.89s 3.10s
Total Time 9.70s (± 1.11%) 9.65s (± 0.54%) -0.05s (- 0.52%) 9.49s 9.78s
material-ui - node (v8.9.0, x86)
Memory used 256,668k (± 0.01%) 256,514k (± 0.02%) -154k (- 0.06%) 256,410k 256,662k
Parse Time 2.19s (± 0.68%) 2.19s (± 0.71%) +0.01s (+ 0.32%) 2.17s 2.24s
Bind Time 0.68s (± 0.72%) 0.69s (± 1.27%) +0.01s (+ 0.88%) 0.68s 0.72s
Check Time 15.38s (± 0.65%) 15.38s (± 0.94%) -0.00s (- 0.00%) 15.06s 15.73s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 18.25s (± 0.58%) 18.26s (± 0.77%) +0.01s (+ 0.07%) 17.95s 18.60s
System
Machine Namets-ci-ubuntu
Platformlinux 4.4.0-166-generic
Architecturex64
Available Memory16 GB
Available Memory1 GB
CPUs4 × Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
Hosts
  • node (v10.16.3, x64)
  • node (v12.1.0, x64)
  • node (v8.9.0, x64)
  • node (v8.9.0, x86)
Scenarios
  • Angular - node (v10.16.3, x64)
  • Angular - node (v12.1.0, x64)
  • Angular - node (v8.9.0, x64)
  • Angular - node (v8.9.0, x86)
  • Monaco - node (v10.16.3, x64)
  • Monaco - node (v12.1.0, x64)
  • Monaco - node (v8.9.0, x64)
  • Monaco - node (v8.9.0, x86)
  • TFS - node (v10.16.3, x64)
  • TFS - node (v12.1.0, x64)
  • TFS - node (v8.9.0, x64)
  • TFS - node (v8.9.0, x86)
  • material-ui - node (v10.16.3, x64)
  • material-ui - node (v12.1.0, x64)
  • material-ui - node (v8.9.0, x64)
  • material-ui - node (v8.9.0, x86)
Benchmark Name Iterations
Current 38228 10
Baseline master 10

Copy link
Contributor

@orta orta left a comment

Choose a reason for hiding this comment

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

Systemically looks 👍

@JoshuaKGoldberg
Copy link
Contributor Author

By the way, I realize the turnaround time for my changes on your review comments isn't great - sorry if my responsiveness is holding up getting this in time for 3.9! I wouldn't be offended at all if you added commits to speed it along.

@DanielRosenwasser
Copy link
Member

@typescript-bot pack this

@brieb
Copy link

brieb commented May 1, 2020

Just tried it out on our codebase. :)

We still get errors for multiline comments that used the previous recommended workaround.

image

Though it does now work to change those to be on a single line which looks nicer.

image

But it would be nice for it to be backwards compatible by handling either format.

We have ~919 usages of the old format in our code. And based on the activity here, #27552 it might affect others as well.

I'm happy to upgrade our migration tool to use the new format and fix up these usages, but seems like it'd be nice to avoid this as a breaking change by supporting both.

Would it be possible to add tests for TSX files as well to help catch this in CI?

Thank you for working on this!

@JoshuaKGoldberg
Copy link
Contributor Author

😐 sorry, hit the Close button by accident.

Anyway, 199d256 should allow any amounts of \, /, and * before the @ts- in multiline comments. 👍

@DanielRosenwasser
Copy link
Member

@typescript-bot pack this

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 1, 2020

Heya @DanielRosenwasser, I've started to run the tarball bundle task on this PR at 65a7587. You can monitor the build here.

@DanielRosenwasser
Copy link
Member

Thanks for the quick turnaround @JoshuaKGoldberg! @brieb, a new build should be coming in.

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 1, 2020

Hey @DanielRosenwasser, I've packed this into an installable tgz. You can install it for testing by referencing it in your package.json like so:

{
    "devDependencies": {
        "typescript": "https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/72666/artifacts?artifactName=tgz&fileId=17CEA66AF73BA8F225A7C26F4DAF9E11EBFBDCB20A4C928B6505E8FBB16B603902&fileName=/typescript-4.0.0-insiders.20200501.tgz"
    }
}

and then running npm install.


There is also a playground for this build.

@sheetalkamat
Copy link
Member

Depending on how #38296 is merged we would also need to handled (e860d48) is picked up in it or not, we would need changes to markPrecedingCommentDirectiveLine to handle multiline comments as well?

@brieb
Copy link

brieb commented May 4, 2020

Confirming that the latest build (from #38228 (comment)) works for us.

And, thank you so much for adding TSX tests that would have helped catch the issue!

@DanielRosenwasser
Copy link
Member

@JoshuaKGoldberg looks like we need to re-run baselines. After that we can merge.

@JoshuaKGoldberg
Copy link
Contributor Author

Well, this is a really cool GitHub feature:
image

...but the build breaks are unrelated to this PR.

@orta
Copy link
Contributor

orta commented May 5, 2020

I've updated the PR with the fix from master 👍

@sheetalkamat
Copy link
Member

Do we need test similar to tests/cases/compiler/checkJsFiles_skipDiagnostics and handle multiline comments for scenarios like that

/* @ts-ignore */
/*anopther comment
 that could be multiline*/

some expression with error?

@RyanCavanaugh
Copy link
Member

@typescript-bot cherry-pick this to release-3.9

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 5, 2020

Heya @RyanCavanaugh, I've started to run the task to cherry-pick this into release-3.9 on this PR at b620104. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

Hey @RyanCavanaugh, I've opened #38350 for you.

typescript-bot pushed a commit to typescript-bot/TypeScript that referenced this pull request May 5, 2020
Component commits:
956ac21 Allowed comment directives to be multiline

12749c9 Added tests, and perhaps fixed a test runner bug?

99bb366 I think it's going to need a consistent variable to loop over

a21477d Used dynamically computed indexes in verifies

992441d Added multiline tests

199d256 Increased flexibility for multiline comment parsing

65a7587 Undid a couple of formatting changes; removed backslashes from multiline regexp

036a4ae Merge branch 'master'

b620104 Merge branch 'master' of https://github.com/microsoft/TypeScript into multiline-comment-directives
that could be multiline*/

x();

Copy link
Contributor Author

@JoshuaKGoldberg JoshuaKGoldberg May 6, 2020

Choose a reason for hiding this comment

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

@sheetalkamat sorry, I'm not clear on what you mean by this: #38228 (comment)

Is what you're looking for that a multiline comment containing a directive on its first line should disable the line below it?

If so: sure, I can change the scanner to allow for that. Would you like it to be just the first and last line? Or any line in the comment?

/*another comment
that could be multiline*/

x();
Copy link
Member

Choose a reason for hiding this comment

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

Yes the question is should this be error or not... Since we are talking about multiline scenarios:: and single line skips the single line comments, should we in general be skipping multiline comments as well

Is better approach to check leading trivia of the node (and or its statement/declaration) where the error is being reported instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That makes sense to me as an improvement point, thanks. Do you think we could push that into a separate issue? I'm wary of continuing to add cherry picking work for TS 3.9.

Copy link
Member

Choose a reason for hiding this comment

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

@DanielRosenwasser and @RyanCavanaugh will have final say but i think not having that should be ok for 3.9 since multiline ts-ignore is new anyway so its not regression.

Please open new issue to track pending work in that case.
Thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@DanielRosenwasser DanielRosenwasser merged commit be2eb8a into microsoft:master May 6, 2020
DanielRosenwasser pushed a commit that referenced this pull request May 6, 2020
Component commits:
956ac21 Allowed comment directives to be multiline

12749c9 Added tests, and perhaps fixed a test runner bug?

99bb366 I think it's going to need a consistent variable to loop over

a21477d Used dynamically computed indexes in verifies

992441d Added multiline tests

199d256 Increased flexibility for multiline comment parsing

65a7587 Undid a couple of formatting changes; removed backslashes from multiline regexp

036a4ae Merge branch 'master'

b620104 Merge branch 'master' of https://github.com/microsoft/TypeScript into multiline-comment-directives

Co-authored-by: Orta Therox <[email protected]>
@JoshuaKGoldberg JoshuaKGoldberg deleted the multiline-comment-directives branch May 6, 2020 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Milestone Bug PRs that fix a bug with a specific milestone
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

TSX @ts-ignore comments no longer suppressing errors in TypeScript 3.9
8 participants