Skip to content

Instantly share code, notes, and snippets.

@justanotherdot
Last active August 29, 2017 03:39
Show Gist options
  • Save justanotherdot/305e4ea88e6e137b0bb54e7e2bbf1885 to your computer and use it in GitHub Desktop.
Save justanotherdot/305e4ea88e6e137b0bb54e7e2bbf1885 to your computer and use it in GitHub Desktop.
Restrict a field to have only one level of nesting for an embedded array
type UnionTy = 'a' | 'b';
type Arr = Array<UnionTy | UnionTy[]>;
interface Demo {
prop: Arr,
}
const demo: Demo = {
prop: ['a', ['a', 'b']]
// prop: ['a', ['a', 'b', ['a']]] // => Errors.
};
console.log(demo);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment