microsoft / microsoft/TypeScript
Better error message when a module declaration is not found, but a module augmentation is?
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
🔎 Search Terms
declaration, augmentation
🕗 Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about module augmentation and declaration files
⏯ Playground Link
Can't be shown on Playground, since it requires two files
💻 Code
// declaration.d.ts
import { ComponentType } from "react";
declare module "a/b" {
const B: ComponentType<any>;
// const B: import("react").ComponentType<any>;
export default B;
}
// file.ts
import B from "a/b";
🙁 Actual behavior
The error message is "Cannot find module 'a/b' or its corresponding type declarations (2307)". I know this works as indended from https://github.com/microsoft/TypeScript/issues/49043#issuecomment-1124047244, so my proposal is only about changing the error message.
🙂 Expected behavior
In the case where TypeScript can't find a declaration of a module but can find its augmentation, it seems very likely the user intended to make it a declaration, but didn't know top-level import/export change the meaning (like I didn't yesterday). It would be nice to have the message tell the user about the problem and guide to fixing it.
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
Reproduce el comportamiento con los dos archivos mostrados, declaration.d.ts y file.ts, y compara el diagnóstico cuando falta la declaración del módulo pero se encuentra su ampliación. Sigue la ruta del diagnóstico de resolución de módulos y actualiza el mensaje para explicar la distinción entre import/export de nivel superior; verifica las indicaciones revisadas con este ejemplo y con las pruebas de diagnóstico relacionadas.
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
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100