4

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();

2 Answers 2

4

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();
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you for your answer @jsejcksn! I found out that I should have imported the module without the ./ at the beginning. So the line import {TelegramBotForSafetyMania} from '../telegram_bot' solved this issue.
However, now I'm facing another error while importing the module. I created a question to it. I will really appreciate it if you could help me with solving it. stackoverflow.com/questions/70876587/…
1

I found out that I should have imported the module without the ./ at the beginning. So the line

import {TelegramBotForSafetyMania} from '../telegram_bot' solved this issue

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.