zalando-incubator/authmosphere

Document breaking change in 3.0.0

bzums opened this issue · 1 comments

bzums commented

A breaking change was introduced regarding the Token type in 3.0.0. This change should be documented.

The type changed from:

type Token<CustomTokenPart = {}> = CustomTokenPart & {
  access_token: string;
  expires_in?: number;
  scope?: string[];
  token_type?: string;
  local_expiry?: number;
};

to

type Token<CustomTokenPart = Record<string, unknown>> = CustomTokenPart & {
  access_token: string,
  expires_in?: number,
  scope?: string[],
  token_type?: string,
  local_expiry?: number
};

So when you before could "extend" the token type with custom properties like:

const mytoken: Token<{ id: number }> = {
  access_token: 'abcToken',
  id: 2424242828
}

with 3.0.0 id is of type unknown and you have to convince the compiler of the type you want to be applied yourself.

This has still to be documented, furthermore, maybe the types can be simplified because the generic part of Token is not really customisable anymore from outside the lib as it seems. I think because the generic part defaults to Record<string, unknown> and it is not really possible to "overwrite" this in a meaningful way.

tackled by #254