Skip to content

Commit

Permalink
fix: enum d.ts generator
Browse files Browse the repository at this point in the history
  • Loading branch information
askuzminov committed Sep 16, 2020
1 parent 71a224b commit d1d9e89
Show file tree
Hide file tree
Showing 2 changed files with 153 additions and 153 deletions.
6 changes: 3 additions & 3 deletions src/generator/enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@ function enu(pack: string, out: MakeOuts, item: Enum, enumsList: EnumsList) {
const cName = checkSame(out, 'name');

out.js.push(`export const ${eName} = {`);
out.dts.push(`export const ${eName} = {`);
out.dts.push(`export const ${eName}: {`);

for (const field in item.values) {
const val = item.values[field].value;
if (isNumber(val) && !isNaN(val) && !isInvalid(field, val)) {
cID(val, `${pack}.${field}`);
cName(field, `${pack}.${field}`);
out.js.push(` ${field}: ${val},`);
out.dts.push(` ${field}: ${val},`);
out.dts.push(` readonly ${field}: ${val},`);
}
}

out.js.push('};');
out.dts.push('} as const;');
out.dts.push('};');
out.dts.push(`export type ${eName} = Values<typeof ${eName}>;`);
}

Expand Down

0 comments on commit d1d9e89

Please sign in to comment.