Skip to content

Commit

Permalink
ref(utils): Make States a const enum (#4210)
Browse files Browse the repository at this point in the history
`States` is an interally used enum, so we do not need the runtime support. The `States` enum lives in `packages/utils/src/syncpromise.ts` and is used by `SyncPromise` to manage state internally.

According to the TS docs: https://www.typescriptlang.org/docs/handbook/enums.html 

> Const enums can only use constant enum expressions and unlike regular enums they are completely removed during compilation. Const enum members are inlined at use sites. This is possible since const enums cannot have computed members. 

This helps save on bundle size.
  • Loading branch information
AbhiPrasad authored Dec 2, 2021
1 parent 7ec20cb commit 3370277
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/utils/src/syncpromise.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import { isThenable } from './is';

/** SyncPromise internal states */
enum States {
const enum States {
/** Pending */
PENDING = 'PENDING',
/** Resolved / OK */
Expand Down

0 comments on commit 3370277

Please sign in to comment.