Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
location: Vector,
mass: NonNegative,
name: String,
crew: Array(CrewMember),
});
type Ship = Static<
typeof Ship
>; /* = {
type: 'ship';
location: Vector;
mass: NonNegative;
name: string;
crew: CrewMember[];
}*/
const Fleet = Dictionary(Ship, 'number');
type Fleet = Static; // = { [_: number]: Ship }
const SpaceObject = Union(Asteroid, Planet, Ship);
type SpaceObject = Static; // = Asteroid | Planet | Ship
const isHabitable = SpaceObject.match(asteroid => false, planet => planet.habitable, ship => true);
// Pattern matching from a union
function foo(spaceObject: SpaceObject) {
if (isHabitable(spaceObject)) {
// ...
}
}
export type CriteriaListNormalized =
CriteriaBaseNormalized>[]
export type Criteria =
| CriteriaBase
| CriteriaList
export type CriteriaNormalized =
| CriteriaBaseNormalized
| CriteriaListNormalized
export const Index = t.Union(
t.String,
t.Array(t.Union(t.String, t.Array(t.String))),
t.Dictionary(t.Union(t.String, t.Array(t.String)))
)
export const GroupClause = t.Union(
t.String,
t.Array(t.String)
)
export const OrderClause = t.Union(
t.String,
t.Tuple(t.String, t.String)
)
export const TrilogyOptions = t.Partial({
client: t.Union(t.Literal('sqlite3'), t.Literal('sql.js')),
dir: t.String
})