Skip to content

Commit

Permalink
Correctly quote as-const enum values
Browse files Browse the repository at this point in the history
Resolves #1727
  • Loading branch information
Gerrit0 committed Oct 5, 2021
1 parent 7521f1d commit 244e904
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Expand Up @@ -2,7 +2,8 @@

### Bug Fixes

- Fixed flash when navigating to a second page when OS theme does not match selected theme.
- Fixed flash when navigating to a second page when OS theme does not match selected theme, #1709.
- Fixed improper quoting of `as const` style enums, #1727.

### Thanks!

Expand Down
4 changes: 3 additions & 1 deletion src/lib/converter/symbols.ts
Expand Up @@ -897,7 +897,9 @@ function convertVariableAsEnum(
void 0
);

reflection.defaultValue = (prop.initializer as ts.StringLiteral).text;
reflection.defaultValue = JSON.stringify(
(prop.initializer as ts.StringLiteral).text
);

rc.finalizeDeclarationReflection(reflection, childSymbol, void 0);
}
Expand Down
2 changes: 2 additions & 0 deletions src/test/behaviorTests.ts
Expand Up @@ -20,6 +20,8 @@ export const behaviorTests: Record<
equal(SomeEnumLike.kind, ReflectionKind.Variable);
const SomeEnumLikeTagged = query(project, "SomeEnumLikeTagged");
equal(SomeEnumLikeTagged.kind, ReflectionKind.Enum);
const A = query(project, "SomeEnumLikeTagged.a");
equal(A.defaultValue, '"a"');
},
duplicateHeritageClauses(project) {
const b = query(project, "B");
Expand Down

0 comments on commit 244e904

Please sign in to comment.