0

There exists the exact same question, but it was about array parameters.

How do I type str in this case?

const func = ({str, ...rest})=>{//doStuff}

This did not work:

const func = ({str, ...rest}:{str:string})=>{//doStuff}

This neither:

const func = ({str, ...rest}:{str:string; ...rest:any[]})=>{//doStuff}
2
  • Please show how your function is supposed to look like and work in JS Commented Dec 6, 2018 at 11:30
  • 1
    @miensol Why?... Commented Dec 6, 2018 at 13:03

1 Answer 1

1

You want this:

type Func = (arg: {str: string} & {[key: string]: any}) => any

const func: Func = ({str, ...rest})=>{/* doStuff */}    
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.