Suppose I have a library published in NPM with only one line:
function myLib(x) {return x;}
Want to import it into app.component.tsthis repo
https://github.com/AngularClass/angular2-webpack-starter/blob/master/src/app/app.component.ts
After npm install myLiband create the file index.d.tsin node_modules/myLib/as
export default function myLib (x: any): any;
Below are my QUESTIONS:
Q1.Use it in app.component.tslike:
import myLib from 'myLib'
console.log( myLib )
Result undefinedwhy?
Q2.If you change the code as below:
import * as myLib from 'myLib'
console.log( myLib )
The result function myLib(x) {return x;}seems correct, but
console.log( myLib(123) )
An error message appears in Webpack:
Src / app / app.component.ts: 12: 21
Cannot invoke an expression whose type does not have a call signature
What the heck?
Thank!!