简体   繁体   中英

Typescript import and Webpack

I am trying to use the hellosign-embedded module from my TypeScript application, which is then packaged using Webpack and run as part of a web page.

I've also imported the @types typings .

The problem is that if I use:

import * as HelloSign from "hellosign-embedded";

Typescript gives me an error:

error TS2306: File 'D:/Work/ProjectX/node_modules/@types/hellosign-embedded/index.d.ts' is not a module.

I've also tried simply using:

import "hellosign-embedded";

Which gives me access to the HelloSign global from my code, but the problem then is that after running webpack, when running it in the browser, HelloSign is not found:

Uncaught ReferenceError: HelloSign is not defined
    at HTMLDocument.<anonymous> (onboarding.tsx:10)
    at mightThrow (jquery.js:3570)
    at process (jquery.js:3638)

What's the proper way to import this library? Is there a problem with the typings provided?

do this it works for me :

   import HelloSign = require("hellosign-embedded");

   console.log(HelloSign.init);

go to the definition file : node_modules/@types/hellosign-embedded/index.d.ts

add this to the end of file :

export = HelloSign;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM