Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ivank committed Sep 5, 2022
1 parent 480654a commit 1d98485
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 15 deletions.
2 changes: 1 addition & 1 deletion packages/avro-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"devDependencies": {
"@types/jest": "^26.0.20",
"@types/node": "^14.14.28",
"avsc": "^5.5.6",
"avsc": "^5.7.5",
"eslint-config-prettier": "^7.2.0",
"jest": "^26.6.3",
"moment": "^2.29.1",
Expand Down
28 changes: 14 additions & 14 deletions packages/avro-ts/src/types/enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ export const isEnumType = (type: Schema): type is schema.EnumType =>

export const convertEnumType: Convert<schema.EnumType> = (context, schema) => {
const namespace = schema.namespace ?? context.namespace;
const type = context.withTypescriptEnums === true ?
Node.Enum({
name: convertName(firstUpperCase(schema.name)),
members: schema.symbols.map(val => Node.EnumMember({ name: val, value: val })),
isExport: true,
jsDoc: schema.default ? withDefault(schema.default, schema.doc) : schema.doc,
})
:
Type.Alias({
name: convertName(firstUpperCase(schema.name)),
type: Type.Union(schema.symbols.map((symbol) => Type.Literal(symbol))),
isExport: true,
jsDoc: schema.doc,
});
const type =
context.withTypescriptEnums === true
? Node.Enum({
name: convertName(firstUpperCase(schema.name)),
members: schema.symbols.map((val) => Node.EnumMember({ name: val, value: val })),
isExport: true,
jsDoc: schema.default ? withDefault(schema.default, schema.doc) : schema.doc,
})
: Type.Alias({
name: convertName(firstUpperCase(schema.name)),
type: Type.Union(schema.symbols.map((symbol) => Type.Literal(symbol))),
isExport: true,
jsDoc: schema.doc,
});

return namedType(type, context, schema, namespace);
};
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2151,6 +2151,11 @@ avsc@^5.5.6:
resolved "https://registry.yarnpkg.com/avsc/-/avsc-5.6.0.tgz#b05d308f719dc7c24a427a55dff4e1fb2fa41fca"
integrity sha512-aZ/tCgSaXnIgYomdtSiYkJb5iStk9D0Qls/VXIGb+Z+seOQmgEA8YfzEPw9qgJYi3JyLVRwfta06ztVXtrhekA==

avsc@^5.7.5:
version "5.7.5"
resolved "https://registry.yarnpkg.com/avsc/-/avsc-5.7.5.tgz#da1840506b3ff69e14b5f87ce511e9c384405166"
integrity sha512-vkyt1+sj6qaD9oMtqqLE2pZ2IcHI66kFx8lpnVuXp55SnNPjKghfOhVfZpaDwDPpY0oVWP3Qu1uHZWxF3E856A==

aws-sign2@~0.7.0:
version "0.7.0"
resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.7.0.tgz#b46e890934a9591f2d2f6f86d7e6a9f1b3fe76a8"
Expand Down

0 comments on commit 1d98485

Please sign in to comment.