Skip to content

Instantly share code, notes, and snippets.

@soulsam480
Created November 8, 2020 13:45
Show Gist options
  • Save soulsam480/2c769cd156462f8add5c23d145566f85 to your computer and use it in GitHub Desktop.
Save soulsam480/2c769cd156462f8add5c23d145566f85 to your computer and use it in GitHub Desktop.
Declaring custom instance properties in Vue 3 and typescript
//declare the property so that it can be used by ts
declare module '@vue/runtime-core' {
    interface ComponentCustomProperties {
        $socket: SocketIOClient.Socket;
    }
}

const app = createApp(App)
//mount app with the vue 3 global properties  api
app.config.globalProperties.$socket = socket;
app.mount('#app')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment