P.narrow<Input, Pattern> will narrow the input type to only keep the set of values that are compatible with the provided pattern type.
P.narrow<Input, Pattern>
Read the documentation for P.narrow on GitHub
P.narrow
type Input = ['a' | 'b' | 'c', 'a' | 'b' | 'c']const Pattern = ['a', P.union('a', 'b')] as consttype Narrowed = P.narrow<Input, typeof Pattern>// ^? ['a', 'a' | 'b'] Copy
type Input = ['a' | 'b' | 'c', 'a' | 'b' | 'c']const Pattern = ['a', P.union('a', 'b')] as consttype Narrowed = P.narrow<Input, typeof Pattern>// ^? ['a', 'a' | 'b']
P.narrow<Input, Pattern>
will narrow the input type to only keep the set of values that are compatible with the provided pattern type.Read the documentation for
P.narrow
on GitHub