提问者:小点点

如何在TypeScript中导出库?


尝试以这种方式导出socket.io时,从'socket.io-client'导入socketIOClient;获取错误TS1192:Module'“***/node_modules/socket.io-client/build/index”‘没有默认导出

我的tsconfig.client.json文件具有以下设置:

{
  "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"
  ]
}

共1个答案

匿名用户

是否尝试导入单个属性?

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

如果不起作用,试试这个:

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