Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Commit f854ce0

Browse files
committed
fix: Promise.toString() to look like native function
1 parent 5c7bc01 commit f854ce0

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

Diff for: lib/zone.ts

+4
Original file line numberDiff line numberDiff line change
@@ -1151,6 +1151,10 @@ const Zone: ZoneType = (function(global: any) {
11511151
}
11521152

11531153
class ZoneAwarePromise<R> implements Promise<R> {
1154+
static toString() {
1155+
return 'function ZoneAwarePromise() { [native code] }';
1156+
}
1157+
11541158
static resolve<R>(value: R): Promise<R> {
11551159
return resolvePromise(<ZoneAwarePromise<R>>new this(null), RESOLVED, value);
11561160
}

Diff for: test/common/Promise.spec.ts

+4
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ describe(
5555
log = [];
5656
});
5757

58+
it('should pretend to be a native code', () => {
59+
expect(String(Promise).indexOf('[native code]') >= 0).toBe(true);
60+
});
61+
5862
it('should make sure that new Promise is instance of Promise', () => {
5963
expect(Promise.resolve(123) instanceof Promise).toBe(true);
6064
expect(new Promise(() => null) instanceof Promise).toBe(true);

0 commit comments

Comments
 (0)