Estoy usando lib externo. Lo agregué a package.json :
dependencies: { ... "hello-world": "0.0.1", ... }Esta lib exporta un método
index.js :
const helloWorld = (name: string) => { ... } window.helloWorld = window.helloWorld || helloWorld; export default helloWorld; Ahora, estoy tratando de usar eso en mi proyecto Angular. src/types.d.ts :
declare module 'hello-world'; y tsconfig.json :
... "files": [ "types.d.ts" ] Luego en 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'); } } Pero obtengo: ERROR TypeError: hello_world__WEBPACK_IMPORTED_MODULE_0___default(...) is not a function Importarlo como import { helloWorld } from 'hello-world'; da el mismo error.
Sin embargo, cuando llamo a window.helloWorld('Bob') en la consola del depurador (F12), funciona.