Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jquintozamora/8a292b74aabd2f8d4a2212b5e469eb43 to your computer and use it in GitHub Desktop.
Save jquintozamora/8a292b74aabd2f8d4a2212b5e469eb43 to your computer and use it in GitHub Desktop.
import(/* webpackChunkName: "momentjs" */ "moment")
.then(function (moment) {
// lazyModule has all of the proper types, autocomplete works,
// type checking works, code references work \o/
var time = moment().format();
console.log("TypeScript >= 2.4.0 Dynamic Import Expression:");
console.log(time);
_this.setState({ time: time });
})
.catch(function (err) {
console.log("Failed to load moment", err);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment