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.

`Cannot find name defineProps` ts error

See original GitHub issue

In a vue2 + vite + unplugin-vue2-script-setup project i have a ts error (not eslint) on build that Cannot find name defineProps/defineEmits

Here’s project’s tsconfig https://github.com/jacekkarczmarczyk/rachunek/blob/master/tsconfig.json and example usage of defineProps https://github.com/jacekkarczmarczyk/rachunek/blob/master/src/components/BillForm/BillForm.vue#L163 (that’s not a minimal repro, but I guess just the settings files are imporant, if you want a minimal repro though let me know)

To reproduce the issue run yarn build

screenshot

Error can be supressed with // @ts-ignore but that doesn’t sound like a valid solution. Another option is to add .d.ts files with defineProps declaration but I think that should be rather provided by the lib (or maybe it is but can’t find anything)

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
jacekkarczmarczykcommented, Jan 20, 2022

hm what is https://github.com/johnsoncodehk/volar then? nvm, I see now still i think that putting information about dependency in the IDE section is misleading, writing about Vetur, Volar and VS Code in one sentence may make people think that it’s about using Volar extension in VS Code

0reactions
andygeekcommented, Jun 12, 2022

It happens to me because I didn’t give it npm install, but then you have to disabled Vetur if you have it installed

Read more comments on GitHub >

github_iconTop Results From Across the Web

Problems with Vue 3.2 <script setup> tag and TypeScript ...
This works, but I get an error on the User type that says: 'User' only refers to a type, but is being used...
Read more >
Vue3: withDefaults(defineProps<T>(),{}) does not work ...
Vue3: withDefaults(defineProps<T>(),{}) does not work when working with a Typescript ... Create a Vue 3 Component with <script setup lang="ts"> Syntax.
Read more >
script setup
The options passed to defineProps and defineEmits will be hoisted out of setup into module scope. Therefore, the options cannot reference local variables ......
Read more >
FAQ | Vetur - GitHub Pages
If it says cannot find module <some-module> , go to Vetur's client code ... a lot of Property 'xxx' does not exist on...
Read more >
cannot find name 'beforeeach'.ts(2304)
Im getting Cannot find name 'global'.ts(2304) typescript error in App.tsx at ... find name 'text'.ts(2304) </template> <script setup> import { defineProps } ...
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