And then otherwise, the structure is still there for us. Another nice thing about this approach as well as you can progressively enhance code. So in other words, especially if you're coming from a code base that has been around for a while, already using options, for example, there is a way for you to progressively enhance your code there is a way for you to progressively add composition API features without having to refactor everything and rewrite all of your code, which again, to me, is one of views biggest selling points as far as it's flexibility to allow to accommodate different situations.
In addition, because now you have the ability to basically fuse the composition API stuff with the options API, you have more typescript friendliness than you would if you had done pure options API. So just something to consider. When it comes to cons, though, as you might expect, because you're using two approaches, this does mean that you kind of have to have a better understanding of basically both methodologies. And this is just a con from a sense of there's a little bit more of a learning curve, because that means that people who were very comfortable with options API now also have to know composition API, and then vice versa, those who knew composition API will also then want need to know options API. But again, one of the interesting things that I would say when it comes to that is a lot of people when using Vue are already familiar with options usually right out of the gate. And more importantly, the principles that I think drive the API behind both composition and options as far as like lifecycle hooks, computer properties, reactive data, they're for the most part very, very similar. So you know, hopefully the while there are two different approaches, there are similarities and hopefully the learning curve is not too bad.
That said, though, right, as we saw earlier with the script setup, it can be quite concise. But now that you have both, it can be a little bit verbose, sometimes because you're having to manually define your returns. And while there might be a pink, like basically tooling to help with that in the future, like, this is technically a con when it comes to sort of comparing like the ability to go pure composition API versus options. And so, you know how I said it was more TS friendly, well, then, again, similarly, compared to the composition API is not as TypeScript friendly in the sense that you can use some really clean syntax with the pure composition API but with object or options API, on the other hand, then you have to do a little bit more of that finessing of making sure that you type things correctly according to the context. And so this is one of those things where it's just, it's, well, this is not a perfect solution when it comes to that. And so again, it's a hybrid approach. This is to be expected. So which approach is the right approach? Well, I think one of the challenging things when it comes to engineering is a lot of time as developers were kind of obsessed with like being like the most correct or finding ways to prove that this will always be right. But rather than think of right in terms of correctness or some sort of objective superiority, I think it's more important to flip the context of right instead as to focus on the fact that what really matters is choosing the right approach for your team. In other words, more about fit and rather than some sort of objective grading skill that we're talking about. And so here are some aspects to consider when making the choice between the various approaches. The first of which is the code base that you're working from, right? Because if you're migrating from an existing one that has view two and you already are using options API and you're migrating it into view three, for example. Again, we know that migrations can be expensive and they want to still turn out new features. So I would say in that case, because the team's already familiar with options API, in my personal opinion, it makes the most sense to progressively enhance your components with composition API. And then even if your team is thinking about doing more composition API, this does prevent the need to like make your entire code base pure composition API from the get-go, which can definitely slow down development, especially when it comes to releasing new features and such.
On the other hand, though, if we're talking about new project, this is where I think the nuances come in a little bit more differently. I think this is something I think is often overlooked, but really important to consider is who is really contributing to the code base, right? What is the makeup of the team? If you have a lot of people who aren't as familiar with JavaScript and you have maybe one or two people that are writing the code base primarily, with them coming in to help with little bits and pieces, options API serving as the primary methodology might actually be a really good use case for this for a majority of components, because believe it or not, when we think about a lot of components, it's easy to always want to think they'll scale infinitely, but because Vue gives you the flexibility to choose between various methodologies, depending on which, there's no reason to say that you can't start with options and then, as it basically grows in complexity, you can enhance it with composition API or eventually switch it as it sees fit. And so as a result, when you're considering your team, this can be really, really important, because, for example, if you have a team that's really, really familiar with JavaScript, and they want the flexibility of making their own architectural decision, then yeah, composition API all the way could make a lot of sense. But again, this is why it's really matters about your team makeup and how basically that contributes to the maintenance and iteration of your code base.
And a third one, which is actually pretty a big factor, is are you planning are you or does the team plan on using TypeScript very, very heavily, right? And I think there's a difference between using TypeScript lightly to annotate some types occasionally to like some heavier TypeScript users who want to do a lot more complex things with TypeScript.
Comments