strapi-sdk-js
strapi-sdk-js copied to clipboard
Import has no construct signatures
Bug report
Describe the bug
Though I can clearly see the class constructor in both the mjs and d.ts files in the node_modules folder, I am unable to initialize the Strapi class due to a 'no construct signatures' error.
Steps to reproduce the behavior
See code sample below.
Expected behavior
For the Strapi SDK to initialize.
Screenshots
$ /Users/daniel/Developer/jewish-earth-alliance/node_modules/.bin/tsc
src/importer.ts:8:20 - error TS2351: This expression is not constructable.
Type 'typeof import("/Users/daniel/Developer/jewish-earth-alliance/node_modules/strapi-sdk-js/dist/index")' has no construct signatures.
8 const strapi = new Strapi();
~~~~~~
Found 1 error in src/importer.ts:8
Code snippets
All of these fail to load and yield the above error or similar.
import Strapi from 'strapi-sdk-js';
const strapi = new Strapi();
import Strapi from 'strapi-sdk-js';
const strapi = new Strapi.default();
import * as Strapi from 'strapi-sdk-js';
const strapi = new Strapi();
import * as Strapi from 'strapi-sdk-js';
const strapi = new Strapi.default();
System
- Typescript version: 5.2.2
- Node.js version: 18.17.1
- NPM version: 10.1.0
- Strapi version: 4.14.0
- Strapi SDK version: 2.3.3
- Operating system: MacOS 13.5.2
Additional context
tsconfig.json
{
"compilerOptions": {
"allowJs": true,
"allowSyntheticDefaultImports": true,
"baseUrl": "./",
"declaration": true,
"esModuleInterop": true,
"experimentalDecorators": true,
"inlineSourceMap": true,
"isolatedModules": true,
"module": "Node16",
"moduleResolution": "NodeNext",
"outDir": "./dist",
"removeComments": true,
"resolveJsonModule": true,
"resolvePackageJsonExports": true,
"resolvePackageJsonImports": true,
"rootDir": "./src",
"skipLibCheck": true,
"strict": true,
"target": "es2016",
"types": [
"node"
]
},
"exclude": [
"node_modules",
"**/*.spec.ts"
],
"include": [
"src/**/*"
]
}
Found this Stackoverflow Error TS2351
import Strapi, { StrapiOptions } from "strapi-sdk-js"
const TheStrapi = Strapi as unknown as typeof Strapi.default
const options: StrapiOptions = {
url: "http://strapi-host/",
}
export const strapi = new TheStrapi(options)