Open weswigham opened 2 weeks ago
This PR no longer has any functional changes, and instead just has a lint rule to check that commandLineParser.ts
and the CompilerOptions
interface in types.ts
are synchronized. We could do this at compile-time with type arithmetic (though not the @internal
sync bit), but it'd require as const
ing most of the option definitions and collections in commandLineParser.ts
, which seems a little heavyweight when we can't easily outright derive CompilerOptions
from the option definitions (and so would still need quite a bit of duplication) because there's a collection of 3 calculated fields on CompilerOptions
we use to smuggle path/origin information for the options around (which this lint rule exempts from the sync check).
Running it exposed a couple more internal compiler options we didn't have option definitions for that I didn't already know about.
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 https://github.com/microsoft/TypeScript/blob/cd566bad95124aded20f4cd35e95810077500e40/src/testRunner/unittests/config/commandLineParsing.ts#L252 which checks if all affectsSemanticDiagnostics
are marked as affectsBuildInfo
as well. May be some test case like that would be better than lint rule
A number of our
@internal
options 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
CompilerOptions
interface and the option definitions incommandLineParser.ts
and ensures their state is synchronized. It also adds aninternal
field to command line option definitions whose only purpose is tracking which options are@internal
annotated. 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.