[英]How to declare a function parameter as the “QUnit” type in TypeScript with qunit?
我在用TypeScript部分编写的MIT许可项目中使用QUnit 。 我有一些TS函数接受QUnit作为参数,并希望从键入中将其作为其接口键入
例如:
import { QUnit } from "qunit";
export function run_tests(q: QUnit)
{
q.module((a) => { ... });
}
但是,当我尝试时,出现此错误:
tsc --project lib/typescript/www/tsconfig.json
src/ts/web-fc-solve-tests.ts(12,23): error TS2306: File '/home/shlomif/progs/fre
ecell/git/fc-solve/fc-solve/site/wml/node_modules/@types/qunit/index.d.ts' is no
t a module.
这是我的代码(请注意分支): https : //github.com/shlomif/fc-solve/tree/qunit-typescript-它位于fc-solve/site/wml
子目录下。
我的tsconfig.json
是:
{
"compilerOptions": {
"baseUrl": ".",
"esModuleInterop": true,
"module": "amd",
"moduleResolution": "node",
"noImplicitReturns": true,
"outDir": "../../../lib/out-babel/js",
"paths": {
"big-integer": ["node_modules/big-integer/BigInteger.d.ts"],
"qunit": ["node_modules/@types/qunit"]
},
"target":"es6"
},
"include": ["../../../src/ts/**/*.ts"]
}
谢谢你的帮助。
如果您只需要输入内容,则只需使用npm为qunit安装@types库,并且完全省略import语句即可。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.