-
-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Defaults to TS for <script vapor>
#198
Comments
One of the vue main sell point is easy adoption. |
It's worth mentioning that TS can essentially be considered a superset of JS. Enabling TS automatically does not require users to use types mandatorily. |
Wouldn't it be a high cognitive load for users if the interface is not aligned with other modes? Some may argue that having documentation would solve the issue, but personally, I think predictability through a unified interface is important.
If you want to default to TS, shouldn't we first raise an RFC in vuejs/core rather than here, so that vapor and non-vapor can be unified? When marking Vapor Mode in the script attribute, I thought it would be better to have an interface like the following: <script setup lang="ts" vapor>
</script> Initially, there was a suggestion of using |
|
From my understanding, Vapor requires a build step to compile into runtime code. Given Vue works fantastically with TypeScript brings, I think a default of TS is sensible. |
Shouldn't non-setup scripts be supported? For example, I have seen projects that write code like the following (in fact, I often use it myself). <!-- DialogA.vue -->
<script lang="ts">
export function useDialogA() {
/* ... */
return {/* ... */}
}
</script>
<script setup lang="ts">
// some setup script
</script>
<template>
<!-- ... -->
</template> If non-setup scripts are not supported, we cannot export anything from the SFC. |
About non-setup scripts, I haven't figured this out yet, let's leave this topic for another thread. |
How about <script> // options API
<script setup> // composition API
<script setup=vapor> // vapor mode all defaults to |
There may be two ways to indicate attributes, where to focus on them? <!-- If you want to focus on the attributes of the script as "SFC settings" -->
<script setup="vapor">
</script>
<template>
</template> <!-- If you want to focus on the settings of the template (outputting a renderer that does not use virtual DOM) without affecting the setup -->
<script setup>
</script>
<template vapor>
</template> In the latter case, the script remains the same as before. |
Couldn't it be a compiler option that defaults to |
I think we should keep Vapor's behavior predictable. Replacing the <!-- Defaults to lang="js" as `setup` does -->
<script vapor>
</script> <!-- Manually opt-in to TypeScript with lang="ts" keeping the same behaviour -->
<script vapor lang="ts">
</script> |
Unless |
I will also point out that this would be the only instance (I can think of) in a sfc where an attribute other than |
I have to echo what @icarusgk said, that script should default to JS. <script lang="ts" vapor>
</script> ...is clear to me. |
If |
This is the best suggestion. It's simple and straightforward. |
We would like Vue users to use vapor as soon as possible. However, until it stabilises, we would like to be able to return to virtual DOM mode by simply removing the five letters Therefore, I would like to be able to write the following. <script setup lang="ts" vapor>
</script> For import * as acorn from 'acorn';
import { tsPlugin } from 'acorn-typescript';
const ParserWithTS = acorn.Parser.extend(tsPlugin({ allowSatisfies: true }));
const parser = typescript ? ParserWithTS : acorn.Parser; If we don't support anything other than And for edge case: |
pickup some tweets of vuejs team https://x.com/johnsoncodehk/status/1787211286008213826
https://x.com/_justineo/status/1787305010654822788
|
I really like TypeScript, and I use it in almost all of my projects. However, the inconsistency between I think enabling TS by default could be considered as a global configuration switch for a project, effective both in setup and vapor. This would avoid breaking changes while allowing projects that primarily use TypeScript to benefit from a more streamlined syntax. At the same time, I also like the |
I'd be happy to have a global config on this, and let individual component decides what they want. |
I think the default ts would break the retrospective process. It makes the most sense; <script setup vapor lang=‘ts’> |
I like this suggestion. Not ambiguous too. 👍🏾 |
I think TS should not be the default. |
My opinion aligns with @ubugeeei on this. I don't really mind making ts as default, but I think in that case, it should be so in non-vapor Vue SFC too 👀 |
TypeScript should not be the default for Vapor mode because it breaks the fundamental philosophy that Vue is an approachable framework. In other words, we build on top of standards and let people opt in to what makes sense for their team. Regardless of people's opinions on whether TypeScript is superior, it has always been one of Vue's strengths to let people choose based on their opinion alone. To enable TypeScript by default for Vapor (or non-vapor) would go against this fundamental philosophy that has made Vue the framework it is. |
Discussion: Should
lang
default tots
in Vapor SFCs?<script vapor>
This would make it behave like a non-Vapor component:
<script setup lang="ts">
Please leave a 👍 or 👎 reaction below.
The text was updated successfully, but these errors were encountered: