angular2-logger: ERROR in [default] \node_modules\angular2-logger\app\core\logger.ts:62:38 Type 'string' is not assignable to type 'Level'.

This problem appeared with angular2-logger 0.3.0 after I updated to Angular 2 rc5. I just updated angular2-logger to its latest 0.4.2 and the problem still shows up.

ERROR in [default] \node_modules\angular2-logger\app\core\logger.ts:62:38 Type 'string' is not assignable to type 'Level'.

Changing the line from:

private _loadLevel = (): Level => localStorage.getItem( this._storeAs );

to

private _loadLevel = (): any=> localStorage.getItem( this._storeAs );

seems to resolve the problem.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 39 (16 by maintainers)

Commits related to this issue

Most upvoted comments

Ha, edited the best part 😃 Most heated ā€œsearch for truthā€ I’ve witnessed so far! Thanks guys!

Yea @ascreamingweas ,

In short, it means your build process is compiling this third party library which is an overhead in your build process since the library is already compiled, the fact that you get this error means your build process can be highly improved in order to avoid already compiled third parties (not only this one, but any), getting compiled once again by your PC. If you follow the Quickstart Guide in Angular 2 for either SystemJS or Webpack you won’t get this error.

If you don’t care about this extra overhead in your project’s build process you can leave it as is, I’ll be commiting a fix for this error soon enough.

@ascreamingweas Yes, this entire thread is about this problem 😃 You can do one of the following directly in the relevant line of the angular2-logger module. These are obviously temporary hacks:

private _loadLevel = (): Level => +localStorage.getItem( this._storeAs ); or private _loadLevel = (): any => localStorage.getItem( this._storeAs );