microsoft / microsoft/TypeScript
Imports in .d.ts files break wildcard modules declarations
まだ誰も着手していません。
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.3k
- 平均マージ
- 2日 4時間
- マージ済み PR(30日)
- 132
説明
TypeScript Version: 3.1.3
Search Terms:
import d.ts wildcard module
Code
main.ts
/// <reference path="./typings.d.ts" />
import template from './template.html';
typings.d.ts
import * as _angular from 'angular';
declare module '*.html' {
const content : string;
export default content;
}
{
"name": "ts-bug",
"version": "1.0.0",
"dependencies": {
"angular": "^1.7.5"
}
}
Compile with:
tsc main.ts
Expected behavior:
Compiled without errors.
Actual behavior:
Compiled with error
main.ts:3:22 - error TS2307: Cannot find module './template.html'.
3 import template from './template.html';
~~~~~~~~~~~~~~~~~
Removing import * as _angular from 'angular'; fixes the issue.
Side Note 1
Regular module declarations work regardless of imports being present.
Side Note 2
import * as _angular from 'angular'; is needed to later do:
declare global {
const angular : typeof _angular;
}
to workaround https://github.com/Microsoft/TypeScript/issues/10178
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
main.ts と typings.d.ts を使い、tsc main.ts でレポートを再現します。その際、angular からの import と *.html のワイルドカードモジュール宣言を維持します。typings.d.ts 内の import によって ./template.html を解決できない理由を追跡します。import とワイルドカード宣言を維持したまま、例が TS2307 なしでコンパイルできれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 35/100