-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Do not rename all *.js files to *.ts after running vue add @vue/typescript
- give users a choice to enable allowJs:true
mode.
#2676
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
Comments
Sure. But If you want rot "copy over" an existing project into this new one, can't you set So I may be missing something? I don't the the problems you are speaking of. |
This is not about creating a new project with |
Oh, that's indeed a good point that I haven't had thought about! |
Yes please |
Any news on this? |
Close #2676 At the moment when we run `vue add`, Vue CLI renames all `*.js` files to `*.ts`. This PR introduces two new prompts on `@vue/cli-plugin-typescript` late-invokation: 1. `convertJsToTs`: if set to `true`, renames all `.js` files to `.ts`. Otherwise renames only `main.js` -> `main.ts`; 2. `allowJs`: if set to `true`, adds `allowJs: true` to TSConfig compiler options.
Close #2676 At the moment when we run `vue add`, Vue CLI renames all `*.js` files to `*.ts`. This PR introduces two new prompts on `@vue/cli-plugin-typescript` late-invokation: 1. `convertJsToTs`: if set to `true`, renames all `.js` files to `.ts`. Otherwise renames only `main.js` -> `main.ts`; 2. `allowJs`: if set to `true`, adds `allowJs: true` to TSConfig compiler options. (cherry picked from commit 38debb4)
I assume that #4212 was merged to v4.0.0-beta.0? |
Yeah, @varna, you are not mistaken. In |
…Ts (#4346) fixes #2676 (comment) (cherry picked from commit 8b7af38)
This is extremely annoying. Even in an existing project, when I run |
@ffxsam but I think this option has already been shipped since 3.10 or 4.0.0-beta.1? |
@sodatea It doesn't seem so. I literally just upgraded my vue-cli 3.x project, and every time I ran I'm using |
|
@sodatea Yeah, if you have |
What problem does this feature solve?
This feature makes the JS -> TypeScript migration easier
What does the proposed API look like?
At the moment when we run
@vue/typescript
then vue CLI adds all required dependencies and creates all required configuration files - this is fine. But it also renames all *.js files to *.ts. IMO it doesn't help with anything. Such an automation only makes sense if we have a fresh Vue project, but if we already have an existing application, then it doesn't make the migration any easier. It's very unlikely that existing files will compile successfully. Missing types and different import syntax will cause lots of compilation failures.So I suggest that after the
vue add @vue/typescript
command is executed:allowJs: true
mode.main.js
file.allowJs: true
is the best way to migrate a JS project to TypeScript progressively. Thanks to this we can still use existing JS modules as they are, write new modules in TypeScript, and migrate existing ones one by one.It's not my personal opinion. Setting
allowJs
totrue
is recommended in the official Migration from Javascrtipt guide.The text was updated successfully, but these errors were encountered: