• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: Typescript Issue – Typescript dosen’t Infer object properties

Resolved: Typescript Issue – Typescript dosen’t Infer object properties

0
By Isaac Tonny on 18/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

I have a trouble with Typescript I am trying to infer the properties of an Object dynamically.
take a look at the below code
enter image description here
as you can see Typescript can infer a global UI properties
but When I put the additional property in the Actions Object enter image description here
Typescript doesn’t infer Object properties
enter image description here
How can I achieve it? please give any idea

Answer:

Your mapper function works as expected :
The problem lies in the fn function which infers a union as a return type. { openModal: string } | { addDirectory: string } in your example.
So you need to explicit the return type with a generic :
Playground

If you have better answer, please add a comment about this, thank you!

typescript
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: Why reference in pointer array doesn’t have data?

24/03/2023

Resolved: EntityFramework creates/runs migrations using parameterless DataContext instance

24/03/2023

Resolved: Visual Studio 2022 crashes when using breakpoints

24/03/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.