obsidian-modules icon indicating copy to clipboard operation
obsidian-modules copied to clipboard

TypeScript self.require error

Open LeonardoGentile opened this issue 1 year ago • 1 comments

Hello, I've been using the plugin with plain js for a while and it's been working great. In my case I've been importing modules using self.require as it is the form that generate the less problem for me.

I wanted to test how to work in the same way with TypeScript but as soon I've create a ts file and added

const { MyFunction } = self.require("modules/myModule.js")

Then I've received the following error:

Property 'require' does not exist on type 'Window & typeof globalThis'

Is there any special tsconfig we should use to work with or should we import type definitions from obsidian-modules?

I have something like this in my tsconfig (using vscode)

{
  "compilerOptions": {
    "noEmit": true,
    "target": "ES5",
    "module": "CommonJS",
    "sourceMap": true,
    "allowJs": true
  }
}

LeonardoGentile avatar Apr 24 '24 21:04 LeonardoGentile

Sorry for the delay.

If I create a TypeScript file and have it simply import something using self.require, it does not error out when I import the TypeScript file. Could you send a reproducible example? Thanks.

polyipseity avatar Jun 06 '24 08:06 polyipseity