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

Cannot find .svelte imports #27

Open
Krossmaskinen opened this issue Oct 5, 2022 · 0 comments
Open

Cannot find .svelte imports #27

Krossmaskinen opened this issue Oct 5, 2022 · 0 comments

Comments

@Krossmaskinen
Copy link

When I try to import something with a .svelte ending I get this message:

Cannot find module './svelte-components/Button.svelte' or its corresponding type declarations

I installed a fresh app with create-react-app (react 18.x.x), installed svelte-adapter (0.5.0), and just added a basic button component like this:

// Button.svelte

<script>
  function logHello() {
    console.log('Hello');
  }
</script>

<button on:click={logHello}>Svelte Button</button>

and import it in my App.tsx like this:

import React from "react";
import toReact from "svelte-adapter/react";
import Button from "./svelte-components/Button.svelte";

function App() {
  const SvelteInReact = toReact(Button, {}, "div");

  return (
    <div className="App">
      <SvelteInReact />
    </div>
  );
}

export default App;

I've also tried installing @tsconfig/svelte (3.0.0) and adding the following to my tsconfig.json

"extends": "@tsconfig/svelte/tsconfig.json"

But I still get the same error. The codesandbox example imports and renders an installed library component from svelte-easy-crop, so it's not really the same as importing your own components.

When I update the codesandbox example with my own code, adding a Button.svelte and renders it, I get the same as in issue #15:
Uncaught TypeError: Component is not a constructor

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

1 participant