I'm using external lib. I added it to package.json:
dependencies: {
...
"hello-world": "0.0.1",
...
}
This lib exports one method
index.js:
const helloWorld = (name: string) => {
...
}
window.helloWorld = window.helloWorld || helloWorld;
export default helloWorld;
Now, Im trying to use that in my Angular project.
I added src/types.d.ts:
declare module 'hello-world';
and tsconfig.json:
...
"files": [
"types.d.ts"
]
Then in app.component.ts:
...
import helloWorld from 'hello-world';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent implements OnInit {
ngOnInit(): void {
helloWorld('Bob');
}
}
But im getting:
ERROR TypeError: hello_world__WEBPACK_IMPORTED_MODULE_0___default(...) is not a function
Importing it like import { helloWorld } from 'hello-world'; gives the same error.
However when i call window.helloWorld('Bob') in debugger console (F12) it works.