generated JS uses type as value
See original GitHub issueI opened https://github.com/vuejs/vue-cli/issues/1498 on vue-cli
, but was redirected here.
Reproduction repo: https://github.com/doppelreim/vue-test-app/tree/test-import-route
Steps to reproduce:
Run ./node_modules/.bin/vue-cli-service serve
Expected: The app should compile without warnings.
Actual: There are warnings:
WARNING Compiled with 4 warnings 09:41:30
warning in ./src/components/HelloWorld.vue?vue&type=script&lang=ts
"export 'Route' was not found in 'vue-router'
warning in ./src/components/HelloWorld.vue?vue&type=script&lang=ts
"export 'Route' was not found in 'vue-router'
warning in ./src/components/HelloWorld.vue?vue&type=script&lang=ts
"export 'Route' was not found in 'vue-router'
warning in ./src/components/HelloWorld.vue?vue&type=script&lang=ts
"export 'Route' was not found in 'vue-router'
The change that introduces the warnigns can be seen here: https://github.com/doppelreim/vue-test-app/commit/af036724ecbe53853ce10707796c82213ae07a43
I want to add a Watcher on $route
. The parameters of the function (newRoute
and oldRoute
) should be typed. I assume Route
is the correct type.
I checked out /node_modules/vue-router/types/index.d.ts
and there Route
does get exported, as far as I can tell.
If I use Route
inside of the function-body, like this:
const r: Route = {
path: '',
hash: '',
query: {},
params: {},
fullPath: '',
matched: [],
};
then it does not throw errors. And if I leave out some of the required attributes, then the compiler rightfully complains. So I assume the export/import does work here.
@yyx990803 provided a technical explanation in https://github.com/vuejs/vue-cli/issues/1498#issuecomment-395461425 - but there is nothing vue-cli
can do about it.
Not sure, where to address this. Maybe here?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:14 (4 by maintainers)
Top GitHub Comments
Looks like it, see https://github.com/vuejs/vue-cli/blob/05391b6e9e51917437d79c46721548dc7038993a/packages/%40vue/cli-plugin-typescript/generator/template/tsconfig.json#L9
I will open an issue with
vue-cli
to remove the line from the template.Disabling
emitDecoratorMetadata
works. Nice!It was initially enabled when I created the app with
vue-cli
. Do you know whether they do it only because ofvue-property-decorator
?