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
abstractclassCommand{name: string;abstractexecute(client: Client,message: Message,args: string[]): void;constructor(name: string){this.name=name;}}exportdefaultCommand;ping.ts
importCommandfrom"src/classes/commandBase";classPingextendsCommand{constructor(){super("ping");}asyncexecute(client: Client<boolean>,message: Message<boolean>,args: string[]): Promise<void>{constm=awaitmessage.channel.send("Ping");m.edit(`Pong! Latency is ${m.createdTimestamp-message.createdTimestamp}ms. Discord Chat API Latency is ${Math.round(client.ws.ping)}ms`);}}exportdefaultPing;🙁 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 importCommandfrom"src/classes/commandBase";constfoo: Command={name: "",execute: function(client: Client,message: Message,args: string[]): void{thrownewError("Function not implemented.");},};exportdefaultfoo;🙂 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.