microsoft / microsoft/TypeScript
Export an interface for JSON `CompilerOptions`
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Go
- Estrellas
- 111k
- Forks
- 14.3k
- Merge medio
- 2 d 4 h
- PR fusionados (30 d)
- 132
Descripción
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.
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza con la declaración pública de CompilerOptions enlazada en lib/typescript.d.ts y el punto de entrada convertCompilerOptionsFromJson en src/compiler/commandLineParser.ts. Define la interfaz de opciones con forma de JSON y expónla públicamente; después, asegúrate de que la función de conversión la acepte y conserve el comportamiento solicitado de comprobación de tipos.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- typescript
- Área
- api, compilers
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 38/100