Typescript 用于导入文本而非类型检查的通配符模块
以下是通配符模块定义:Typescript 用于导入文本而非类型检查的通配符模块,typescript,Typescript,以下是通配符模块定义: declare module 'text!*' { const content: string; export default content; } 以及进口: import * as html from 'text!./myHtml.html'; 和编译器错误: 错误TS2345:类型为'typeof'text!*''的参数不可转让给 “string |”类型的参数(this:HTMLElement,index:number, oldhtml:str
declare module 'text!*' {
const content: string;
export default content;
}
以及进口:
import * as html from 'text!./myHtml.html';
和编译器错误:
错误TS2345:类型为'typeof'text!*''的参数不可转让给
“string |”类型的参数(this:HTMLElement,index:number,
oldhtml:string)=>string')
我真的希望html
有类型string
我真的希望html有字符串类型
然后,将导出更改为字符串。我在下面显示了无效和正确的代码