Closed enbermudas closed 5 years ago
It's exported, and nobody else gets this error:
Some (+10) production bots are written in Klasa and use the latest commits, and they build fine.
My guess is that yarn corrupted your install, I suggest you to clean your yarn cache (yarn cache clean
), nuke the node_modules folder (rm -r -Force node_modules
in PowerShell, rm -rf node_modules
in Linux), the yarn.lock, and re-install.
I did so by:
yarn cache clean
The problem persist, any other idea?
@enbermudas klasa does not support discord.js v11. Klasa v0.4.0 aka stable doesn't actually work.
You will need to switch to klasa#master v1.0.0-alpha or settings branch and discord.js master aka v12-dev.
Discord.js
# Npm
npm i discordjs/discord.js
# Yarn
yarn add discordjs/discord.js
Klasa
# NPM
npm i dirigeants/klasa
# Yarn
yarn add dirigeants/klasa
If you want to use the v1.0.0-alpha or settings branch apply #branchname
after dirigeants/klasa
I installed those two dependencies and there are 58 errors now within the typings.
Has this been fixed yet? There was a discussion in the support server that led to a fix.
The culprit was the lack of "types": ["node", "discord.js", "klasa"]
in the tsconfig.json
's compilerOptions
, and the error is pretty understandable as:
TSC (TypeScript Compiler) reads the main file, detects klasa
is being imported, a module that defines both klasa
itself (it's own definitions) and discord.js
(augmented definitions), but since the real discord.js
module has not been loaded, TSC takes the augmentations as the type source, which is not valid, causing this problem.
With the types
being defined, TSC will load Node.js's types (which defines NodeJS.Timeout
, Buffer
, and others, which both discord.js and klasa rely on), then it will load discord.js
, which defines ClientApplication
and many other classes klasa imports, and finally, klasa
itself.
That way when you load your project and TSC finds the import { Client } from 'klasa';
, all the types are pre-loaded, and everything is available and valid.
it was also because they were trying to compile to es4 or es5 code, instead of es6/esnext
I am having this issue using both master and settings branches even though I reordered the types as per the above message.
The issue ultimately comes from here:
// node_modules/discord.js/typings/index.d.ts
declare module 'discord.js' {
import BaseCollection from '@discordjs/collection'; // <--
// *snip*
}
My tsconfig.json
:
{
"compilerOptions": {
"target": "es6",
"outDir": "./dist",
"baseUrl": ".",
"sourceMap": true,
"allowSyntheticDefaultImports": true,
"types": ["node", "discord.js", "klasa"]
},
"include": ["./**/*", "./data/**/*"],
"exclude": ["**/node_modules"]
}
Describe the issue
I just got the next error while initializing my discord bot:
Module '"discord.js"' has no exported member 'ClientApplication'.
Code or steps to reproduce
index.ts file
package.json script runned: "start"
Expected and actual behavior
Run just fine?
Further details