Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeScript error with external config file ? #87

Open
mrleblanc101 opened this issue Dec 29, 2022 · 3 comments
Open

TypeScript error with external config file ? #87

mrleblanc101 opened this issue Dec 29, 2022 · 3 comments

Comments

@mrleblanc101
Copy link

mrleblanc101 commented Dec 29, 2022

Hi,
I use this is nuxt in my nuxt.config.ts like so:

import ViteSvgLoader from 'vite-svg-loader';
import svgoConfig from './svgo.config.js';

export default defineNuxtConfig({
    vite: {
        plugins: [
            ViteSvgLoader({
                svgoConfig,
            }),
        ],
    },
});

Here is my external config file svgo.config.js:

module.exports = {
    plugins: [
        { name: 'prefixIds' },
        { name: 'removeTitle' },
        { name: 'removeDesc' },
        { name: 'removeDimensions' },
        {
            name: 'removeAttrs',
            params: {
                attrs: '(fill|stroke)',
            },
        },
    ],
};

Here is the error:

Type '{ plugins: ({ name: string; } | { name: string; params: { attrs: string; }; })[]; }' is not assignable to type 'Config'.
Types of property 'plugins' are incompatible.
Type '({ name: string; } | { name: string; params: { attrs: string; }; })[]' is not assignable to type 'PluginConfig[]'.
Type '{ name: string; } | { name: string; params: { attrs: string; }; }' is not assignable to type 'PluginConfig'.
Type '{ name: string; }' is not assignable to type 'PluginConfig'.
Property 'fn' is missing in type '{ name: string; }' but required in type 'CustomPlugin'.

@gkatsanos
Copy link
Collaborator

@mrleblanc101 does this work properly if you switch the files into plain JS?

@mrleblanc101
Copy link
Author

The Nuxt config ? I would guess not since it wouldn't do any type check. Haven't tried tho

@gkatsanos
Copy link
Collaborator

The Nuxt config ? I would guess not since it wouldn't do any type check. Haven't tried tho

I mean does the app and the plug-in work properly if you remove types / switch to JS instead of TS files.

(I suspect they don't, somethings wrong with your svgoConfig, I'd recheck the structure.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants