Skip to content

Instantly share code, notes, and snippets.

@Eyas
Created January 23, 2020 03:17
Show Gist options
  • Save Eyas/a59ad953df64d15fd28b1157df1c3df5 to your computer and use it in GitHub Desktop.
Save Eyas/a59ad953df64d15fd28b1157df1c3df5 to your computer and use it in GitHub Desktop.
// Top-level module:
const wellKnownTypes = [ ... ]; // Top-level var with more than one "Type".
const dataType = ...;
function ForwardDeclareClasses(topics: ReadonlyArray<TypedTopic>): ClassMap {
const classes = new Map<string, Class>();
for (const wk of wellKnownTypes) {
classes.set(wk.subject.toString(), wk);
}
classes.set(dataType.subject.toString(), wk);
for (const topic of topics) {
// ...
}
if (classes.size === 0) {
throw new Error('Expected Class topics to exist.');
}
return classes;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment