Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript support #2

Closed
wasmake opened this issue Oct 23, 2024 · 1 comment
Closed

Typescript support #2

wasmake opened this issue Oct 23, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@wasmake
Copy link

wasmake commented Oct 23, 2024

Describe the bug

The lib is giving errors on typescript when default config is used

Expected behavior

Using same code as the example:

`import { HiAnime, HiAnimeError } from "aniwatch";

const hianime = new HiAnime.Scraper();

try {
const result: HiAnime.ScrapedAnimeAboutInfo = await hianime.getInfo(
"steinsgate-3"
);
console.log(result);
} catch (err) {
console.error(err instanceof HiAnimeError, err);
}`

In a Typescript + NestJs environment with the next tsbuild.config

{ "compilerOptions": { "module": "CommonJS", "moduleResolution": "node", "declaration": true, "removeComments": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, "target": "es2020", "sourceMap": true, "outDir": "./dist", "baseUrl": "./", "incremental": true, "skipLibCheck": true, "strictNullChecks": false, "noImplicitAny": false, "strictBindCallApply": false, "forceConsistentCasingInFileNames": false, "noFallthroughCasesInSwitch": false, "esModuleInterop": true, "allowSyntheticDefaultImports": true }, "include": [ "./src/**/*" ], "exclude": [ "node_modules" ] }

Actual behavior

Gives the error:

const aniwatch_1 = require("aniwatch");

Error [ERR_REQUIRE_ESM]: require() of ES Module

Instead change the require of index.js in [...] to a dynamic import() which is available in all CommonJS modules.

Additional context

Typescript + NestJs

Apparently lib only includes the compiled "dist" javascript, so when tryong to run it in an "Typescript environment" such as the development server, gives the error.

@wasmake wasmake added the bug Something isn't working label Oct 23, 2024
@ghoshRitesh12
Copy link
Owner

ghoshRitesh12 commented Oct 27, 2024

This library doesn't support CJS and it's intentional. This maybe the reason why those errors are occurring.

@ghoshRitesh12 ghoshRitesh12 closed this as not planned Won't fix, can't repro, duplicate, stale Dec 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants