-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Prepare tests for --noImplicitAny
#62989
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
base: main
Are you sure you want to change the base?
Conversation
…s with mixed line endings.
Co-authored-by: Copilot <[email protected]>
…ors.txt`" This reverts commit 614be3b.
…ss' into letsDoNoImplicitAny
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR prepares TypeScript's test suite for enabling --noImplicitAny by default (as part of #62333). The change involved analyzing all tests that would have different error output when --noImplicitAny defaults to true, and prepending // @strict: false to tests that should continue to allow implicit any types.
Changes:
- Added
// @strict: falsecompiler directive to test files that rely on implicit any behavior - Used an automated script to prepend the directive while safely handling UTF-16, UTF-8 BOM, non-ASCII characters, and files that already had
@strictor@noImplicitAnydirectives
Reviewed changes
Copilot reviewed 300 out of 2034 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tests/cases/compiler/*.ts (200+ files) | Added // @strict: false directive to compiler test cases that need to preserve implicit any behavior |
| tests/baselines/reference/tsserver/fourslashServer/*.js (5 files) | Updated baseline files to reflect the addition of "strict": false in tsconfig.json compiler options and adjusted line numbers in diagnostic messages |
|
This history is already a nightmare... |
|
On one hand, I feel bad locking so many tests into a mode we basically don't want anyone using, but on the other, that is what they were testing before, so, there's not much difference.... |
|
The problem I'm trying to solve is that I don't want people opening the error baselines of a test to have to deal with dozens of irrelevant errors. Maybe we could add some sort of comment to explain the reason they're off? Then in the future someone could forward-migrate the tests. But maybe just having this PR is enough, and I don't realistically think anyone is going to do that work anyway. |
As preparation for #62333, I looked at all tests that had a difference in errors when
--noImplicitAnydefaulted to true. I basically figured that anything that fails at--noImplicitAnywould fail on--strictas a whole.There's a lot that changed, so I wrote a script that prepended
// @strict: falseto the majority of the tests that had affected output (see below). This was only possible after merging #62987. The script bailed out only if:@strictor@noImplicitAnysomewhere (makes the script re-runnable)One thing you might note about the script is that it operates over globs. I got the globs in a somewhat hacky way - basically, I ran
git statusafter accepting baselines, and replacedtests/baselines/reference/withtests/**/.errors.txtwith*.ts, and/\(.+\)/with nothing.So this won't be all the tests, and technically I might have slapped
// @strict: falseon a few tests that didn't need it. But that is fine since they were already running with strict off, and we're just trying to clear noise from error baselines (both for maintenance and for the eventual PR).Prepending script