-
I initialized a fresh app with VIte + Typescript. It contains the vue-shims.d.ts. It contains declare module "*.vue" {
import { defineComponent } from "vue";
const Component: ReturnType<typeof defineComponent>;
export default Component;
} Defined a new global property in the main.ts file. app.config.globalProperties.$foo = "bar" Now I want to let Typescript know this global property exists: declare module '@vue/runtime-core' {
interface ComponentCustomProperties {
$foo: string;
}
} The build now fails:
Could anyone help me with this? How do I define additional global properties without messing with the included vue-shims? |
Beta Was this translation helpful? Give feedback.
Answered by
kevcodez
Feb 22, 2021
Replies: 1 comment
-
Fixed by moving to separate file and exporting an empty object. export {}
declare module '@vue/runtime-core' {
interface ComponentCustomProperties {
$foo: string;
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
kevcodez
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Fixed by moving to separate file and exporting an empty object.
Also see https://stackoverflow.com/questions/63999118/how-to-declare-typescript-type-interface-for-custom-meta-fields-in-vue-router-v4