You could also just add es2015 to tsconfig -> compilerOptions -> lib and set module as mentioned elsewhere in the comments. lib tells tsc "Hey, I know I'm compiling to ES5, but you can count on an ES2015 polyfill." You could restrict the scope further with just es2015.promise, which would tell it that a Promise constructor will be available at runtime.
If you're explicit, you end up with lib being the exact list of polyfills that will be required.
It's also worth mentioning, in this setup, you could add your gulp command to the package.json scripts, and then no one needs to know about npx as npm will add ./node_modules/.bin to the path for anything executed with npm run.
You could also just add
es2015
totsconfig -> compilerOptions -> lib
and setmodule
as mentioned elsewhere in the comments.lib
tells tsc "Hey, I know I'm compiling to ES5, but you can count on an ES2015 polyfill." You could restrict the scope further with justes2015.promise
, which would tell it that a Promise constructor will be available at runtime.If you're explicit, you end up with
lib
being the exact list of polyfills that will be required.It's also worth mentioning, in this setup, you could add your
gulp
command to thepackage.json
scripts, and then no one needs to know about npx as npm will add./node_modules/.bin
to the path for anything executed withnpm run
.e.g.
You'd then be able to run gulp with
npm run build
oryarn build
.I like using package.json scripts, because it's self-documenting in terms of all of the available build commands.