Uolary
Uolary

Reputation: 119

How to export libraries in TypeScript?

When trying to export socket.io this way import socketIOClient from 'socket.io-client'; getting error TS1192: Module '"***/node_modules/socket.io-client/build/index"' has no default export.

My tsconfig.client.json file has the following settings:

{
  "compilerOptions": {
    "outDir": "./public/js/",
    "noImplicitAny": true,
    "module": "es6",
    "moduleResolution": "node",
    "target": "es5",
    "jsx": "react",
    "allowSyntheticDefaultImports": true,
    "allowJs": true,
    "lib":[
      "es2015", "dom"
    ]
  },
  "include": [
    "src/client/**/*"
  ],
  "exclude": [
    "node_modules"
  ]
}

Upvotes: 1

Views: 385

Answers (1)

aaaeee
aaaeee

Reputation: 46

Have you tried to import a single property?

import { io } from 'socket.io-client';

If it doesn't work, try this:

import { connect } from 'socket.io-client';

Upvotes: 3

Related Questions