George Kalpakas 97ae2d3b9b refactor(docs-infra): fix docs examples for tslint rule prefer-const (#38143)
This commit updates the docs examples to be compatible with the
`prefer-const` tslint rule.

This is in preparation of updating the docs examples `tslint.json` to
match the one generated for new Angular CLI apps in a future commit.

PR Close #38143
2020-08-07 22:10:55 -04:00

26 lines
680 B
TypeScript

import { Injectable, Type } from '@angular/core';
import { Logger } from './logger.service';
import { Hero } from './hero';
const HEROES = [
new Hero('Windstorm', 'Weather mastery'),
new Hero('Dr Nice', 'Killing them with kindness'),
new Hero('Magneta', 'Manipulates metallic objects')
];
@Injectable()
export class BackendService {
constructor(private logger: Logger) {}
getAll(type: Type<any>): PromiseLike<any[]> {
if (type === Hero) {
// TODO: get from the database
return Promise.resolve<Hero[]>(HEROES);
}
const err = new Error('Cannot get object of this type');
this.logger.error(err);
throw err;
}
}