Skip to content

Unable to import TS file from Svelte file #15

Closed
@tomasbonco

Description

@tomasbonco

Describe the bug
The path of .ts dependency can't be resolved by .svelte file.

To Reproduce
Steps to reproduce the behavior:

  1. Create a store.ts file, with content:
import { writable } from 'svelte/store'
export const something = writable( 10 )
  1. In App.svelte add following line:
import {something} from './store'

And you'll get:

[!] Error: Could not resolve './store' from src\App.svelte
Error: Could not resolve './store' from src\App.svelte
    at error (d:\node\bug-repro\node_modules\rollup\dist\rollup.js:10162:30)
    at ModuleLoader.handleMissingImports (d:\node\bug-repro\node_modules\rollup\dist\rollup.js:17237:17)
    at ModuleLoader.<anonymous> (d:\node\bug-repro\node_modules\rollup\dist\rollup.js:17288:26)
    at Generator.next (<anonymous>)
    at fulfilled (d:\node\bug-repro\node_modules\rollup\dist\rollup.js:40:28)
    at <anonymous>

Expected behavior
Everything should be awesome, no errors reported.

Additional context
During filling of this bug I found out that import {something} from './store.ts' does work, but throws error into console:

src/App.svelte:4:27 - error TS2691: An import path cannot end with a '.ts' extension. Consider importing './store' instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions