Open
Description
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 #10178