[@vue/cli-plugin-typescript] Is there any way to make type checks work in .ts files in editor?
See original GitHub issueWhat problem does this feature solve?
I find in vscode (with vetur), props check works in .vue
file when editing.
However it doesn’t work in .ts
file.
Is there any way to make type checks work in .ts files?
What does the proposed API look like?
Nil
Vue Info
➜ vue3-ts-2 git:(master) ✗ vue info
Environment Info:
System:
OS: macOS 11.1
CPU: (8) x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
Binaries:
Node: 12.16.1 - ~/.nvm/versions/node/v12.16.1/bin/node
Yarn: 1.22.10 - /usr/local/bin/yarn
npm: 6.14.9 - ~/.nvm/versions/node/v12.16.1/bin/npm
Browsers:
Chrome: 87.0.4280.88
Edge: 87.0.664.66
Firefox: 84.0
Safari: 14.0.2
npmPackages:
@vue/cli-overlay: 5.0.0-alpha.0
@vue/cli-plugin-e2e-cypress: ~5.0.0-alpha.0 => 5.0.0-alpha.0
@vue/cli-plugin-eslint: ~5.0.0-alpha.0 => 5.0.0-alpha.0
@vue/cli-plugin-router: 5.0.0-alpha.0
@vue/cli-plugin-typescript: ~5.0.0-alpha.0 => 5.0.0-alpha.0
@vue/cli-plugin-unit-jest: ~5.0.0-alpha.0 => 5.0.0-alpha.0
@vue/cli-plugin-vuex: 5.0.0-alpha.0
@vue/cli-service: ~5.0.0-alpha.0 => 5.0.0-alpha.0
@vue/cli-shared-utils: 5.0.0-alpha.0
@vue/compiler-core: 3.0.4
@vue/compiler-dom: 3.0.4
@vue/compiler-sfc: ^3.0.4 => 3.0.4
@vue/compiler-ssr: 3.0.4
@vue/component-compiler-utils: 3.2.0
@vue/eslint-config-standard: ^6.0.0 => 6.0.0
@vue/eslint-config-typescript: ^7.0.0 => 7.0.0
@vue/preload-webpack-plugin: 1.1.2
@vue/reactivity: 3.0.4
@vue/runtime-core: 3.0.4
@vue/runtime-dom: 3.0.4
@vue/shared: 3.0.4
@vue/test-utils: ^2.0.0-0 => 2.0.0-beta.13
@vue/web-component-wrapper: 1.2.0
eslint-plugin-vue: ^7.2.0 => 7.4.0
jest-serializer-vue: 2.0.2
typescript: ~4.1.2 => 4.1.3
vue: ^3.0.4 => 3.0.4
vue-eslint-parser: 7.3.0
vue-hot-reload-api: 2.3.4
vue-jest: ^5.0.0-0 => 5.0.0-alpha.7 (3.0.7)
vue-loader: 16.1.2 (15.9.6)
vue-style-loader: 4.1.2
vue-template-es2015-compiler: 1.9.1
npmGlobalPackages:
@vue/cli: 5.0.0-alpha.0
Issue Analytics
- State:
- Created 3 years ago
- Comments:11
Top Results From Across the Web
Documentation - Type Checking JavaScript Files - TypeScript
Here are some notable differences on how checking works in .js files compared to .ts files. Properties are inferred from assignments in class...
Read more >vue/cli-plugin-typescript
typescript plugin for vue-cli. Uses TypeScript + ts-loader + fork-ts-checker-webpack-plugin for faster off-thread type checking.
Read more >@vue/cli-plugin-typescript | Yarn - Package Manager
@vue/cli-plugin-typescript. typescript plugin for vue-cli. Uses TypeScript + ts-loader + fork-ts-checker-webpack-plugin for faster off-thread type checking.
Read more >Error: 'types' can only be used in a .ts file - Visual Studio Code ...
What is the correct setup in order to use .js files with TypeScript and get Intellisense so I know what the errors in...
Read more >Typescript | Crossref Knowledge Base - GitLab
Type checking occurs within the IDE (if configured) and at compile time. ... Convert all .js files to .ts? No ? Allow .js...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
There is vuedx extension in vscode store, which can be used with vetur together (not recommended, I find it seems to slow down my vscode, not quite sure).
Before Vue3 DX reach a usable level, I think we still need to wait for some tool chains to reach stable state.
For type checking like
tsc --noEmit
, we need@vuedx/typecheck
.For type checking in IDE like
tsx
, we needvetur
to support both.ts|js|vue
in vscode. (After thatshims-vue.d.ts
is not required)For packing a
.ts + .vue
library in its file original structure, currently there is no integrated solution. (For.ts + tsx
it is quite easy. just runtsc
)For people who want to use typescript
tsc
to build their library, I buildv2s
(vue to script) to help convert.vue
file to.ts
file and refactor all the related imports/exports.It does the conversion in place.
Firstly copy
src
tocopied-src
Run
npx v2s -dr copied-src/**/*
(-dr
means delete source & refactor imports/exports)Then you can use
tsc
to compile your library.