gmostert / ng2-breadcrumb

This is an angular 2 component that creates a breadcrumb trail. It hooks into the angular2/router, to dynamically build up the crumb trail once a component is routed to.
MIT License
102 stars 81 forks source link

Variable 'name' is of the wrong type #81

Open pascallaprade opened 7 years ago

pascallaprade commented 7 years ago

In the breadcrumbService.ts file, in the getFriendlyNameForRoute method, variable name is created as a string but not assigned. At the end of the method, it is checked against a falsy value.

However, since its type is only string, TypeScript does not allow for it to be undefined in strict mode.

Even if this compiles correctly in normal modes, it does not when in strict mode, and should be fixed.

A simple fix considering the actual usage would just be to make the type string | undefined and everything would work as is.

Here is the actual tsc error message:

node_modules/ng2-breadcrumb/app/components/breadcrumbService.ts(83,16): error TS2454: Variable 'name' is used before being assigned.