File tree Expand file tree Collapse file tree 3 files changed +34
-2
lines changed
Expand file tree Collapse file tree 3 files changed +34
-2
lines changed Original file line number Diff line number Diff line change @@ -241,6 +241,7 @@ export class LuaPrinter {
241241 // Inline lualib features
242242 sourceChunks . push ( "-- Lua Library inline imports\n" ) ;
243243 sourceChunks . push ( loadInlineLualibFeatures ( file . luaLibFeatures , this . emitHost ) ) ;
244+ sourceChunks . push ( "-- End of Lua Library inline imports\n" ) ;
244245 }
245246
246247 if ( this . options . sourceMapTraceback && ! isBundleEnabled ( this . options ) ) {
Original file line number Diff line number Diff line change @@ -85,7 +85,7 @@ export class __TS__Promise<T> implements Promise<T> {
8585 }
8686 } else {
8787 // We always want to resolve our child promise if this promise is resolved, even if we have no handler
88- this . fulfilledCallbacks . push ( ( ) => resolve ( undefined ) ) ;
88+ this . fulfilledCallbacks . push ( v => resolve ( v ) ) ;
8989 }
9090
9191 if ( onRejected ) {
@@ -96,6 +96,9 @@ export class __TS__Promise<T> implements Promise<T> {
9696 // If promise already rejected, immediately call callback
9797 internalCallback ( this . rejectionReason ) ;
9898 }
99+ } else {
100+ // We always want to reject our child promise if this promise is rejected, even if we have no handler
101+ this . rejectedCallbacks . push ( err => reject ( err ) ) ;
99102 }
100103
101104 if ( isFulfilled ) {
Original file line number Diff line number Diff line change @@ -523,6 +523,34 @@ test("chained then throws", () => {
523523 ] ) ;
524524} ) ;
525525
526+ test ( "empty then resolves" , ( ) => {
527+ util . testFunction `
528+ const { promise, resolve } = defer<string>();
529+
530+ promise.then().then(v => { log("then2", v) });
531+
532+ resolve("mydata");
533+
534+ return allLogs;
535+ `
536+ . setTsHeader ( promiseTestLib )
537+ . expectToEqual ( [ "then2" , "mydata" ] ) ;
538+ } ) ;
539+
540+ test ( "empty then rejects" , ( ) => {
541+ util . testFunction `
542+ const { promise, reject } = defer<string>();
543+
544+ promise.then().catch(err => { log("catch", err) });
545+
546+ reject("my error");
547+
548+ return allLogs;
549+ `
550+ . setTsHeader ( promiseTestLib )
551+ . expectToEqual ( [ "catch" , "my error" ] ) ;
552+ } ) ;
553+
526554test ( "catch on rejected promise immediately calls callback" , ( ) => {
527555 util . testFunction `
528556 Promise.reject("already rejected").catch(reason => { log(reason); });
@@ -592,7 +620,7 @@ describe("finally behaves same as then/catch", () => {
592620 log("final code");
593621 })
594622 .catch(reason => {
595- log("handling error", data );
623+ log("handling error", reason );
596624 log("final code");
597625 });
598626 ` ;
You can’t perform that action at this time.
0 commit comments