angular-redux / store

Angular 2+ bindings for Redux
MIT License
1.34k stars 205 forks source link

@select decorator error: property has no initializer and is not definitely assigned in the constructor. #560

Open ildar-icoosoft opened 5 years ago

ildar-icoosoft commented 5 years ago

This is a...

What toolchain are you using for transpilation/bundling?

Environment

NodeJS Version: v8.12.0 Typescript Version: 3.1.6 Angular Version: 7.2.7 @angular-redux/store version: 9.0.0 @angular/cli version: (if applicable) 7.2.4 OS: windows 7

I have tsconfig with the following settings

{
  ...
  "compilerOptions": {
    ...
    "strictNullChecks": true,
    "strictPropertyInitialization": true,
    ...
  }
  ...
}

these are very useful settings, but they don't work with @select() decorator. For example:

@Component({
  selector: "app-root",
  templateUrl: "app.component.html"
})
export class AppComponent {
  @select()
  private entities$: Observable<IReduxEntities>;
}

This code causes error: Property 'entities$' has no initializer and is not definitely assigned in the constructor.

I know that I can use ngRedux.select(['entities']); instead of @select decorator. But it would be great if @select() decorator worked with my tsconfig