microsoft / microsoft/TypeScript
Cannot find type definition file for ambient declaration module
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 2g 4h
- PR unite (30g)
- 132
Descrizione
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
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Riproduci il problema con tsc -d usando src/index.ts e typings/somemodule/index.d.ts, quindi confronta il dist/index.d.ts generato con il riferimento triple-slash previsto. Leggi l’issue correlata #32878 e traccia il comportamento dell’emissione delle dichiarazioni responsabile della conversione del riferimento al percorso. Il lavoro è completato quando il percorso del riferimento originale viene preservato e le applicazioni che lo utilizzano non segnalano più la mancanza del file di definizione dei tipi.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript
- Ambito
- compilers
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100