Giter VIP home page Giter VIP logo

Comments (4)

scttcper avatar scttcper commented on September 14, 2024 1
import koaSwagger from 'koa2-swagger-ui';

is working for me. maybe make sure you have "esModuleInterop": true, in your tsconfig.

here's what i'm using

{
  "compileOnSave": false,
  "compilerOptions": {
    "moduleResolution": "node",
    "lib": ["es2018"],
    "target": "es2017",
    "module": "commonjs",
    "esModuleInterop": true,
    "strict": true,
    "noImplicitAny": false,
    "noUnusedLocals": true,
    "declaration": true,
    "sourceMap": true,
    "inlineSources": true,
    "outDir": "dist"
  },
  "include": ["src/index.ts"]
}

from koa2-swagger-ui.

nodehack avatar nodehack commented on September 14, 2024

Thanks Scott!
Adding "esModuleInterop": true worked but I had to update a bunch of other imports to use that style. Sounds like a discussion on requiring esModuleInterop could end in a holy war so I'll just take my win and run.

Thanks again!

from koa2-swagger-ui.

scttcper avatar scttcper commented on September 14, 2024

It’s probably because I tried to keep backwards comparability with the previous nodejs version. Oh well

from koa2-swagger-ui.

dgreene1 avatar dgreene1 commented on September 14, 2024

Okay @nodehack (and others), here's a workaround that allows you to include the library

  • saves you from having to turning on esModuleInterop (which is great since that messes up every other import)
  • it also gets you the types
import { KoaSwaggerUiOptions } from 'koa2-swagger-ui';
type koa2SwaggerUiFunc = (config: Partial<KoaSwaggerUiOptions>) => Koa.Middleware
// tslint:disable-next-line: no-var-requires // We actually have to use require for koa2-swagger-ui
const koaSwagger = require('koa2-swagger-ui') as koa2SwaggerUiFunc;

from koa2-swagger-ui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.