[[+content_image]]
T
T
TheSnegok2021-09-03 19:00:23
typescript
TheSnegok, 2021-09-03 19:00:23

Is the array of strings properly typed?

Typescript does not swear, but when passing it through props, it swears that everything needs to be typed as string | string[]:

const projectInfo: (string | string[])[][] = [['Registration form', 'Page with registration form of four fields, which displays an error notification if it is incorrectly filled.', ['Javascript', 'CSS']], ['Giphy', 'Page for search and watch gif files, from Giphy API. Multiple language and may copy gif.', ['React', 'Redax', 'Axios', 'CSS']], ['Landing Glopt', 'A page with several section, addaptation for any device.', ['Javascript', 'SASS', 'GULP']], ['Project Euler', 'Answers and solutions to problems of the famous Euler project.', ['Javascript']]
];

Answer the question

In order to leave comments, you need to log in

[[+comments_count]] answer(s)
D
Dmitry Belyaev, 2021-09-03
@TheSnegok

It's better to make a more precise type: [string, string, string[]][]
https://www.typescriptlang.org/play?#code/MYewdgzg...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question