TypeScript
Explicit imports

by Benny Neugebauer

import {MemberData, NewTeamData, TeamChunkData, TeamData} from '../team';

export default class TeamAPI {
  constructor(private data: TeamData) {
  }
}

import * as team from '../team';

export default class TeamAPI {
  constructor(private data: team.TeamData) {
  }
}

Don't import * because otherwise it's not understandable which objects were imported. Also team. will be redundant.

Florian Keller

@Florian: But the redundancy at this point can be really helpful. Imagine this:


import * as user from '../user';

import * as team from '../team';



export default class TeamAPI {

  constructor(private data: team.TeamData) { //... }

  public getTeam(id: team.Identifier): Promise<void> { //... }

  public getUser(id: user.Identifier): Promise<void> { //... }

}

Benny Neugebauer

Sign in to comment!