nuxt-community / fontawesome-module

Module to use Font Awesome icons in Nuxt.js
MIT License
110 stars 12 forks source link

feat: implemented Typescript definitions #28

Open gekkedev opened 3 years ago

gekkedev commented 3 years ago

aligns with the readme file, but left out deprecated property imports
fixes #27
not sure how to map the fontawesome key directly - could we somehow create an interface that automatically extends the nuxt configuration by this property?

pimlie commented 3 years ago

@gekkedev Have a look at how the i18n module adds a config key to the nuxt options: https://github.com/nuxt-community/i18n-module/blob/master/types/vue.d.ts#L44

And thanks for working on this btw!

gekkedev commented 3 years ago

@pimlie I've tried to this to the type definitions:

declare module '@nuxt/types' {
    interface NuxtOptions {
        fontawesome?: NuxtFontawesomeOptions
    }
}

Unfortunately it doesn't get recognized. What did I forget?

gekkedev commented 3 years ago

Forgot the entry in tsconfig.json as the other library suggests as well but unfortunately that did not help. It might be that I have too many chaotic imports or that my IDE is not refreshing the imports often enough (or something is wrong with all the declaration merging coming from different libraries). Any idea what to change here?

pimlie commented 3 years ago

@gekkedev I think the issue might be a missing types entry in pkg.json in the stable package? Maybe your editor doesnt pick that up correctly for your local dev. I assume you yarn linked nuxt-fontawesome into your nuxt project?.

gekkedev commented 3 years ago

I adjusted the module declaration because previously I had no idea about declaration merging (and am still unsure if this is entirely correct). The types entry is there if this is what you mean. Also added "@nuxtjs/fontawesome" into types in my local tsconfig.json; exactly as seen with another Nuxt package. Is there something I might have forgotten or just a technical (IDE) issue on my side?

gekkedev commented 2 years ago

I added an enclosing config key that I forgot and it works for me - however the type definitions only get applied when the file is open in VSCode, not when the file is closed. I restarted TSServer & Vetur - maybe you know what has to be done @pimlie ?