jshemas / openGraphScraper

Node.js scraper service for Open Graph Info and More!
MIT License
664 stars 105 forks source link

Typescript Export Assignment #237

Closed Sydney-o9 closed 4 weeks ago

Sydney-o9 commented 1 month ago

Describe the bug There is a regression in ^6.6 for Tyepscript users.

image

We had to downgrade to ^6.5 to transpile properly image

To Reproduce

Use ^6.6 and build $ tsc

Expected behavior It should compile

Actual behavior It doesn't compile with error:

image

The issue arises because the code is trying to mix export default with export =, which is not allowed in TypeScript. In a module, you cannot use both export default and export = together.

jshemas commented 1 month ago

That was added fix ESM imports for module/moduleResolution = NodeNext projects. I'm not sure if there is a better way to fix that problem.

jshemas commented 1 month ago

Hello. This should be fixed in open-graph-scraper@6.7.1

nekochan0122 commented 1 month ago

Hello. This should be fixed in open-graph-scraper@6.7.1

Hello, the types SuccessResult and ErrorResult are not exported in 6.7.1

image

jshemas commented 1 month ago

@nekochan0122 These types were moved into the types file. So you can do something like import type { SuccessResult, ErrorResult } from 'open-graph-scraper/types/lib/types';

nekochan0122 commented 1 month ago

@jshemas Thx for the reply, but I still got the errors.

image

jshemas commented 1 month ago

import type { SuccessResult, ErrorResult } from 'open-graph-scraper/types/lib/types'; should now work in open-graph-scraper@6.7.2

image

nekochan0122 commented 1 month ago

Will be more nice if the import path can be shorter : import type { SuccessResult, ErrorResult } from 'open-graph-scraper/types

https://github.com/jshemas/openGraphScraper/blob/0d01a6bed4a5d810906c5a722fdd554d62715fb2/package.json#L14

By changing: "./types/lib/types": "./types/lib/types.d.ts"

to: "./types": "./types/lib/types.d.ts"

jshemas commented 4 weeks ago

@nekochan0122 Good idea. Changes are live in open-graph-scraper@6.8.0. Open a new issue if you have any more problems.