Search code examples
typescriptdefinitelytyped.d.ts

Getting "Error: Unused file" when running test for new type definition


I created a new type definition within the DefinitelyTyped project for the hyphen library. You can see it here.

However when running the test script npm run test hyphen I get the following error message:

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

> [email protected] 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)

The error says that index.d.ts is an unused file. But this is not true as it is used within my hyphen-tests.ts file.

I could add index.d.ts to OTHER_FILES.txt to bypass the problem, but this is obviously not the right solution. Can someone help me out here? Thanks in advance.


Solution

  • I turns out I was missing the index.d.ts entry in the files option within my tsconfig.json:

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

    But I still don't know why it has to be there as all other .d.ts files are recognized through their respective imports within hyphen-tests.ts.