Bug Report
Every time when I try to extend the abtract class Command and I try to compile I get the error: Error: Cannot find module src/classes/commandBase
🔎 Search Terms
- Module not found
- class module not found
🕗 Version & Regression Information
💻 Code
My project has the following structure:
├────tsconfig.json
└────src
├───classes
│ └───commandBase.ts
├───commands
│ └───ping.ts
├...
tsconfig.json
{
"compilerOptions": {
"target": "ESNext",
"module": "CommonJS",
"rootDir": "./src/",
"outDir": "./dist/",
"strict": true,
"moduleResolution": "node",
"importHelpers": true,
"experimentalDecorators": true,
"esModuleInterop": true,
"skipLibCheck": true,
"allowSyntheticDefaultImports": true,
"resolveJsonModule": true,
"forceConsistentCasingInFileNames": true,
"removeComments": true,
"typeRoots": ["node_modules/@types"],
"sourceMap": true,
"baseUrl": "./"
},
"include": ["./**/**/*.ts"],
"exclude": ["node_modules", "dist"]
}
commandBase.ts
abstract class Command {
name: string;
abstract execute(client: Client, message: Message, args: string[]): void;
constructor(name: string) {
this.name = name;
}
}
export default Command;
ping.ts
import Command from "src/classes/commandBase";
class Ping extends Command {
constructor() {
super("ping");
}
async execute(
client: Client<boolean>,
message: Message<boolean>,
args: string[]
): Promise<void> {
const m = await message.channel.send("Ping");
m.edit(
`Pong! Latency is ${
m.createdTimestamp - message.createdTimestamp
}ms. Discord Chat API Latency is ${Math.round(client.ws.ping)}ms`
);
}
}
export default Ping;
🙁 Actual behavior
Error: Cannot find module 'src/classes/commandBase'.
However if you change import Command from "src/classes/commandBase"; to import Command from "../classes/commandBase"; everything is working fine when importing.
BUT the weird behavior starts now:
If you create a new file which import Command from 'src/classes/commandBase and exports a variable everything is working as intended. The error only appears when you extend a class.
file foo.ts
// This is working
import Command from "src/classes/commandBase";
const foo: Command = {
name: "",
execute: function (
client: Client,
message: Message,
args: string[]
): void {
throw new Error("Function not implemented.");
},
};
export default foo;
🙂 Expected behavior
Since the module exists it should be able to import.
Bug Report
Every time when I try to extend the abtract class Command and I try to compile I get the error: Error: Cannot find module
src/classes/commandBase🔎 Search Terms
🕗 Version & Regression Information
💻 Code
My project has the following structure:
tsconfig.json
{ "compilerOptions": { "target": "ESNext", "module": "CommonJS", "rootDir": "./src/", "outDir": "./dist/", "strict": true, "moduleResolution": "node", "importHelpers": true, "experimentalDecorators": true, "esModuleInterop": true, "skipLibCheck": true, "allowSyntheticDefaultImports": true, "resolveJsonModule": true, "forceConsistentCasingInFileNames": true, "removeComments": true, "typeRoots": ["node_modules/@types"], "sourceMap": true, "baseUrl": "./" }, "include": ["./**/**/*.ts"], "exclude": ["node_modules", "dist"] }commandBase.ts
ping.ts
🙁 Actual behavior
Error: Cannot find module 'src/classes/commandBase'.However if you change
import Command from "src/classes/commandBase";toimport Command from "../classes/commandBase";everything is working fine when importing.BUT the weird behavior starts now:
If you create a new file which
import Command from 'src/classes/commandBaseand exports a variable everything is working as intended. The error only appears when you extend a class.file foo.ts
🙂 Expected behavior
Since the module exists it should be able to import.