microsoft / microsoft/TypeScript
Export an interface for JSON `CompilerOptions`
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.3k
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 117
Beschreibung
Search Terms
- CompilerOptions
- convertCompilerOptionsFromJson
Suggestion
Currently TypeScript exports the CompilerOptions interface, which represents the compiler options that can be passed in. However, since this interface uses enums, it doesn't match with the format of compilerOptions in the tsconfig.json file. I'd like to be able to use a JsonCompilerOptions (or some better name) interface to strictly type options in libraries that wrap TypeScript without rewriting the interface.
Use Cases
- Libraries that wrap TypeScript like rollup-plugin-typescript can strictly type overrides for values in
tsconfigwithout either requiring the user to import TypeScript enums or rewriting the interface. - The
convertCompilerOptionsFromJsonfunction takes inanycurrently, and could instead use this hypothetical interface.
Examples
TypeScript wrapping libraries can let consumers override tsconfig options
import { Plugin } from 'rollup';
import { JsonCompilerOptions } from 'typescript';
interface Options extends JsonCompilerOptions {
customOptions?: string;
}
export default function rollupPluginTypescript(options?: Options): Plugin;
Strict typing for convertCompilerOptionsFromJson
import { convertCompilerOptionsFromJson } from 'typescript';
// Type error
const opts = convertCompilerOptionsFromJson({ allowJs: 'true' }, process.cwd());
Checklist
My suggestion meets these guidelines:
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
- This feature would agree with the rest of TypeScript's Design Goals.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit der öffentlichen, in lib/typescript.d.ts verknüpften CompilerOptions-Deklaration und dem Einstiegspunkt convertCompilerOptionsFromJson in src/compiler/commandLineParser.ts. Definiere die JSON-förmige Optionsschnittstelle und mache sie öffentlich zugänglich. Stelle anschließend sicher, dass die Konvertierungsfunktion sie akzeptiert und dabei das angeforderte Verhalten der Typprüfung beibehält.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- typescript
- Bereich
- api, compilers
- Issue-Typ
- Feature
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 38/100