我在一个麻省理工学院许可的项目中使用了QUnit,其中一部分是用TypeScript编写的。我有一些TS函数,它们接受QUnit作为参数,并希望从the typing中键入它们作为其接口
例如:
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 - it在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"]
}谢谢你的帮助。
发布于 2019-05-14 04:35:12
如果你只需要输入,安装@types for qunit with npm应该是你需要做的全部事情,只需完全省略import语句。
https://stackoverflow.com/questions/56118562
复制相似问题