Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to import a typescript module into Svelte Component

I'm trying to import a self-written TypeScript module into a svelte component. But I'm receiving the error that the module was not exported from its file even though I have done that. Does anybody have an idea how to solve this problem ?

ScreenShot of the Error

My Code:

telegram_bot.ts

export class TelegramBotForSafetyMania {...}

Home.svelte

import * as telegramBot from './../telegram_bot';
let bot = TelegramBotForSafetyMania.startBot();
like image 664
HostageQ Avatar asked Sep 13 '25 19:09

HostageQ


1 Answers

Assuming startBot is a static method on your class:

telegram_bot.ts:

export class TelegramBotForSafetyMania {...}

Home.svelte:

import * as telegramBot from './../telegram_bot';

const {TelegramBotForSafetyMania} = telegramBot;

let bot = TelegramBotForSafetyMania.startBot();
like image 103
jsejcksn Avatar answered Sep 15 '25 10:09

jsejcksn