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.

Typescript support

See original GitHub issue
  Try `npm install @types/vue-confetti` if it exists or add a new declaration (.d.ts) file containing `declare module 'vue-confetti';`
    1 | import Vue from 'vue'
  > 2 | import VueConfetti from 'vue-confetti'
      |                         ^
    3 | 
    4 | Vue.use(VueConfetti)
    5 | 

ℹ Version: typescript 3.8.3  

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:1
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
mikesimpscommented, Jul 10, 2020

I got this working with Nuxtjs and Typescript

plugins/vue-confetti.client.ts

import Vue from 'vue'
import { Plugin } from '@nuxt/types'
import VueConfetti from 'vue-confetti'

declare module 'vue/types/vue' {
    interface Vue {
        $confetti: VueConfetti
    }
}

const VueConfettiPlugin: Plugin = () => {
    Vue.use(VueConfetti as any)
}

export default VueConfettiPlugin

types/vue-confetti.d.ts

declare module 'vue-confetti' {
    interface ParticleOptions {
        type?: string
        size?: number
        dropRate?: number
        colors?: Array<string>
    }

    interface ConfettiOptions {
        particles?: Array<ParticleOptions>
        defaultType?: string
        defaultSize?: number
        defaultDropRate?: number
        defaultColors?: Array<string>
        canvasId?: string
        particlesPerFrame?: number
    }

    export default class VueConfetti {
        install(Vue: Vue, options: ConfettiOptions): void
        start(opts?: ConfettiOptions): void
        stop(): void
    }
}

nuxt.config.js

plugins: [
        { src: '~/plugins/vue-confetti.client.ts' }
]

Now I can use $confetti in any part of my Vue components

mounted() {
    this.$confetti.start()
}
1reaction
Vidhya-Dilipcommented, Nov 12, 2021

@mikesimps your solution worked. 💥 But only on pages, not components. So I emitted on click, from component to page and called this.$confetti.start().

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeScript: JavaScript With Syntax For Types.
TypeScript extends JavaScript by adding types to the language. TypeScript speeds up your development experience by catching errors and providing fixes ...
Read more >
TypeScript - Wikipedia
TypeScript supports definition files that can contain type information of existing JavaScript libraries, much like C++ header files can describe the ...
Read more >
TypeScript Programming with Visual Studio Code
Visual Studio Code includes TypeScript language support but does not include the TypeScript compiler, tsc . You will need to install the TypeScript...
Read more >
TypeScript | WebStorm Documentation - JetBrains
WebStorm supports developing, running, and debugging TypeScript source code. ... Learn more from Compiling TypeScript into JavaScript.
Read more >
TypeScript Introduction - W3Schools
TypeScript is JavaScript with added syntax for types. ... as Visual Studio Code, have built-in TypeScript support and can show errors as you...
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