Lint to ensure CompilerOptions and options in commandLineParser are synchronized#58312
Lint to ensure CompilerOptions and options in commandLineParser are synchronized#58312weswigham wants to merge 13 commits intomicrosoft:mainfrom
Conversation
| }, | ||
| "compilerOptions": {}, | ||
| "compilerOptions": { | ||
| "allowNonTsExtensions": true |
There was a problem hiding this comment.
The LS sets allowNonTsExtensions for any project with js and any inferred project forcibly - this wasn't reflected in telemetry (and all these baselines), since without an options declaration, the serializer couldn't serialize the option.
f494cc6 to
d5b24f8
Compare
|
This PR no longer has any functional changes, and instead just has a lint rule to check that Running it exposed a couple more internal compiler options we didn't have option definitions for that I didn't already know about. |
| internal: true, | ||
| extraValidation() { | ||
| return [Diagnostics.Unknown_compiler_option_0, "allowNonTsExtensions"]; | ||
| }, |
There was a problem hiding this comment.
If an option is marked internal, can extraValidation always just issue this wherever that func is called? Or is that too annoying? Seems like this is copy/pasted a bunch, but I guess not for anything outside this block?
|
It feels a little weird to enforce this via a lint rule, but I guess if it's too annoying to do statically... |
|
we have testcase which checks if allaffectsSemanticDiagnostics are marked as affectsBuildInfo as well. May be some test case like that would be better than lint rule
|
The perk of the lint rule is that it has an autofixer (that adds the missing declarations to whichever side of the pair of declarations is missing one) - not so for a test. |
A number of our
@internaloptions were missing from our option definitions incommandLineParser.ts, which in turn causes us to elide them from telemetry, even though we may forcibly set them in the language service.This PR adds a lint rule that compares the
CompilerOptionsinterface and the option definitions incommandLineParser.tsand ensures their state is synchronized. It also adds aninternalfield to command line option definitions whose only purpose is tracking which options are@internalannotated. This is currently unused but should be a good runtime indicator to anyone looking over our option definitions which ones aren't meant to be used publicly. This field is also synchronized by the lint.