Skip to content

Commit

Permalink
Merge pull request #92 from rkristof/angular-promises
Browse files Browse the repository at this point in the history
Fix awaiting Promises when using with Angular
  • Loading branch information
ceifa authored Oct 29, 2023
2 parents b6b7f39 + dda0292 commit f2b2a25
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/type-extensions/promise.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class PromiseTypeExtension<T = unknown> extends TypeExtension<Promise<T>> {
thread.lua.lua_setfield(thread.address, metatableIndex, '__gc')

const checkSelf = (self: Promise<any>): true => {
if (Promise.resolve(self) !== self) {
if (Promise.resolve(self) !== self && typeof self.then !== 'function') {
throw new Error('promise method called without self instance')
}
return true
Expand Down Expand Up @@ -131,7 +131,7 @@ class PromiseTypeExtension<T = unknown> extends TypeExtension<Promise<T>> {
}

public pushValue(thread: Thread, decoration: Decoration<Promise<T>>): boolean {
if (Promise.resolve(decoration.target) !== decoration.target) {
if (Promise.resolve(decoration.target) !== decoration.target && typeof decoration.target.then !== 'function') {
return false
}
return super.pushValue(thread, decoration)
Expand Down
2 changes: 1 addition & 1 deletion src/type-extensions/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ class ProxyTypeExtension extends TypeExtension<any, ProxyDecorationOptions> {
}
}

if (Promise.resolve(target) === target) {
if (Promise.resolve(target) === target || typeof target.then === 'function') {
return false
}
} else if (options.proxy === false) {
Expand Down

0 comments on commit f2b2a25

Please sign in to comment.