Skip to content

Commit

Permalink
add ignored null to RawGenResult for convenience
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanatkn committed Jan 13, 2023
1 parent 496f6f8 commit a8cf511
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# changelog

## 0.68.1

- **break**: relax the type of `RawGenResult` to include an ignored `null`

## 0.68.0

- **break**: move `types` from the main config to the build config
Expand Down
6 changes: 4 additions & 2 deletions src/gen/gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export interface GenContext {
log: Logger;
}
// TODO consider other return data - metadata? effects? non-file build artifacts?
export type RawGenResult = string | RawGenFile | RawGenFile[];
export type RawGenResult = string | RawGenFile | RawGenFile[] | null;
export interface RawGenFile {
content: string;
// Defaults to file name without the `.gen` or `.schema`, and can be a relative path.
Expand Down Expand Up @@ -68,7 +68,9 @@ export const toGenResult = (originId: string, rawResult: RawGenResult): GenResul
};

const toGenFiles = (originId: string, rawResult: RawGenResult): GenFile[] => {
if (typeof rawResult === 'string') {
if (rawResult === null) {
return [];
} else if (typeof rawResult === 'string') {
return [toGenFile(originId, {content: rawResult})];
} else if (Array.isArray(rawResult)) {
const files = rawResult.map((f) => toGenFile(originId, f));
Expand Down

0 comments on commit a8cf511

Please sign in to comment.