Skip to content

TypeScript not being processed when no filename is given #488

@bfanger

Description

@bfanger

Describe the bug
if (filename == null) return { code: content };
in svelte-preprocess/src/transformers/typescript.ts line 497 is the issue.

To Reproduce
Call svelte.preprocess(code, processor) manually without providing the third optional parameter ( omitting the filename )

https://github.com/wangjia184/svelte-parser/blob/master/src/worker.ts (not mine, not small)

Expected behavior
when inputing const x : number = 1 the output to be const x = 1, even when no filename was provided.

Additional context
When you provide a weird filename like " " then the preprocessor will work and remove the type annotations.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions