Is it possible to combine members of multiple types in a TypeScript annotation?

ANSWER UPDATED ON 2018-10-30

TypeScript now has type intersections. So you can now simply do:

interface ClientRequest {
  userId:     number
  sessionKey: string
}

interface Coords {
  lat:  number
  long: number
}

function log(data: ClientRequest & Coords) { 
  console.log(
    data.userId,
    data.sessionKey,
    data.lat,
    data.long
  );
}

ORIGINAL ANSWER

The specific answer to your question is: no, there is not a single inline annotation to signify combined or extended types.

The best practice for the problem you are trying to solve would be to create third type that would extend the other two.

interface IClientRequestAndCoords extends IClientRequest, ICoords {} 

function(data: IClientRequestAndCoords) 

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)