-
Notifications
You must be signed in to change notification settings - Fork 160
Closed
Labels
Description
Describe the bug
Using the latest gamedig and @types/gamedig packages in my project, I get the following TypeScript compile error:
error TS7016: Could not find a declaration file for module 'gamedig'. '<...>/workspace/discord-player-count-bot/node_modules/gamedig/lib/index.js' implicitly has an 'any' type.
There are types at '<...>/workspace/discord-player-count-bot/node_modules/@types/gamedig/index.d.ts', but this result could not be resolved when respecting package.json "exports". The '@types/gamedig' library may need to update its package.json or typings.
3 import {GameDig, QueryOptions} from "gamedig";
This is my package.json
{
"name": "discord-player-count",
"version": "1.0.0",
"exports": "./dist/index.js",
"scripts": {
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
"build": "del-cli dist && tsc",
"prestart": "npm run build",
"start": "node ./dist/index.js"
},
"devDependencies": {
"@types/gamedig": "^5.0.2",
"@types/jest": "^29.2.1",
"@types/node": "^16.18.3",
"del-cli": "^5.0.0",
"jest": "^29.2.2",
"ts-jest": "^29.0.3",
"typescript": "^5.4.5"
},
"jest": {
"testEnvironment": "node",
"extensionsToTreatAsEsm": [".ts"],
"modulePathIgnorePatterns": [
"<rootDir>/dist/"
],
"moduleNameMapper": {
"^(\\.{1,2}/.*)\\.js$": "$1"
},
"transform": {
"^.+\\.tsx?$": [
"ts-jest",
{
"useESM": true
}
]
}
},
"engines": {
"node": "20.x.x"
},
"optionalDependencies": {
"fsevents": "*"
},
"type": "module",
"author": "Florian Schmidt",
"license": "MIT",
"dependencies": {
"cftools-sdk": "^3.1.7",
"discord.js": "^14.6.0",
"dotenv": "^16.0.3",
"gamedig": "^5.0.0",
"got": "^12.5.2",
"rxjs": "^7.5.7"
}
}
And my tsconfig.json:
{
"compilerOptions": {
"outDir": "dist",
"rootDir": "src",
"lib": ["ES2020", "dom"],
"moduleResolution": "node16",
"moduleDetection": "force",
"target": "ES2020",
"module": "node16",
"strict": true,
"allowSyntheticDefaultImports": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
}
}
When switching to commonjs, typings work fine, however, this is not really an option for me here. Tbh, I don't have a direct clue on what is wrong here, is it a configuration error on my side? Or are the types not working with modules?