How to use "required" Webpacks and "require.ensure" in TypScript

I am trying to integrate TypeScript into Webpack and am looking for some @types types that will help with all the specific Webpack materials.

I used declare function require(string): any; to use fe .: require('some.scss') , but was quickly annoyed by adding it directly or over the syntax /// <reference path="... and hoping there was a better way to do this.

The ideal thing would be just npm i @types/webpack , but this package only seems to be for the Webpack configuration file, which I think is completely useless ...

to be more specific, I'm trying to get this code to work in TypeScript:

 require.ensure([ require('./first') ], function(require) { require('./second') }, 'second'); 
+6
source share
1 answer

They are available at @ types / webpack-env

 npm install --save-dev @types/webpack-env 
+7
source

Source: https://habr.com/ru/post/1014015/


All Articles