-
Notifications
You must be signed in to change notification settings - Fork 12.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Global Promise assumed from custom? See resultant awaiter code. #12374
Comments
It looks to me like the transpiled code doesn't use the import alias because it doesn't need to. |
@aluanhaddad It makes no sense to me that it's automatically figuring out what my promise module is. |
Also I found this odd: export function awaiterFactory(UserPromise:PromiseConstructorLike):Awaiter
{
return (thisArg:any, _arguments:any[], P:PromiseConstructorLike, generator:Function) =>
{
awaiter(thisArg, _arguments, P || UserPromise, generator);
};
} I know it's my code, but I expected it to work to fix my woes. |
in the TypeScript source you have async function bumpVersion(type:string): NPromise<File[]> {
} Here, the compiler uses the return type function bumpVersion(type) { // Promise_1.Promise === NPromise
return __awaiter(this, void 0, Promise_1.Promise, function () {
}
} This is the only case, as far as I know, of type directed emit in TypeScript and was necessary to downlevel |
@aluanhaddad OHHH WOW. Okay... That's really smart. :| |
After updating to the dev version. I noticed that the diff when I checked in showed this code with
Promise_1.Promise
instead ofvoid 0
. But then when I thought about it, how is this happening?The compiler tells me I'm not allowed to use
Promise
as a name, but then somehow knows where to get my ownPromise
module from? :/Can someone please explain what's going on here? Why is this changing so much? What is this magic?
TypeScript Version: 2.2.0-dev.20161117
Code
https://github.com/electricessence/TypeScript.NET/blob/master/_gulp/bumpVersion.js#L22
https://github.com/electricessence/TypeScript.NET/blob/master/_gulp/bumpVersion.ts#L27
My solution for 2.1.1 was to create an awaiter with a factory so that each module could actually have it's own Promise lib:
https://github.com/electricessence/TypeScript.NET/blob/master/source/awaiter.ts#L50
The text was updated successfully, but these errors were encountered: