Comments (9)
With relative path I got this error:
error TS2307: Cannot find module './../components/MyComponent.vue'.
import:
import MyComponent from "./../components/MyComponent.vue"
from typescript-template.
Does it work by importing with a relative path instead of the alias ~components?
from typescript-template.
I tried also importing without the vue extension:
import MyComponent from "./../components/MyComponent"
error:
error TS2307: Cannot find module './../components/MyComponent'.
from typescript-template.
Thanks for taking a look @Atinux
I don't quite understand appendTSSuffixTo
:
https://github.com/TypeStrong/ts-loader#appendtssuffixto-regexp-default
Also, every example I've read through uses esModule:true
on the vue-loader
:
https://github.com/vuejs/vue-class-component/blob/master/example/webpack.config.js#L24
I just don't have that much webpack experience, so trying to override the build config
in nuxt.config.js
just turns into guessing for me.
from typescript-template.
Do you think adding typings like this:
declare module '*.vue' {
import Vue = require('vue')
const value: Vue.ComponentOptions<Vue>
export default value
}
will have any effect?
from typescript-template.
@jvbianchi no, it's not a type error...
from typescript-template.
@jvbianchi Try something for me:
add a components/Foo.vue
with the following contents:
<template>
<div>
Hi
</div>
</template>
<script lang="ts">
export default {
}
</script>
import it in index.vue
with
import Foo from "~components/Foo"
and make sure to add it to
@Component({
components: {
Foo
},
If the dev server is running, stop then yarn dev
again.
Tell me if that works...
I'm thinking I've seen the following behaviors:
- When you add a new component, you need to stop then restart the dev server
- If you
import
without actually using a component, it throws a "module not found". Do at least aconsole.log(Foo)
makes this go away. - I believe a
.vue
for TS need a minimalscript
tag that exports at least an object.
Those are bizarre behaviors IMO, but I don't have any answers...
from typescript-template.
@johnlindquist when you add:
<script lang="ts">
export default {
}
</script>
to any component it starts working.
I tested with:
import MyComponent from "./../components/MyComponent.vue"
import Foo from "~components/Foo.vue";
// and
import MyComponent from "./../components/MyComponent"
import Foo from "~components/Foo";
In both cases work as expected.
As you said:
- It works even without restarting the server.
- If you don't use the component I got the error:
error TS2307: Cannot find module './../components/Foo.vue'.
but if I console.log(Foo)
it works.
from typescript-template.
Great, thanks for the help.
from typescript-template.
Related Issues (20)
- How to include vuetify package? HOT 1
- How do i can debug it in VS Code? HOT 1
- Interface 'NuxtApp' incorrectly extends interface 'Vue'. Types of property '$loading' are incompatible. HOT 2
- GitHub issue template points to wrong CMTY app address HOT 1
- When using this inside the head() function of a component, this does not let you access computed HOT 4
- Action Required: Fix Renovate Configuration
- Dependency Dashboard
- Any plans to upgrade @nuxtjs/composition-api to 0.33.0? HOT 1
- Nuxt 3 Support HOT 2
- [Critical] - Build is failing. Missing dependency nuxt-property-decorator HOT 27
- vue-dev-tools do not work HOT 4
- Nuxt Edge - Issue when running/building the project HOT 4
- Nuxt.js fetch functionality HOT 1
- Update TypeScript HOT 1
- Update TypeScript version HOT 3
- Not compatible with nuxt 2.0.0 HOT 12
- asyncData not working HOT 1
- TypeScript template has error when installing in latest version HOT 4
- axios 编辑器一直报错 HOT 1
- Fresh Installed and got this error HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from typescript-template.