Please describe the problem you are having in as much detail as possible:
tsc reports errors with the typings file
Include a reproducible code sample here, if possible:
import { Client } from 'discord.js';
new Client()
.on('ready', () => console.log('Ready'))
.login(process.env.TOKEN);
Further details:
Extension of #2835 but not locked, with more input
Here's a video I made to help show it, though it's just showing the same errors as below:
https://youtu.be/GvgDsJeEB8I
tsc output:
node_modules/discord.js/typings/index.d.ts:38:15 - error TS2417: Class static side 'typeof ActivityFlags' incorrectly extends base class static side 'typeof BitField'.
Types of property 'resolve' are incompatible.
Type '(permission: BitFieldResolvable<ActivityFlagsString>) => number' is not assignable to type '(bit?: string | number | Readonly<BitField<string>> | RecursiveArray<string | number | Readonly<BitField<string>>> | undefined) => number'.
Types of parameters 'permission' and 'bit' are incompatible.
Type 'string | number | Readonly<BitField<string>> | RecursiveArray<string | number | Readonly<BitField<string>>> | undefined' is not assignable to type 'BitFieldResolvable<ActivityFlagsString>'.
Type 'undefined' is not assignable to type 'BitFieldResolvable<ActivityFlagsString>'.
38 export class ActivityFlags extends BitField<ActivityFlagsString> {
~~~~~~~~~~~~~
node_modules/discord.js/typings/index.d.ts:789:15 - error TS2417: Class static side 'typeof Permissions' incorrectly extends base class static side 'typeof BitField'.
Types of property 'resolve' are incompatible.
Type '(permission?: number | "CREATE_INSTANT_INVITE" | "KICK_MEMBERS" | "BAN_MEMBERS" | "ADMINISTRATOR" | "MANAGE_CHANNELS" | "MANAGE_GUILD" | "ADD_REACTIONS" | "VIEW_AUDIT_LOG" | "PRIORITY_SPEAKER" | ... 22 more ... | undefined) =>
number' is not assignable to type '(bit?: string | number | Readonly<BitField<string>> | RecursiveArray<string | number | Readonly<BitField<string>>> | undefined) => number'.
Types of parameters 'permission' and 'bit' are incompatible.
Type 'string | number | Readonly<BitField<string>> | RecursiveArray<string | number | Readonly<BitField<string>>> | undefined' is not assignable to type 'number | "CREATE_INSTANT_INVITE" | "KICK_MEMBERS" | "BAN_MEMBERS" | "ADMINISTRATOR" | "MANAGE_CHANNELS" | "MANAGE_GUILD" | "ADD_REACTIONS" | "VIEW_AUDIT_LOG" | "PRIORITY_SPEAKER" | ... 22 more ... | undefined'.
Type 'string' is not assignable to type 'number | "CREATE_INSTANT_INVITE" | "KICK_MEMBERS" | "BAN_MEMBERS" | "ADMINISTRATOR" | "MANAGE_CHANNELS" | "MANAGE_GUILD" | "ADD_REACTIONS" | "VIEW_AUDIT_LOG" | "PRIORITY_SPEAKER" | ... 22 more ... | undefined'.
789 export class Permissions extends BitField<PermissionString> {
~~~~~~~~~~~
node_modules/discord.js/typings/index.d.ts:1018:15 - error TS2417: Class static side 'typeof Speaking' incorrectly extends base class static side 'typeof BitField'.
Types of property 'resolve' are incompatible.
Type '(permission: BitFieldResolvable<SpeakingString>) => number' is not assignable to type '(bit?: string | number | Readonly<BitField<string>> | RecursiveArray<string | number | Readonly<BitField<string>>> | undefined) => number'.
Types of parameters 'permission' and 'bit' are incompatible.
Type 'string | number | Readonly<BitField<string>> | RecursiveArray<string | number | Readonly<BitField<string>>> | undefined' is not assignable to type 'BitFieldResolvable<SpeakingString>'.
Type 'undefined' is not assignable to type 'BitFieldResolvable<SpeakingString>'.
1018 export class Speaking extends BitField<SpeakingString> {
tsconfig.json:
{
"compileOnSave": true,
"compilerOptions": {
"allowJs": true,
"alwaysStrict": true,
"experimentalDecorators": true,
"module": "commonjs",
"moduleResolution": "node",
"noImplicitAny": true,
"noUnusedParameters": true,
"outDir": "build",
"pretty": true,
"sourceMap": true,
"strict": true,
"target": "esnext"
},
"exclude": [
"node_modules"
],
"include": [
"src",
"typings"
]
}
Related package.json sections:
"main": "build/index.js",
"scripts": {
"prestart": "tsc",
"start": "node .",
"pretest": "tsc",
"test": "node --inspect .",
"debug": "nodemon -e ts --exec npm test"
},
"dependencies": {
"@types/node": "^10.7.1",
"discord.js": "github:discordjs/discord.js",
"typescript": "^3.0.1"
},
"devDependencies": {
"nodemon": "^1.18.3",
"tslint": "^5.11.0"
},
Let me know if there's anything else I can provide.
To repeat the suggestion on discord, disabling strict as a compile option is a workaround for the issue, unsure if a good permanent resolution, however.
for me this worked:
npm i -D @types/node
and in tsconfig :
"types": ["node"]
Most helpful comment
To repeat the suggestion on discord, disabling
strictas a compile option is a workaround for the issue, unsure if a good permanent resolution, however.