Skip to content
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

Fix awaiting Promises when using with Angular #92

Merged
merged 3 commits into from
Oct 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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