python (65.1k questions)
javascript (44.2k questions)
reactjs (22.7k questions)
java (20.8k questions)
c# (17.4k questions)
html (16.3k questions)
r (13.7k questions)
android (12.9k questions)
Narrow union types for custom react hook
I have 4 objects with few similar keys & a few different keys. I am using their union for database operations like so ->
type Objects = Food | Diary | Plan | Recipe ;
Pagination custom hook
fun...
Narayan Waraich
Votes: 0
Answers: 1
Factory narrowing inside switch statement
Is it possible to narrow type output of a factory create method by literal types?
I've managed to get some narrowing with if statements and discriminated unions, but this is creational method so I'm n...
steakoverflow
Votes: 0
Answers: 2
Infer narrow type from parent object referencing itself in typescript
I would like to constrain a parameter type of a callback function that is inside an object like this:
makeObj({
items: [
{
value: "foo",
func(items) {}
},
{
v...
schl3ck
Votes: 0
Answers: 1
How to narrow a list of unions?
I have a variable of type list[A | B] that could hold a mixed list (like [A(), B(), A()]).
If I later reach some corner case and I want to make sure all elements are actually of type A, I can assert i...
fonini
Votes: 0
Answers: 1