The 'assure' property does not exist on the type 'NodeRequire'

advertisements

I'm trying webpack 2 code splitting.

According to this doc: https://webpack.js.org/guides/code-splitting-require/

the following code should include some.css into a new chunk named 'something'

require.ensure([], function(require) {
    require('some.css');
}, 'something');

but when I run it, I get this error:

ERROR in ./src/index.ts
(4,9): error TS2339: Property 'ensure' does not exist on type 'NodeRequire'.

Any idea about how to fix it? Thanks


I required a javascript document which then did the require. Not exactly the nicest solution, but it did work