I just do not understand. When it was relatively easy, I downloaded the fragment from DefinitelyTyped, it suggested that it was declared globally, I added a script, and it worked. Now it seems like I have no other choice to use a sophisticated package manager and asynchronous boot system, possibly with an optimizer for production.
Ideally, I just need TypeScript code like this
// maybe some import? Promise.resolve("foo").then(function(msg) { console.log(msg); }
compile some JavaScript like this:
Promise.resolve("foo").then(function(msg) { console.log(msg); }
I want it to work in a browser or in a minimal environment like Rhino. If necessary, I can enable require.js, almond.js, build using a browser or something else, but I want it to work without the need for XHR.
So far I have tried:
- Using global (surrounding) modules: it was no longer possible to find one for Bluebird.
- Using ES6 import with AMD modules, setting
outFile to get a package of my code, and then including the files in that order: almond.js, bluebird.js, my-code.js and some code requiring the main module so that everything works: Error: See almond README: incorrect module build, no module name (apparently, bluebird.js , downloaded from the official page, does not determine the name in AMD, should I create it myself or what ...?) - Same as previous point using full require.js:
missing bluebird . - The same as at the previous point using a pad as follows:
requirejs.config({shim: { bluebird: { exports: "Promise" }}}) : exception from uncaught JavaScript throw: Error: Mismatched anonymous define() module and all Bluebird code in the error message. - Bluebird definition file fix: Not allowed in ES6 mode:
Subsequent variable declarations must have the same type.
It seems to me that I spent too much time on such an obviously simple request, so I will try to ask for StackOverflow :)
source share