Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Module has no exported member, export interface

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'.

My leaderboard.ts file:

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:

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?

like image 426
Eric Chu Avatar asked Apr 13 '17 04:04

Eric Chu


People also ask

How do I fix a module that has no exports?

The error "Module has no exported member" occurs when we try to import a member that doesn't exist in the specified module. To solve the error, make sure the module exports the specific member and you haven't mistyped the name or mistaken named for default import. Copied!

How do I export a TypeScript Const?

To export a constant in TypeScript, we can use the export keyword. export const adminUser = { //... }; to export the adminUser constant.

What is export type in TypeScript?

TypeScript supports export = to model the traditional CommonJS and AMD workflow. The export = syntax specifies a single object that is exported from the module. This can be a class, interface, namespace, function, or enum.

How do I export a function in TypeScript?

Use named exports to export a function in TypeScript, e.g. export function sum() {} . The exported function can be imported by using a named import as import {sum} from './another-file' . You can use as many named exports as necessary in a single file.


2 Answers

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

like image 179
Eric Chu Avatar answered Nov 02 '22 14:11

Eric Chu


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.

like image 31
Gabi Klapman Avatar answered Nov 02 '22 12:11

Gabi Klapman