microsoft / microsoft/TypeScript
Cannot find type definition file for ambient declaration module
まだ誰も着手していません。
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.3k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
説明
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
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
src/index.ts と typings/somemodule/index.d.ts を使用して tsc -d で問題を再現し、生成された dist/index.d.ts と期待される triple-slash reference を比較します。関連する issue #32878 を読み、パス参照の変換を引き起こしている declaration emit の動作を追跡します。元の参照パスが保持され、利用側のアプリケーションで missing type definition file が報告されなくなれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100