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.

vue-tsc How to generate for .vue files only and merge into one file

See original GitHub issue

Hi,

The first question, how to declare for .vue files only I could probably solve with some bash hacking (simply delete whatever is changed in git and isn’t *.vue.d.ts) but I can’t figure out how to merge all the declaration files into one. Tried to RTFM but neither --outDir nor --outFile worked for me.

Actually, checked StackOverflow and saw this

To map a .d.ts file to its javascript file you need to give the .d.ts file the same name as the javascript file, keep them in the same folder, and point the code that needs it to the .d.ts file.

So its possible that everything is working as designed. They’re basically header like files. But I’ll ask the question anyway so you can confirm and others wondering the same will be able to find it here

But it would be nice if you could process .vue files only and overwrite existing .d.ts files. Because the script I’m currently thinking of will be something along the lines of

find -name '*.vue.d.ts' | xargs rm || true
npx vue-tsc --declaration --emitDeclarationOnly
git ls-files --others --exclude-standard | grep -v vue | grep .d.ts | xargs rm || true

which is… ok 😃

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
xiaoxiangmoecommented, Mar 12, 2022

Generate it to another dir such as ./generated/src/App.vue.ts and use rootDirs to resolve it.

0reactions
DGollingscommented, Mar 31, 2022

thanks @johnsoncodehk

For anyone wondering what his tsconfig.build-dts.json snippet does, it does what my bash hack does. Delete (or better, prevents creating) unwanted files

But I added xstate and Pinia to my exports and now it complains about TS7056: The inferred type of this node exceeds the maximum length the compiler will serialize. An explicit type annotation is needed. I have a feeling I’ll have to rethink how to approach testing

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to create a Vue.js app using Single-File Components ...
It merges code from multiple files into one. Before Webpack, the user included a script tag for each JavaScript file.
Read more >
Evan You on Twitter: "- vue-tsc: check Vue files like TS from ...
vue-tsc : check Vue files like TS from the command line - vue-dts-gen: generate definitions from Vue files. Quote Tweet.
Read more >
Writing multiple Vue components in a single file
Writing multiple components in one file is a pattern from React where some files contain multiple components. Some of those components are ...
Read more >
Single-File Components - Vue.js
Vue Single -File Components (a.k.a. *.vue files, abbreviated as SFC) is a special file format that allows us to encapsulate the template, logic, ......
Read more >
Features | Vite
Vite provides first-party HMR integrations for Vue Single File Components ... --noEmit in the build script or install vue-tsc and run vue-tsc --noEmit...
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