Dr. Derek Austin šŸ„³
1 min readOct 6, 2022

--

I use TypeScript exclusively so never have any issues knowing if I forget a required parameter, since I'll have a build error.

I agree with you that order is a pain, which is the main reason I advocate always using an object. After all, the "always pass function parameters as an object" is a well-known pattern from React that's used in 100% of React components, so it's definitely a standard that some developers stick to.

My issue with "order for most APIs has a certain rhythm" is that if later you add a new nullable parameter where it makes sense -- so you put it first in the list -- then you have a breaking API change. You can't have a breaking API change in the same way if you always pass objects.

Last but not least, if you always use an object, then you always know what you're passing -- I know `clusterName` will be the `clusterName` instead of having to look up the parameter order with Intellisense.

Give it a shot, Andrew, and see if you really hate it.

--

--

Dr. Derek Austin šŸ„³
Dr. Derek Austin šŸ„³

Written by Dr. Derek Austin šŸ„³

Hi, I'm Doctor Derek! I've been a professional web developer since 2005, and I love writing about programming with JavaScript, TypeScript, React, Next.js & Git.

Responses (1)