[英]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.