natemoo-re / astro-icon

Inline and sprite-based SVGs in Astro made easy!
https://astroicon.dev
Other
992 stars 57 forks source link

Argument of type 'string | undefined' is not assignable to parameter of type 'string' #138

Closed FDiskas closed 6 months ago

FDiskas commented 10 months ago

Hi! πŸ‘‹

Firstly, thanks for your work on this project! πŸ™‚

Today I used patch-package to patch astro-icon@0.8.1 for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/astro-icon/lib/createIconPack.ts b/node_modules/astro-icon/lib/createIconPack.ts
index c49ccae..3045d92 100644
--- a/node_modules/astro-icon/lib/createIconPack.ts
+++ b/node_modules/astro-icon/lib/createIconPack.ts
@@ -15,7 +15,7 @@ export function createIconPack({
 }: CreateIconPackOptions) {
   if (pkg) {
     return async (name: string) => {
-      const baseUrl = new URL(pathToFileURL(resolvePackage(pkg)) + "/");
+      const baseUrl = new URL(pathToFileURL(resolvePackage(pkg) ?? '') + "/");
       const path = fileURLToPath(
         new URL(dir ? `${dir}/${name}.svg` : `${name}.svg`, baseUrl)
       );

This issue body was partially generated by patch-package.

natemoo-re commented 6 months ago

Thanks for the issue! I'm going to close this since Astro Icon v1 has been released, but please open a new issue if you run into anything problems!