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

Use const enums in typescript schemas #123

Closed
wants to merge 1 commit into from
Closed
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
12 changes: 6 additions & 6 deletions internal/__snapshots__/exportTypeScriptSchemas.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,7 @@ export type Vector3 = {
"LineType" => "// Generated by https://github.com/foxglove/schemas

/** An enumeration indicating how input points should be interpreted to create lines */
export enum LineType {
export const enum LineType {
/** Connected line segments: 0-1, 1-2, ..., (n-1)-n */
LINE_STRIP = 0,

Expand All @@ -904,7 +904,7 @@ export enum LineType {
"LogLevel" => "// Generated by https://github.com/foxglove/schemas

/** Log level */
export enum LogLevel {
export const enum LogLevel {
UNKNOWN = 0,

DEBUG = 1,
Expand All @@ -921,7 +921,7 @@ export enum LogLevel {
"SceneEntityDeletionType" => "// Generated by https://github.com/foxglove/schemas

/** An enumeration indicating which entities should match a SceneEntityDeletion command */
export enum SceneEntityDeletionType {
export const enum SceneEntityDeletionType {
/** Delete the existing entity on the same topic that has the provided \`id\` */
MATCHING_ID = 0,

Expand All @@ -932,7 +932,7 @@ export enum SceneEntityDeletionType {
"NumericType" => "// Generated by https://github.com/foxglove/schemas

/** Numeric type */
export enum NumericType {
export const enum NumericType {
UNKNOWN = 0,

UINT8 = 1,
Expand All @@ -955,7 +955,7 @@ export enum NumericType {
"PointsAnnotationType" => "// Generated by https://github.com/foxglove/schemas

/** Type of points annotation */
export enum PointsAnnotationType {
export const enum PointsAnnotationType {
UNKNOWN = 0,

/** Individual points: 0, 1, 2, ... */
Expand All @@ -974,7 +974,7 @@ export enum PointsAnnotationType {
"PositionCovarianceType" => "// Generated by https://github.com/foxglove/schemas

/** Type of position covariance */
export enum PositionCovarianceType {
export const enum PositionCovarianceType {
UNKNOWN = 0,

APPROXIMATED = 1,
Expand Down
2 changes: 1 addition & 1 deletion internal/generateTypeScript.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe("generateTypeScript", () => {
"// Generated by https://github.com/foxglove/schemas

/** An example enum */
export enum ExampleEnum {
export const enum ExampleEnum {
/** Value A */
A = 1,

Expand Down
6 changes: 3 additions & 3 deletions internal/generateTypeScript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ export function generateTypeScript(schema: FoxgloveSchema): string {
return `${name} = ${value},`;
}
});
definition = `/** ${schema.description} */\nexport enum ${schema.name} {\n ${fields.join(
"\n\n ",
)}\n}`;
definition = `/** ${schema.description} */\nexport const enum ${
schema.name
} {\n ${fields.join("\n\n ")}\n}`;
break;
}

Expand Down
2 changes: 1 addition & 1 deletion schemas/typescript/LineType.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion schemas/typescript/LogLevel.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion schemas/typescript/NumericType.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion schemas/typescript/PointsAnnotationType.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion schemas/typescript/PositionCovarianceType.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion schemas/typescript/SceneEntityDeletionType.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading