microsoft / microsoft/TypeScript
disable certain global types for specific files, or specify type roots for specific files.
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Go
- Estrellas
- 111k
- Forks
- 14.4k
- Merge medio
- 1 d 19 h
- PR fusionados (30 d)
- 117
Descripción
This continues some ideas from https://github.com/microsoft/TypeScript/issues/17042, which was closed by @microsoft (for inactivity, I think?).
Search Terms
disable certain global types for specific files, specific type roots for certain files
Suggestion
Ability to specify which @types (or in general, which specified typeRoots) apply to which files in a project.
Use Cases
My project's src folder contains both .ts and .test.ts files, and I'd like an easy way for globals like describe to be defined only for the .test.ts files.
Examples
Not sure, but maybe some sort of new options in tsconfig.json for specifying which types items, lib items, or typeRoots items apply to which files.
This would be a beneficial feature because various editors (VS Code aside) look for a tsconfig.json file at the root of a project, and at the moment the only way to make types work in all files is to just provides all types for all files, which is undesirable because describe is not a function that is available in source files (as an example).
Example configuration: maybe instead of a typeRoots array, it can be an object like:
"typeRoots": {
"./src/**/*.test.ts": ["../path/to/test/types"], // test-only types
"./src/**/*.ts": ["../path/to/@types"] // other types other files
}
Or something. That's just an example to get the idea rolling.
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
Empieza leyendo el issue relacionado #17042 y los ejemplos de tsconfig.json de la propuesta. Investiga cómo se aplican actualmente types, lib y typeRoots a los archivos src del proyecto, incluidos los archivos .test.ts. Se considerará terminado cuando exista una forma documentada e implementada de limitar esas fuentes de tipos a archivos seleccionados sin afectar a las configuraciones existentes.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- typescript
- Área
- compilers
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Estado de actividad
- Estancado
- Claridad
- Necesita aclaración
- Aptitud para principiantes
- 25/100