microsoft / microsoft/TypeScript
Cannot find type definition file for ambient declaration module
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Go
- Estrellas
- 111k
- Forks
- 14.3k
- Merge medio
- 1 d 19 h
- PR fusionados (30 d)
- 117
Descripción
TypeScript Version: 3.6 to 3.8.0-dev.20191025
Search Terms: ambient module triple slash reference path declaration
Code
// A *self-contained* demonstration of the problem follows...
[typings/somemodule/index.d.ts]
declare module "somemodule"
{
export namespace common {
export interface Foo {
bar: string;
fuzz: Number;
}
}
}
[src/index.ts]
/// <reference path="../typings/somemodule/index.d.ts" />
Typescript 3.5.3 works as expected, anything at or above 3.6 has the same issue..
When running tsc -d, for a manually created declaration file, the triple slash reference path file should be preserved in the output declaration file. This particular declaration file acts as a shim for an existing library whose type definitions are incomplete and is to be included as-is and without transpiler manipulation in the output declaration file. This provides accurate intellisense for package consumers and ensures build errors do not occur.
Expected behavior:
Maintain the same triple-slash reference path in the .d.ts file as was in the .ts file.
[dist/index.d.ts]
/// <reference path="../typings/somemodule/index.d.ts" />
Actual behavior:
The reference path is changed to reference types and the relative path is also broken:
[dist/index.d.ts]
/// <reference types="typings/somemodule" />
This causes consuming applications of the package to receive the following build error:
Cannot find type definition file for 'typings/somemodule'.
I have been unsuccessful in manipulating the consuming application to build correctly or provide correct intellisense with the updated directive. The original directive must be preserved.
Playground Link:
Related Issues: I believe this is where the issue was introduced: #32878
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 problema con tsc -d usando src/index.ts y typings/somemodule/index.d.ts, y luego compara el dist/index.d.ts generado con la referencia triple-slash esperada. Lee el issue relacionado #32878 y sigue el comportamiento de emisión de declaraciones responsable de convertir la referencia de ruta. Se considera terminado cuando se conserva la ruta de referencia original y las aplicaciones consumidoras dejan de informar de que falta el archivo de definición de tipos.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- typescript
- Área
- compilers
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100