-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
RFC: TypeScript plugin #718
Comments
Looks great, but wasn't able to run due to the same problem as in this thread #717. Minor note for the code: |
Awesome work, I'll take a look tomorrow. Been waiting for this! |
I gotta say this is the first time I use Vue with TS (been using TS with Angular for a while). I read this guide and the official TS guide so most of what I'm about to say might be just my lack of experience. I set up the project and everything is working. I still need to fully understand the way this plugin system is gonna work. It wasn't complicated to set up everything but I would have expected a tslint/tsconfig file out of the box and the addition of Regarding TS itself, I understand Vue converts properties inside the data object into getters/setters so this might be kind of complicated to acomplish without modifying internal things but I would expect something like this to throw:
I mean, I'm typing BTW, as I always say, awesome work. |
@zeratulmdq |
Use |
I just tested generating a TypeScript project and a default project. This is a really good base and seems really simpler to bring a custom feature into vue-cli. Main difference from stable version is that no webpack configuration file is generated. I see two drawbacks for this choice :
For example, IntellijIDEA can parse webpack configuration like webpack aliases. So in IntelliJ IDEA with default template (no typescript), when I write
|
@Toilal you can access the webpack config as a file via We will have a a ton of examples and recipes teaching users how to tweak the webpack config for common use cases. |
@yyx990803 Will writing plugins that use Other than that, PWA + TS seems a pretty solid setup for me. Will use it for a toy project to see how it goes and give more feedback. |
Update: we have started making alpha releases! You can now directly test the new CLI by following the guide in README. |
Can you add tslint-config-standard as an option when enabling TSLint? |
Hi,
If I run
|
Hi, i just try with v3.0.0-alpha.6, it's ok now ! :) |
@DanielRosenwasser I think we are more or less stable now, would love to get your feedback on this before we move to beta :) |
I just gave a try to the new generator (alpha 7) with all options checked (including TypeScript). It runs smoothly and is zero-conf for opening the generated project in IntelliJ. Class component option could be available without TypeScript too. When disabling TypeScript, I have to configure the webpack configuration file in IntelliJ ( Maybe the mutated webpack configuration could be written to a file so the effective final configuration can be loaded by tools/editors ? Thanks for the awesome work 👍 |
@Toilal that webpack file exports the dynamically resolved config that includes your custom config as well ;) |
Looks awesome! Would it be possible to have a choice between TSLint and ESLint, even when in TypeScript mode? I much much prefer working with ESLint even on my TypeScript Vue projects (better VSCode support, eslint-plugin-vue doesn't have a TS equivalent, etc.). Tried it both ways and I've found life to just be a lot easier with ESLint at the moment. It's a relatively straightforward integration - it means instead of adding tslint and tslint.json, keeping eslint as normal and adding the typescript-eslint-parser and eslint-plugin-typescript npm deps, then taking eslintOptions.js from cli-plugin-eslint and changing a few options: extensions: ['.js', '.ts', '.vue'],
parserOptions: {
parser: require.resolve('typescript-eslint-parser'),
sourceType: 'module',
},
plugins: ['typescript'], Also adding the ts extension to the webpack eslint-loader test in cli-plugin-eslint, and tweaking a few enabled eslint rules, but all else should be essentially untouched. |
@dkulchenko cool, I actually didn't know you can use ESLint with TypeScript before. I think that's indeed a better setup than TSLint. Will investigate in the next release. |
@yyx990803 @dkulchenko would you consider using a completely different linter instead? TSLint currently doesn't support .vue files. It's unlikely that this feature will be added anytime soon as it requires a major rewrite. In addition the project seems to be abandoned by its owners. That's why I'm no longer working on it. IIRC ESLint with I'm currently working on a replacement for TSLint that can be fully customized: https://github.com/fimbullinter/wotan |
@yyx990803 I will try to stress test it soon! I think one thing that would be super high-value would be a lint rule to warn Vue+TypeScript users about computed properties, where all methods and get/set accessors need to have explicit type annotations to avoid inference problems with TypeScript (vuejs/vue#7394). Whatever linter we end up choosing, we should factor that into the starter. |
@DanielRosenwasser it's possible to use either ESLint (via |
Cool. In fact, the combination of Currently, I'm busy on acorn and eslint to support ES2018, but I will work on it after done. |
@mysticatea @dkulchenko @yyx990803 Does the ESLint plugin support rules that use the type checker? |
@prograhammer AFAIK, no. With the current setup, type checking is performed by |
Ah, ok. Now I'm wondering why you wouldn't enable tslint in |
@yyx990803 |
@prograhammer actually, when using |
Hey @yyx990803, since you already have support for TSLint, is there a specific place we should place the rule? I know that the respective ESLint rule should probably go in https://github.com/vuejs/eslint-plugin-vue |
@DanielRosenwasser currently TSLint is handled inside the TypeScript plugin itself and we are just using |
@yyx990803 @DanielRosenwasser |
Could you please add typescript support to "vue serve MyComponent.vue" maybe with a parameter "vue serve -ts MyComponent.vue" |
I also love |
I've just tried the typescript template and everything works perfect so far, except for one thing... How do I use typescript in the service worker file? I use this setting in the vue.config.js file to include the worker: module.exports = { I would like to replace the sw.js file with a sw.ts file, but Workbox doesn't seem to allow that. I have a lot of code inside the service worker that needs to be written in typescript... If this is the wrong forum for this question, please redirect me :-) |
The TypeScript plugin now has a preliminary implementation here with:
ts-loader
fork-ts-checker-webpack-plugin
tslint
TODOs
npm run lint
script work with*.vue
filesTrying it Out
npm install -g @vue/cli vue create ts-project # select manual mode, pick TypeScript
For background on how plugins work in the new
vue-cli
, see hereFeedback welcome!
/cc @DanielRosenwasser @ktsn @HerringtonDarkholme @octref @kaorun343 @igogrek @prograhammer @Toilal
The text was updated successfully, but these errors were encountered: