Communities for your favorite technologies. Explore all Collectives
Ask questions, find answers and collaborate at work with Stack Overflow for Teams.
Ask questions, find answers and collaborate at work with Stack Overflow for Teams. Explore Teams
Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
How to define the data type of value in the nodejs function written in typescript, so that error of Object is of type unknow can be solved ?
res.get()
You need to implement type for value. Try smth like this:
type valueType = { id: string, field1: number, field2: string, } const obj = { a: { id: '12', field1: 1, field2: 'asdas', } } for (const [key, value] of Object.entries(obj)) { const typedValue: valueType = value; }
Add a comment
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.
res.get(). Of you post a minimal reproducible example and include the relevant code in you as text then we can help you much better with this.