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?
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!
To export a constant in TypeScript, we can use the export keyword. export const adminUser = { //... }; to export the adminUser constant.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With