最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Attempted import error:' is not exported from - Stack Overflow

programmeradmin1浏览0评论

i cant resolve my problem. I have a file where I declare a class with the following code in lama.d.ts

export declare class lama  {


    // code here
}

Then I import this in another file in the same folder of my react project

import { lama} from './lama.d';

But I have the following error : Attempted import error: 'lama' is not exported from './lama.d'.

It does the same in a .ts instead of .d.ts file. And the mostt weird is that if I export another class from this file (lama.d.ts) that I import from another file to lama.d.ts , it works , but not the class that i wantt to work.

thank you for reading me

i cant resolve my problem. I have a file where I declare a class with the following code in lama.d.ts

export declare class lama  {


    // code here
}

Then I import this in another file in the same folder of my react project

import { lama} from './lama.d';

But I have the following error : Attempted import error: 'lama' is not exported from './lama.d'.

It does the same in a .ts instead of .d.ts file. And the mostt weird is that if I export another class from this file (lama.d.ts) that I import from another file to lama.d.ts , it works , but not the class that i wantt to work.

thank you for reading me

Share Improve this question asked Dec 14, 2021 at 10:19 LamaLama 311 gold badge3 silver badges5 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 2

I had the same error, but used export default and it worked!


    declare class lama {
      // code here .. 
      export default lama
    }

When import :

    import lama from './lama.d'
发布评论

评论列表(0)

  1. 暂无评论