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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot build with default export and typescript #57

Open
dolie opened this issue Oct 27, 2022 · 2 comments
Open

Cannot build with default export and typescript #57

dolie opened this issue Oct 27, 2022 · 2 comments

Comments

@dolie
Copy link

dolie commented Oct 27, 2022

Hello 馃憢,

When using default export, and running vite build, I got this error :

error TS2322: Type '{ class: string; }' is not assignable to type 'IntrinsicAttributes'.
  Property 'class' does not exist on type 'IntrinsicAttributes'.

I do not have this error when running dev server / or using named imports.
I am running Preact.

// tsconfig.json
{
  "compilerOptions": {
    "target": "ESNext",
    "useDefineForClassFields": true,
    "lib": ["DOM", "DOM.Iterable", "ESNext"],
    "allowJs": false,
    "skipLibCheck": true,
    "esModuleInterop": false,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "module": "ESNext",
    "moduleResolution": "Node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react-jsx",
    "jsxImportSource": "preact",
    "baseUrl": ".",
    "types": [
      "vite/client",
      "vite-plugin-svgr/client"
    ],
    "paths": {
      "@/*" : ["src/*"],
      "react": ["./node_modules/preact/compat/"],
      "react-dom": ["./node_modules/preact/compat/"]
    },
    "typeRoots": ["node_modules/@types", "src/@types"],
  },
  "include": ["src"],
  "references": [{ "path": "./tsconfig.node.json" }]
}
// vite.config.ts
  plugins: [
    preact(),
    svgr({
      exportAsDefault: true,
      svgrOptions: {
        svgoConfig: {
          prefixIds: false
        }
      }
    }),
  ],
// svg.d.ts
/// <reference types="vite-plugin-svgr/client" />

declare module "*.svg" {
  const content: any;
  export default content;
}
@panjiangyi
Copy link

see here 44

@spoilerdo
Copy link

Add the following to your tsconfig:

{
  "compilerOptions": {
    "types": ["vite/client", "vitest/globals", "vite-plugin-svgr/client"],
    }
  }
}

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

3 participants