头图

State, effects, action, reducer are all in this folder:

The RouterState interface is defined in routing-state.ts:

Inherited from the RouterReducerState type in ngrx router, the type parameter is our custom ActivatedRouterStateSnapshot.

export interface ActivatedRouterStateSnapshot {
  url: string;
  queryParams: Params;
  params: Params;
  context: PageContext;
  cmsRequired: boolean;
  semanticRoute?: string;
}

Look at an example:

interface myType<T,V>{
  name: T,
  value: V
};

interface jerryType extends myType<string, number>{
  score: number;
}

const a: jerryType = {
  name: 'Jerry',
  value: 1,
  score: 2
};

The type of state is passed when the extension type of RouterReducerState needs to be defined:

BaseRouterStoreState type: There is only one url field:

Our custom ActivatedRouterStateSnapshot extends BaseRouterStoreState, and the first field is url:

Look at an example:


type jerryType = {
  name: string
};
interface mySuperType<T extends jerryType>{
  value: T
};

type superJerryType = {
  score: number;
  name: string;
}

let a: mySuperType<superJerryType> = {
  value:{
    score: 1,
    name: 'Jerry'
  }
};

console.log(a);

More original articles by Jerry, all in: "Wang Zixi":


注销
1k 声望1.6k 粉丝

invalid