Skip to content
This repository was archived by the owner on Jul 22, 2020. It is now read-only.

Typescript import inside Svelte component raises errorΒ #3

@nick-lehmann

Description

@nick-lehmann

Very nice work, highly appreciate this very minimal and sleek template πŸ‘πŸ»

This issue is probably not directly related to this template, but it occurs using it. Importing a .ts file from another .ts file works just fine.

src/utils.ts

export function greeter(): string {
    return "Hello world"
}

src/index.ts

import Svelte from './index.svelte'
import { greeter } from './utils'

console.log(greeter())

new Svelte({
  target: document.body
})

However, if I do the import in a Svelte component, the compiler raises an error that it cannot find the module.

src/index.svelte

<script lang="ts">
  import { greeter } from './utils'
  console.log(greeter())
  
  const a: string = "Svelte",
    b: string = "Typescript",
    c: string = "Rollup";
</script>

<style lang="scss">
  [...]
</style>

<h1>{a} + {b} + {c}</h1>

It errors with the following message:

25 - error TS2307: Cannot find module './utils'.
3 import { greeter } from './utils'

However, it seems to have no effect at all. The application is still running and gets updated. The error also only occurs when saving the .svelte file. If I save a .ts file, nothing happens even if the import that causes the error is still present.

This errors also occurs with this similar template, but not with your rollup template.

I am not very experienced in javascript and setting up all those tools. Therefore, I wanted to ask if you know if this might be a problem with parcel-bundler, parcel-svelte-plugin or with svelte-preprocess?

Metadata

Metadata

Assignees

Labels

help wantedExtra attention is neededstrange behaviourundefined or unexpected behaviour

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions