Open Aliaksandr-Kasko-JazzTeam opened 10 months ago
It works perfectly on my side:
Module fully export methods through index files:
google-play-scraper/index.js
const methods = {
app: appMethod,
list,
search: R.partial(search, [appMethod]),
suggest,
developer,
reviews,
similar,
permissions,
datasafety,
categories
};
export default Object.assign({ memoized }, constants, methods);
google-play-scraper/index.d.ts, line 320 :
export const list: IFnList
Usage :
import gplay from "google-play-scraper"
server.get('/gplay.list', async (req: any, res: any) => {
try {
const result = await gplay.list({ collection: gplay.collection.GROSSING, lang: 'fr', country: 'FR' })
res.send(result)
} catch (err: any) {
res.send('failed ' + JSON.stringify(err?.message))
}
})
My tsconfig.json
{
"$schema": "https://json.schemastore.org/tsconfig",
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"rootDir": "./src/",
"outDir": "./dist/",
"strict": true,
"moduleResolution": "node",
"importHelpers": true,
"experimentalDecorators": true,
"esModuleInterop": true,
"skipLibCheck": true,
"allowSyntheticDefaultImports": true,
"resolveJsonModule": true,
"forceConsistentCasingInFileNames": true,
"removeComments": true,
"sourceMap": false,
"baseUrl": "./",
"typeRoots": [
"./node_modules/@types",
"./src/custom_typings"
]
},
"include": [
"src/**/*",
"src/**/*.d.ts",
"src/**/*.json"
],
"exclude": [
"node_modules",
"dist",
"custom_typings",
"typings"
],
"ts-node": {
"esm": true
}
}
Oh, thank you @jbigman. I added these changes to my tsconfig:
"module": "NodeNext" -> "ESNext",
"moduleResolution": "NodeNext" -> "Node"
and all starts working for me! I think there should be some setup manuals.
Offtop: just a small changes to iteration over enums, but these are trifles.
Description:
Please sync
index.d.ts
withindex.js
. Because of import issue.Example code:
Error message:
If I import with
and call, for example, list
then I got an error
Only one workaround exists for now is to suppress
import gplay from "google-play-scraper"
with// @ts-ignore