Skip to content

Commit eec516e

Browse files
committed
Conceptually this extends Error
We just don't use native classes for this and brand check with $$typeof.
1 parent e201f45 commit eec516e

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

packages/react/src/ReactPostpone.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,15 @@
99

1010
import {REACT_POSTPONE_TYPE} from 'shared/ReactSymbols';
1111

12-
export type Postpone = {
13-
$$typeof: symbol,
14-
message: string,
15-
stack: string,
16-
...
17-
};
12+
declare class Postpone extends Error {
13+
$$typeof: symbol;
14+
}
15+
16+
export type {Postpone};
1817

1918
export function postpone(reason: string): void {
2019
// eslint-disable-next-line react-internal/prod-error-codes
21-
const error = new Error(reason);
22-
(error: any).$$typeof = REACT_POSTPONE_TYPE;
23-
throw error;
20+
const postponeInstance: Postpone = (new Error(reason): any);
21+
postponeInstance.$$typeof = REACT_POSTPONE_TYPE;
22+
throw postponeInstance;
2423
}

0 commit comments

Comments
 (0)