melte icon indicating copy to clipboard operation
melte copied to clipboard

Svelte + TypeScript problem: Inner component is not defined

Open patryk-m-malinowski opened this issue 1 year ago • 8 comments

Hi. I am unable to get a Meteor app to work with Svelte + TypeScript. The issue is that if an outer (i.e. parent) component imports and uses an inner component (i.e. child), and the outer component has

Reproduction: I run the command meteor run, and there are no errors in the command output. However, when I open the app in the browser, I get the following error in the browser console: undefined-component

More information for you: -The app works fine when I change the <script lang="ts> tags to

If this is the wrong project to report this bug, please forgive me.

Thank you.

patryk-m-malinowski avatar Aug 09 '24 04:08 patryk-m-malinowski

You probably need to enable this option in your tsconfig: https://www.typescriptlang.org/tsconfig/#verbatimModuleSyntax

With the current version of svelte-preprocess, component imports can be removed when the option is disabled.

zodern avatar Aug 09 '24 14:08 zodern

This option was already enabled and it didn't have an effect unfortunately. Here is my tsconfig.json

patryk-m-malinowski avatar Aug 10 '24 11:08 patryk-m-malinowski

Just realised something interesting! This error only happens in the top level component (App.svelte), where its children are not defined. The other components work fine.

patryk-m-malinowski avatar Aug 10 '24 17:08 patryk-m-malinowski

Hello, I'm trying to solve Meteor 3 transition problems. I opened a pr for one of them https://github.com/zodern/melte-compiler/pull/11. However, I could not find the cause of the ts problem. I also opened a topic in the Meteor forum and tried to explain the problem I was having. I hope it will be a guide. https://forums.meteor.com/t/meteor-js-v3-0-zodern-melte-compiler/62002

Sergeant61 avatar Aug 11 '24 14:08 Sergeant61

@p9malino26 have you found any solution?

Sergeant61 avatar Aug 12 '24 15:08 Sergeant61

Sorry, didn't really have time to look into this. Will tell you once I look into this.

patryk-m-malinowski avatar Aug 12 '24 18:08 patryk-m-malinowski

Hello, although I do not know exactly what the problem is caused by, we are experiencing this problem in typescript version 5.5.4. I was able to run the project by fixing it to version 5.4.4.

...
"devDependencies": {
    "svelte-preprocess": "^5.1.4",
    "typescript": "5.4.4"
  },
...

Sergeant61 avatar Aug 13 '24 19:08 Sergeant61

Ok so it looks like I no longer have the issue in my project! (don't know what's happened), but I can reproduce the issue when I revert the project to an older Git commit. Will investigate into this deeper when I have time.

patryk-m-malinowski avatar Aug 14 '24 05:08 patryk-m-malinowski

The latest version fixes using typescript 5.

zodern avatar Mar 19 '25 17:03 zodern