Using ts-nameof with Vue
See original GitHub issueI’ve tried to install the npm package using both npm install ts-nameof @types/ts-nameof --save-dev
and npm install @types/ts-nameof --save-dev
, and included a reference to ts-nameof in my tsconfig.json like this:
{
"compilerOptions": {
"types": [
"ts-nameof"
],
"typeRoots": [
"./node_modules/@types/",
],
}
}
But without much luck. Do you have any suggestions as how to continue?
Issue Analytics
- State:
- Created 4 years ago
- Comments:11 (1 by maintainers)
Top Results From Across the Web
Vite-ts-nameof NPM | npm.io
Inject vite-ts-nameof using the vite.config.ts module import vue from "@vitejs/plugin-vue"; import { defineConfig } from "vite"; import tsNameof from ...
Read more >What is the tag name of class based vue component
You can still register components like usual as if you weren't using Typescript: // MyComponent.ts import Vue from 'vue' import Component ...
Read more >TS-nameof: Nameof in TypeScript - Morioh
ts -nameof is a compile time transform so it requires some setup. For setup instructions, see the packages above for the compiler you...
Read more >vite-plugin-ts-nameof - npm Package Health Analysis | Snyk
Ensure you're using the healthiest npm packages. Snyk scans all the packages in your projects for vulnerabilities and provides automated fix advice.
Read more >Component Registration - Vue.js
A Vue component needs to be "registered" so that Vue knows where to locate its implementation when it is encountered in a template....
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
I had the same problem. Almost got it to work (
vue-cli-service build
sometimes worked, and sometimes it threwnameof
errors).This comment actually guided me to the answer, so thanks @Shinigami92 😄
If someone is still trying to make this work, this is how I accomplished this.
In
tsconfig.json
add:so this declaration file would be visible globally.
My
vue.config.js
was looking like this:I added the
ts-nameof-loader
(npm package has the same name) by the way, it helped actually replacingnameof
calls with strings.However it seems, that at this moment
eslint-loader
was “fighting” withts-loader
in parallel, creating a race condition, which caused the build to sometimes work, and sometimes not. So, by inspecting the webpack config usingvue inspect
, I moved theeslint-loader
explicitly to run afterts-nameof-loader
:And there we have it!
Moving ts scripts outside of .vue is not an option for me. The entire component must be in on single file otherwise it makes development nightmare. Sorry I am not an angular guy 😃