Skip to content

Commit

Permalink
Use const enums in typescript since regular enums generate extremely …
Browse files Browse the repository at this point in the history
…bad code (#64486)

To get good behavior in typescript, your enums need to be 'const enum', otherwise it generates some really gross JS with runtime overhead.
  • Loading branch information
kg authored Jan 29, 2022
1 parent 7de2905 commit cede333
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/mono/wasm/runtime/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ export function assert(condition: unknown, messsage: string): asserts condition
}

// see src/mono/wasm/driver.c MARSHAL_TYPE_xxx and Runtime.cs MarshalType
export enum MarshalType {
export const enum MarshalType {
NULL = 0,
INT = 1,
FP64 = 2,
Expand Down Expand Up @@ -230,7 +230,7 @@ export enum MarshalType {
}

// see src/mono/wasm/driver.c MARSHAL_ERROR_xxx and Runtime.cs
export enum MarshalError {
export const enum MarshalError {
BUFFER_TOO_SMALL = 512,
NULL_CLASS_POINTER = 513,
NULL_TYPE_POINTER = 514,
Expand Down

0 comments on commit cede333

Please sign in to comment.