From 0f71133fefd734a1ac83b4bdf68fc610f0762c86 Mon Sep 17 00:00:00 2001 From: gekkedev <17025257+gekkedev@users.noreply.github.com> Date: Fri, 22 Jan 2021 13:36:43 +0100 Subject: [PATCH 1/4] added type definitions aligns with the readme file, but left out deprecated property `imports` --- types/index.d.ts | 50 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 types/index.d.ts diff --git a/types/index.d.ts b/types/index.d.ts new file mode 100644 index 0000000..2d7906e --- /dev/null +++ b/types/index.d.ts @@ -0,0 +1,50 @@ +declare module "@nuxtjs/fontawesome" { + interface NuxtFontawesomeOptions { + /** + * Default: `"FontAwesomeIcon"` + * Change component name. Eg set to fa to use . + * Also see [suffix](https://github.com/nuxt-community/fontawesome-module#suffix) + * It's strongly recommended to use [PascalCase](https://vuejs.org/v2/style-guide/#Component-name-casing-in-templates-strongly-recommended) for component names + */ + component?: string + /** + * Default: `true` + * Boolean to indicate if the layers component should be registered globally. + * Name of the component will be `${options.component}-layers, fe ` + */ + userLayers?: boolean + /** + * Default: `true` + * Boolean to indicate if the layers component should be registered globally. Name of the component will be the `${options.component}-layers-text, fe ` + */ + useLayersText?: boolean + /** + * Which icons you will use. Set tue `true` to import everything. + * FontAwesome [currently](https://fontawesome.com/how-to-use/on-the-web/referencing-icons/basic-use) supports 5 icon styles of which 3 are freely available (partially). + */ + icons: Icons + /** + * See `icons` for how to use, but always uses pro imports. + */ + proIcons: Icons + /** + * Default: `true` + * If the module should automatically add the fontawesome styles to the global css config. It works by unshifting @fortawesome/fontawesome-svg-core/styles.css onto the nuxt.options.css property. + */ + addCss?: boolean + /** + * Default: `false` + * Boolean whether to append -icon to the icon component name. + * This option exists as the component name option is also used for the layer components and you might not want to add `-icon` to those + */ + suffix?: boolean + } + + interface Icons { + solid?: string[] | true, + regular?: string[] | true, + light?: string[] | true, + duotone?: string[] | true, + brands?: string[] | true + } +} From faab6648bc3eb7685373b5e3517646d58455551d Mon Sep 17 00:00:00 2001 From: gekkedev <17025257+gekkedev@users.noreply.github.com> Date: Fri, 22 Jan 2021 13:40:06 +0100 Subject: [PATCH 2/4] linked typedef file --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 2c3e8f3..a2e30ed 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "repository": "nuxt-community/fontawesome-module", "license": "MIT", "main": "lib/module.js", + "types": "types/index.d.ts", "contributors": [ "vaso2 " ], From 432bbc2ce0deb358ff946debb4629c20defdfd73 Mon Sep 17 00:00:00 2001 From: gekkedev <17025257+gekkedev@users.noreply.github.com> Date: Tue, 24 Aug 2021 12:15:58 +0200 Subject: [PATCH 3/4] integrated fontawesome typing into nuxt types (via declaration merging, still not working on my machine) --- types/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/index.d.ts b/types/index.d.ts index 2d7906e..001b280 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -1,5 +1,5 @@ -declare module "@nuxtjs/fontawesome" { - interface NuxtFontawesomeOptions { +declare module '@nuxt/types' { + interface NuxtConfig { /** * Default: `"FontAwesomeIcon"` * Change component name. Eg set to fa to use . From 1d2d56bdc80094d60213ef4d3322a72e1f42d483 Mon Sep 17 00:00:00 2001 From: gekkedev <17025257+gekkedev@users.noreply.github.com> Date: Fri, 17 Dec 2021 12:41:29 +0100 Subject: [PATCH 4/4] added missing config wrapper key --- types/index.d.ts | 101 +++++++++++++++++++++++++---------------------- 1 file changed, 54 insertions(+), 47 deletions(-) diff --git a/types/index.d.ts b/types/index.d.ts index 001b280..88fd220 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -1,50 +1,57 @@ -declare module '@nuxt/types' { - interface NuxtConfig { - /** - * Default: `"FontAwesomeIcon"` - * Change component name. Eg set to fa to use . - * Also see [suffix](https://github.com/nuxt-community/fontawesome-module#suffix) - * It's strongly recommended to use [PascalCase](https://vuejs.org/v2/style-guide/#Component-name-casing-in-templates-strongly-recommended) for component names - */ - component?: string - /** - * Default: `true` - * Boolean to indicate if the layers component should be registered globally. - * Name of the component will be `${options.component}-layers, fe ` - */ - userLayers?: boolean - /** - * Default: `true` - * Boolean to indicate if the layers component should be registered globally. Name of the component will be the `${options.component}-layers-text, fe ` - */ - useLayersText?: boolean - /** - * Which icons you will use. Set tue `true` to import everything. - * FontAwesome [currently](https://fontawesome.com/how-to-use/on-the-web/referencing-icons/basic-use) supports 5 icon styles of which 3 are freely available (partially). - */ - icons: Icons - /** - * See `icons` for how to use, but always uses pro imports. - */ - proIcons: Icons - /** - * Default: `true` - * If the module should automatically add the fontawesome styles to the global css config. It works by unshifting @fortawesome/fontawesome-svg-core/styles.css onto the nuxt.options.css property. - */ - addCss?: boolean - /** - * Default: `false` - * Boolean whether to append -icon to the icon component name. - * This option exists as the component name option is also used for the layer components and you might not want to add `-icon` to those - */ - suffix?: boolean +declare module "@nuxt/types" { + interface NuxtConfig { + /** + * Nuxt FontAwesome module + * https://github.com/nuxt-community/fontawesome-module + */ + fontawesome?: { + /** + * Default: `"FontAwesomeIcon"` + * Change component name. Eg set to fa to use . + * Also see [suffix](https://github.com/nuxt-community/fontawesome-module#suffix) + * It's strongly recommended to use [PascalCase](https://vuejs.org/v2/style-guide/#Component-name-casing-in-templates-strongly-recommended) for component names + */ + component?: string + /** + * Default: `true` + * Boolean to indicate if the layers component should be registered globally. + * Name of the component will be `${options.component}-layers, fe ` + */ + userLayers?: boolean + /** + * Default: `true` + * Boolean to indicate if the layers component should be registered globally. Name of the component will be the `${options.component}-layers-text, fe ` + */ + useLayersText?: boolean + /** + * Which icons you will use. Set tue `true` to import everything. + * FontAwesome [currently](https://fontawesome.com/how-to-use/on-the-web/referencing-icons/basic-use) supports 5 icon styles of which 3 are freely available (partially). + */ + icons: Icons + /** + * See `icons` for how to use, but always uses pro imports. + */ + proIcons: Icons + /** + * Default: `true` + * If the module should automatically add the fontawesome styles to the global css config. It works by unshifting @fortawesome/fontawesome-svg-core/styles.css onto the nuxt.options.css property. + */ + addCss?: boolean + /** + * Default: `false` + * Boolean whether to append -icon to the icon component name. + * This option exists as the component name option is also used for the layer components and you might not want to add `-icon` to those + */ + suffix?: boolean } + } - interface Icons { - solid?: string[] | true, - regular?: string[] | true, - light?: string[] | true, - duotone?: string[] | true, - brands?: string[] | true - } + interface Icons { + solid?: FontAwesomeIcon[] | true + regular?: FontAwesomeIcon[] | true + light?: FontAwesomeIcon[] | true + duotone?: FontAwesomeIcon[] | true + brands?: FontAwesomeIcon[] | true + } + type FontAwesomeIcon = string | [string, string] }