Issue
Using Node.js SDK, when trying to import SplitIO as a namespace in Typescript:
import { SplitIo } from '@splitsoftware/splitio';
The following error is thrown:
/node_modules/@splitsoftware/splitio/types"' has no exported member 'SplitIO'.
Root cause
TypeScript implicitly imports SplitIO namespace when doing import { SplitFactory } from '@splitsoftware/splitio';
, and even the “typeRoots” config is not affecting it because the declaration file is included in the SDK package and the “types” field is properly configured.
Answer
You can explicitly import the SplitIO namespace (for example, on modules/files where SplitFactory is not being imported). To achieve this, include the following line:import SplitIO from '@splitsoftware/splitio/types/splitio';
This requires including "allowSyntheticDefaultImports": true
in tsconfig.
Comments
0 comments
Please sign in to leave a comment.