Calling instance method from getter in VueSingleFileComponent causes error: Cannot find module
See original GitHub issueI’ve a vue 3 project with typescript and I’m trying to get ts-transformer-keys work.
My configuration:
tsconfig.json:
"plugins": [
{ "transform": "ts-transformer-keys/transformer" }
]
vue.config.js
chainWebpack: config => {
['ts', 'tsx'].forEach(rule => {
config.module
.rule(rule)
.use('ts-loader')
.tap(options => Object.assign(options, {
compiler: 'ttypescript',
transpileOnly: false
}))
})
}
I could locate the issue in the following problem: If I call an instance method from a getter I got an error
Error: Cannot find module ‘C:\path\src\App.vue.ts’
Without ts-transformer-keys
this works fine.
For Example: App.vue:
<template>
<p>{{ message }}</p>
<p>{{ messageAlias }}</p>
<p>{{ upperCaseMessage }}</p>
<p>{{ messageToUpperCase }}</p>
</template>
<script lang="ts">
import { Vue } from 'vue-class-component'
export default class App extends Vue {
message = 'hello World'
get messageAlias() {
return this.message
}
get upperCaseMessage() {
// return this.message.toUpperCase() // this will work
return this.messageToUpperCase() // this won't
}
messageToUpperCase() {
return this.message.toUpperCase()
}
}
</script>
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
How can I access setter and getter methods from an instance ...
Your login_method= instance method needs a receiver. If this is not important for you and you can make it private this should do...
Read more >Best Practices for Java Getter and Setter - DZone
In this post, we take a closer look at getter and setter methods in Java, common mistakes, and best practices for combating these...
Read more >self, instance methods and class methods in Ruby - Medium
The following article looks at addressing self, instance methods and class methods in the context of class inheritance, module mix-ins and ...
Read more >Rules for getter and setter - Haxe - The Cross-platform Toolkit
If this is not the case, access to the field from within an accessor method causes a compilation error: class Main { //...
Read more >Vue.js 3 and typescript : Property '$store' does not exist on ...
Vuex doesn't provide typings for this.$store property out of the box. When used with TypeScript, you must declare your own module augmentation. Reference....
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
@Buntelrus Thanks for reporting. Fixed in v0.4.3.
When I tried
yarn build --mode development
, it worked fine. I guess some build setting that is specific to production is preventing the transformer from working properly.A similar problem was found before. But this time
onlyCompileBundledFiles
does not seem to be the cause of the problem as specifyingonlyCompileBundledFiles: false
does not help.