Last active
August 29, 2017 03:39
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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