#I have no idea what I am doing.

6 messages · Page 1 of 1 (latest)

vagrant lintel
#

I'm trying to implement paths into ts, in VSCODE it seems to be fine without errors but when I compiling it.. It gives error:

-src/index.ts:1:51 - error TS2307: Cannot find module '@EXPORT_MODULES' or its corresponding type declarations.
import { Client, Events, GatewayIntentBits } from '@EXPORT_MODULES';

tsconfig.json

{
  "ts-node": {
    "require": ["tsconfig-paths/register"]
  },
  "compilerOptions": {
    "lib": ["es5", "es6", "es7"],
    "target": "es2017",
    "module": "commonjs",
    "moduleResolution": "node",
    "rootDir": "src",
    "outDir": "build",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "esModuleInterop": true,
    "noImplicitAny": true,
    "strict": true,
    "resolveJsonModule": true,
    "allowJs": true,
    "sourceMap": true,

    "baseUrl": ".",
    "paths": {
      "@INDEX_ROOT": ["src/index"],
      "@HANDLERS_ROOT*": ["src/handlers*"],
      "@EXPORT_MODULES": ["src/export"],
    },
  },
  "include": ["src/**/*"],
  "exclude": [
    "node_modules"
  ],
}

src/export.ts

export { SlashCommandBuilder, Client, Collection, Events, GatewayIntentBits } from 'discord.js';
export { glob } from 'glob-promise';

src/index.ts

import { Client, Events, GatewayIntentBits } from '@EXPORT_MODULES';
import { registerCommands } from '@HANDLERS_ROOT/registerCommands';

const client = new Client({ intents: [GatewayIntentBits.Guilds] });

const commands = registerCommands(client);

client.once(Events.ClientReady, c => {
    console.log(`Ready! Logged in as ${c.user.tag}`);
    console.log(commands);
});

client.login(process.env.DTOKEN);

I need help with MODULES not with discord

cloud void
#

!:paths%

wooden pecanBOT
#
tjjfvi#0
`!t6:paths-are-not-magic`:

The paths and baseUrl compiler options don't cause any remapping of imports paths, they only inform TS of existing mappings, which you'll have to setup with some other tool.

baseUrl is a pretty well-supported option (e.g. using the NODE_PATH environment variable with node or resolve.modules with webpack).
paths can be trickier to setup, (especially with node see this for node), and you may find it to not be worth the effort.

vagrant lintel
#

where I can get example of project with pathes?

#

I don't really understand documentation

quartz jetty
#

i generally recommend using relative paths unless you have a specific reason not to