Saya membuat definisi tipe baru dalam proyek DefinitelyTyped untuk tanda hubung. Anda dapat melihatnya di sini.

Namun saat menjalankan skrip pengujian npm run test hyphen saya mendapatkan pesan kesalahan berikut:

C:\MyProjects\code\ts-d.ts\DefinitelyTyped>npm run test hyphen

> definitely-typed@0.0.3 test C:\MyProjects\code\ts-d.ts\DefinitelyTyped
> node node_modules/types-publisher/bin/tester/test.js --run-from-definitely-typed "hyphen"

Clean data
Clean logs
Clean output
Using local Definitely Typed at C:\MyProjects\code\ts-d.ts\DefinitelyTyped.
Parsing definitions...
Found 6695 packages.
Parsing in parallel...
Error: Unused file C:\MyProjects\code\ts-d.ts\DefinitelyTyped/types/hyphen/index.d.ts (used files: ["patterns/de-1996.d.ts","patterns/hu.d.ts","en-gb.d.ts","hyphen-tests.ts","common.ts","tsconfig.json","tslint.json"])
    at checkAllUsedRecur (C:\MyProjects\code\ts-d.ts\DefinitelyTyped\node_modules\types-publisher\bin\lib\definition-parser.js:368:23)
    at checkAllFilesUsed (C:\MyProjects\code\ts-d.ts\DefinitelyTyped\node_modules\types-publisher\bin\lib\definition-parser.js:331:5)
    at getTypingDataForSingleTypesVersion (C:\MyProjects\code\ts-d.ts\DefinitelyTyped\node_modules\types-publisher\bin\lib\definition-parser.js:142:5)
    at combineDataForAllTypesVersions (C:\MyProjects\code\ts-d.ts\DefinitelyTyped\node_modules\types-publisher\bin\lib\definition-parser.js:96:25)
    at Object.getTypingInfo (C:\MyProjects\code\ts-d.ts\DefinitelyTyped\node_modules\types-publisher\bin\lib\definition-parser.js:27:82)
    at C:\MyProjects\code\ts-d.ts\DefinitelyTyped\node_modules\types-publisher\bin\lib\definition-parser-worker.js:17:50
    at Object.logUncaughtErrors (C:\MyProjects\code\ts-d.ts\DefinitelyTyped\node_modules\types-publisher\bin\util\util.js:78:38)
    at process.<anonymous> (C:\MyProjects\code\ts-d.ts\DefinitelyTyped\node_modules\types-publisher\bin\lib\definition-parser-worker.js:15:16)
    at process.emit (events.js:210:5)
    at emit (internal/child_process.js:876:12)
Error: Parsing failed.
    at fail (C:\MyProjects\code\ts-d.ts\DefinitelyTyped\node_modules\types-publisher\bin\util\util.js:272:20)
    at ChildProcess.<anonymous> (C:\MyProjects\code\ts-d.ts\DefinitelyTyped\node_modules\types-publisher\bin\util\util.js:261:21)
    at ChildProcess.emit (events.js:210:5)
    at finish (internal/child_process.js:861:14)
    at processTicksAndRejections (internal/process/task_queues.js:75:11)

Kesalahan mengatakan bahwa index.d.ts adalah file yang tidak digunakan. Tapi ini tidak benar karena digunakan dalam tanda hubung saya -tests.ts file.

Saya dapat menambahkan index.d.ts ke OTHER_FILES.txt untuk melewati masalah, tetapi ini jelas bukan solusi yang tepat. Dapatkah seseorang membantu saya di sini? Terima kasih sebelumnya.

0
Jenny O'Reilly 19 April 2020, 21:06

1 menjawab

Jawaban Terbaik

Ternyata saya melewatkan entri index.d.ts di opsi files dalam tsconfig.json saya:

{
    "compilerOptions": {
        "module": "commonjs",
        "lib": [
            "es6"
        ],
        "strict": true,
        "baseUrl": "../",
        "typeRoots": [
            "../"
        ],
        "noEmit": true,
        "forceConsistentCasingInFileNames": true,
        "types": []
    },
    "files": [
        "index.d.ts",
        "hyphen-tests.ts"
    ]
}

Tapi saya masih tidak tahu mengapa harus ada di sana karena semua file .d.ts lainnya dikenali melalui impor masing-masing dalam hyphen-tests.ts.

0
Krisztián Balla 20 April 2020, 19:23