question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Calling instance method from getter in VueSingleFileComponent causes error: Cannot find module

See original GitHub issue

I’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:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
kimamulacommented, Dec 2, 2020

@Buntelrus Thanks for reporting. Fixed in v0.4.3.

0reactions
kimamulacommented, Dec 3, 2020

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 specifying onlyCompileBundledFiles: false does not help.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found