typescript 模块没有导出成员,导出接口

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/43383498/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 04:26:55  来源:igfitidea点击:

Module has no exported member, export interface

angularjstypescript

提问by Eric Chu

This is the error I'm getting,

这是我得到的错误,

/Users/robot/code/slg-fe/src/app/leaderboards/leaderboards.component.ts (2,10): Module '"/Users/robot/code/slg-fe/src/app/leaderboards/leaderboard"' has no exported member 'Leaderboard'.

/Users/robot/code/slg-fe/src/app/leaderboards/leaderboards.component.ts (2,10): 模块 '"/Users/robot/code/slg-fe/src/app/leaderboards/leaderboard" ' 没有导出成员 'Leaderboard'。

My leaderboard.ts file:

我的排行榜.ts 文件:

export interface Leaderboard {
  id: number,
  username: string,
  rank_elo: number,
  role: number,
  total_wins: number,
  kda: number,
  yesterday_rank: number
}

My leaderboard.component.ts file:

我的排行榜.component.ts 文件:

import { Component } from '@angular/core';
import { Leaderboard } from './leaderboard';

@Component({
  selector: 'leaderboards',
  templateUrl: './leaderboards.component.html'
})
export class LeaderboardsComponent { }

My leaderboard.ts file IS exporting a Leaderboard, but for some reason it's not?

我的 leaderboard.ts 文件正在导出排行榜,但出于某种原因,它不是?

回答by Eric Chu

So.. I'm not sure why, but when I restarted my server it all started working.. -__- I hate this so much. I spent so long trying to figure this out.

所以.. 我不知道为什么,但是当我重新启动我的服务器时,一切都开始工作了.. -__- 我非常讨厌这个。我花了很长时间试图弄清楚这一点。

回答by Gabi Klapman

I had this error for two different imports.

我对两个不同的导入有这个错误。

I restarted my server and one of them disappeared. For the other, I deleted the import, built it (with lots of errors), and added the import exactly as it was before.

我重新启动了我的服务器,其中一个消失了。另一方面,我删除了导入,构建了它(有很多错误),并完全像以前一样添加了导入。