Answer the question
In order to leave comments, you need to log in
How to type the rest-operator when destructuring?
Good day!
Please tell me how to write the typing correctly in this example:
type snbnus = string | number | boolean | null | undefined | symbol;
const func = (...elements: snbnus[]) => {
const [targetArray, ...rest] = elements;
};
const [targetArray: snbnus[], ...rest: snbnus[]] = elements;
Answer the question
In order to leave comments, you need to log in
i would do that
type snbnus = string | number | boolean | null | undefined | symbol;
const func = (targetArray: snbnus[], ...rest: snbnus[]) => {
console.log(targetArray, rest);
};
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question