How do you add polyfills to Globals in typescript (modules)

后端 未结 2 630
深忆病人
深忆病人 2021-01-18 00:39

I was able to find a polyfill(on stack overflow) for Array#includes and add it to typescript but after adding a small import to my file it turned into a module(I understand

2条回答
  •  时光说笑
    2021-01-18 01:23

    Besides adding a declaration, you need to include this polyfill in your code. One way to do that is by importing the file with poylfill declaration and implementation in the entry point module of your application as long as you're polyfilling core objects and want them to be available anywhere in your app (assuming you have your polyfills in ./polyfill/arrayIncludes.ts) like this:

    import './polyfill/arrayIncludes';
    

提交回复
热议问题