-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
typescript building error when import .vue file with separate .ts file #1104
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
|
@posva not exactly the same. I do have file declare module '*.vue' {
import Vue from 'vue'
export default Vue
} and it works like this
but the code below throw an error
|
Maybe @ktsn knows how to make |
This looks like |
I had the same issue some time ago, but i got it to work by removing the |
@UnnoTed |
Thank you for your answer, so I guess I have a bad config. I've a fresh new project generated by vue-cli@3, I just split a module in three files (ts, html, vue). I still have a problem during the serve/build. I tried to remove So I don't know if it's link to a vue-cli config or not, I'm sorry if it's not the good place to ask help. I've created a repo to reproduce: https://github.com/shenron/vue-cli-ts-seed
|
@shenron add // @ts-ignore
import HelloWorld from '@/components/HelloWorld/HelloWorld.vue'; |
Yes ! it works thank you very much. |
indeed had a sort-a-like issue, now it works :-D thanks |
A Workaround is described here: TypeStrong/fork-ts-checker-webpack-plugin#111 (comment) @ktsn since your issue has been open for more than 2 months now and a solution doesn't seem in sight - should we consider removing this plugin from vue-cli until the issue has been fixed? What's the advantage of using fork-ts-checker? It's more performant to run the typechecks in a separate process, is that all to it? |
@LinusBorg I'd agree with your idea, vue-cli should disable the plugin currently. |
@LinusBorg Yes, the advantage is only for performance. I agree with disabling The PR is already made in |
seems that hot module replacement becomes abnormal after using the workaround provided by @LinusBorg |
What does "abnormal" mean, exactly? Can you provide a repository with a minimum reproduction? |
I mean component will lose its state after patch Click button will increase count, but if adding some static text then count will be reset to 0 and this should not happen. |
Thanks, we will have a look. @ktsn we should check this bout before we decide to deactivate the ts-checker plugin |
I ended up to make a PR to fork-ts-checker-webpack-plugin TypeStrong/fork-ts-checker-webpack-plugin#130 |
@ktsn's PR has been merged, pending release in TypeStrong/fork-ts-checker-webpack-plugin#132 |
We're currently waiting on @piotr-oles to generate a new token so we can release. (A result of the eslint token problem the other week.) In the meantime I could publish this to our unofficial fork-ts-checker-webpack-plugin@next channel: https://github.com/TypeStrong/fork-ts-checker-webpack-plugin Let me know if that would help and I'll make it happen. |
@yyx990803 @troy351 In my case , when I try to import some {
"include": [
"src/**/*.ts",
"src/**/*.vue",
"test/**/*.ts"
],
"exclude": [
"node_modules"
],
"files": [
"ts-custom.d.ts"
],
"types": [
"jest"
],
"compilerOptions": {
"outDir": "./dist/",
"target": "es5",
"module": "esnext",
"moduleResolution": "node",
"esModuleInterop": true,
"strict": true,
"noImplicitReturns": true,
"allowJs": false,
"sourceMap": true,
"pretty": true,
"removeComments": true
}
} and finally, vs code feel so happy. :laugh: |
declare module '*.vue' {
import Vue from 'vue'
export default Vue
} It's not working. |
This should not happened since the bug was already fixed in the latest version.
…------------------ Original ------------------
From: Artem <[email protected]>
Date: Fri,May 3,2019 8:20 PM
To: vuejs/vue-cli <[email protected]>
Cc: troy351 <[email protected]>, Mention <[email protected]>
Subject: Re: [vuejs/vue-cli] typescript building error when import .vue file with separate .ts file (#1104)
@troy351
declare module '*.vue' { import Vue from 'vue' export default Vue }
It's not working.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
@troy351 Um... all versions are latest. |
@FlamesoFF Could you create a new empty project with the lateset vue-cli and check if that works? |
@troy351 I don't use vue-cli, because I want to have full control over my project (webpack configurations and other stuff). |
That makes things complicated. I suggest you to use vue-cli to create an empty project with all you needed plugins then use More about the command https://cli.vuejs.org/guide/webpack.html#inspecting-the-project-s-webpack-config FYI. |
Version
3.0.0-beta.6
Reproduction link
https://github.com/troy351/vue-cli-demo
Steps to reproduce
clone the repo, run
What is expected?
run success
What is actually happening?
error
File '/src/components/HelloWorld.vue' is not a module.
in
App.vue
use inline script (not put script into a separate file) works fine
The text was updated successfully, but these errors were encountered: