Skip to content

Error: Could not resolve TypeScript file without .ts extension #159

Closed
@hbbio

Description

@hbbio

Describe the bug

When using Svelte with an external script, in TypeScript, which itself imports components from other .ts files, we can't omit the .ts extension for import.

Otherwise, build fails with:

src/main.ts → public/build/bundle.js...
[!] Error: Could not resolve './initials' from src/App.svelte

Note that adding the .ts extension solves the problem with svelte-preprocess but then raises the following TypeScript error:

src/main.ts → public/build/bundle.js...
src/App.svelte:1:26 - error TS2691: An import path cannot end with a '.ts' extension. Consider importing './initials' instead.

To Reproduce

Cf. hbbio/svelte-ts@4ae0dd0

Expected behavior
Ability to import TypeScript files without the ts extension.
Information about your project:

  • svelte 3.23.0
  • typescript 3.9.3
  • svelte-preprocess 3.7.4
  • rollup

Metadata

Metadata

Assignees

No one assigned

    Labels

    next-majorwill be fixed in the next major

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions