I am confused. It well can be the result of ECMAScript spec or something, but all this doesn't make sense to me.
TypeScript Version: 3.7.x-dev.201xxxxx
Search Terms:promise undefined and I looked through all of the 5 pages + looked through FAQ
Code:
typeTypeA={value: number;}consttest=(): Promise<TypeA>=>{returnnewPromise<TypeA>(resolve=>{resolve(undefined);// Result of test() is Promise of TypeA. I return a promise that is resolved with undefined and it's ok for some reason.});};consttest2=(): Promise<TypeA>=>{returnPromise.resolve(undefined);};test().then(typeAInstance=>{// At this point here `typeAInstance` is of type TypeA and not! of `TypeA | undefined`console.log(typeAInstance.value.toFixed())});Expected behavior:
Both Functions should prevent me from doing writing stupid code at compile time.
Actual behavior:
Only second one does prevent me. First one allows runtime error to happened in the end.
Playground Link:http://www.typescriptlang.org/play/?ts=3.8.0-dev.20200211&ssl=1&ssc=1&pln=14&pc=4#code/C4TwDgpgBAKuEEEoF4oG8BQUoDcCGANgK4QBcUAdkQLYBGEATgNwYC+GAxgPYUDOwUYBH4ooACgCU5AAoMu1AJa8IAHjiQEAPhTbM2BhGBEGFShADuUWfKWr1iTWIO8uBHNGS6s2KM9fuxIgoAEwgAMwUKCGCJFmxWWLYWbj4BIX4AJlFJGTlFZTV4LR10b31DY1NrfIgAOj83CECQ8MjoxNYWdOBJWuAACwgKMVANAElUvAoODy9sFJcCOoIuAHMRoon+KZna-GI64C4AMQUAD2jJCTZYoA
Related Issues:
I don't understand where this undefined as one of the potential argument types is coming from:

My lib.es5.d.ts contains this:
declaretypePromiseConstructorLike=new<T>(executor: (resolve: (value?: T|PromiseLike<T>)=>void,reject: (reason?: any)=>void)=>void)=>PromiseLike<T>;
My lib.es2015.promise.d.ts contains this:
new<T>(executor: (resolve: (value?: T|PromiseLike<T>)=>void,reject: (reason?: any)=>void)=>void): Promise<T>;
I am confused. It well can be the result of ECMAScript spec or something, but all this doesn't make sense to me.
TypeScript Version: 3.7.x-dev.201xxxxx
Search Terms:
promise undefinedand I looked through all of the 5 pages + looked through FAQCode:
Expected behavior:
Both Functions should prevent me from doing writing stupid code at compile time.
Actual behavior:
Only second one does prevent me. First one allows runtime error to happened in the end.
Playground Link:http://www.typescriptlang.org/play/?ts=3.8.0-dev.20200211&ssl=1&ssc=1&pln=14&pc=4#code/C4TwDgpgBAKuEEEoF4oG8BQUoDcCGANgK4QBcUAdkQLYBGEATgNwYC+GAxgPYUDOwUYBH4ooACgCU5AAoMu1AJa8IAHjiQEAPhTbM2BhGBEGFShADuUWfKWr1iTWIO8uBHNGS6s2KM9fuxIgoAEwgAMwUKCGCJFmxWWLYWbj4BIX4AJlFJGTlFZTV4LR10b31DY1NrfIgAOj83CECQ8MjoxNYWdOBJWuAACwgKMVANAElUvAoODy9sFJcCOoIuAHMRoon+KZna-GI64C4AMQUAD2jJCTZYoA
Related Issues:
I don't understand where this

undefinedas one of the potential argument types is coming from:My
lib.es5.d.tscontains this:My
lib.es2015.promise.d.tscontains this: