Skip to content

Commit

Permalink
feat(fhir-ts-codegen): support mutual recursion
Browse files Browse the repository at this point in the history
Generates all types as recursive types until we can identify which types
are mutually recursive. Currently, unaware of any performance tradeoffs
from making types recursive.
  • Loading branch information
tangdrew committed Feb 20, 2019
1 parent cafcd26 commit 4a869f3
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions packages/fhir-ts-codegen/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,17 @@ export class Generator {
const [required, optional] = this.categorizeElementDefinitions(definitions);
const requiredProperties = this.getProperties(required);
const optionalProperties = this.getProperties(optional);
const isRecursive = definitions.some(definition => {
const { display } = parseType(definition);
return display.some(type => type === name);
});

/**
* TODO: Determine if type is mutually recursive with another type.
* Fine to make all types recursive for now. Unsure about perf impacts.
*/
const isRecursive = true;
// const isRecursive =
// definitions.some(definition => {
// const { display } = parseType(definition);
// return display.some(type => type === name);
// });

const runType = `t.intersection([
t.type({
Expand Down

0 comments on commit 4a869f3

Please sign in to comment.