Why are Angular's activated route params of type "any"?

Viewed 1076

Just out of curiosity I tried to assign an ActivatedRoute's param to my variable defined to be a number:

public id: number;

constructor(public activatedRoute: ActivatedRouter) {}

public ngOnInit() {
    this.activatedRoute.params.take(1).subscribe((params) => {
        this.id = params['id']; // I was expecting to see a warning here
    }
}

...and it passed without any warning in my IDE and tslint. So I dug into it and discovered that it emits Params declared (here) to contain any elements:

export type Params = {
  [key: string]: any
};

And the question is why? AFAIK all the parameters are always strings. Is there a way to say Angular that some of our param should be a number or array and it will parse it?

0 Answers
Related