-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Type mismatch with angular 5.2 and typescript 2.6.2 #709
Comments
Confirming, i have this problem, too! |
seem like typescript 2.6.2 break many other libs, switched back to 2.5.3 now |
@sandangel It looks like this error is displaying when |
I confirm that it work when set strict to true and strictFunctionTypes to false |
@brandonroberts @MikeRyanDev this is not only problem of the router, but basically with approach of typed actions. See: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-6.html |
I confirm that I run into the same problem of type incompatibility, and I also have created an issue (#611 (comment)) that is unanswered. I don't agree to the fact that we need to set |
I have modified ofType implementation and solved error in effects. Then using REDUCER_TOKEN instead of ActionReducerMapp as a work around. import { Action } from '@ngrx/store';
import { filter } from 'rxjs/operators';
export function ofType<T extends Action>(...allowedTypes: string[]) {
return filter((action: Action): action is T => {
return allowedTypes.some(type => type === action.type);
});
} export const REDUCER_TOKEN = new InjectionToken<ActionReducerMap<State>>('Registered Reducers');
@NgModule({
declarations: [AppComponent],
imports: [
BrowserModule.withServerTransition({ appId: 'my-app' }),
BrowserAnimationsModule,
LayoutModule,
MaterialModule,
SharedModule,
RouterModule.forRoot([]),
ServiceWorkerModule.register('/ngsw-worker.js', { enabled: environment.production }),
/* use token here */
StoreModule.forRoot(REDUCER_TOKEN),
EffectsModule.forRoot([RouterEffects]),
!environment.production ? StoreDevtoolsModule.instrument() : [],
StoreRouterConnectingModule.forRoot({
stateKey: 'router'
})
],
bootstrap: [AppComponent],
providers: [
{ provide: RouterStateSerializer, useClass: CustomSerializer },
// Provide reducer map here
{ provide: REDUCER_TOKEN, useFactory: () => ({ router: routerReducer }) }
]
})
export class AppModule {} Or you can use ActionReducerMap<any, any> to ignore type checking |
hi, I still have this problem and I suppose that this issue was not fixed by #841 export interface ActionReducer<T, V extends Action = Action> {
(state: T | undefined, action: V): T;
}
// and
export declare function routerReducer<T = RouterStateSnapshot>(
state: RouterReducerState<T>,
action: RouterAction<any, T>
): RouterReducerState<T>;
which mean:
both are not possible since undefined is not assignable to RouterReducerState and string is not assignable to string literal I suggest to fix this issue we have to change the signature of routerReducer to export declare function routerReducer<T = RouterStateSnapshot>(
state: RouterReducerState<T> | undefined, // add undefined
action: RouterAction<any, T>
): RouterReducerState<T>; and change the default type in |
I'm submitting a...
What is the current behavior?
consider the following snippet
tsconfig.json:
It worked with typescript 2.5.3, but after updating to typescript 2.6.2 (which is now supported in angular 5.2.0), compiler has show an error and project can not be successfully built anymore
Expected behavior:
App continue to work with typescript 2.6.2
Minimal reproduction of the problem with instructions:
clone this repo ngrx-bug-report and serve --aot
git clone https://github.com/sandangel/ngrx-bug-report.git
ng serve --aot
Version of affected browser(s),operating system(s), npm, node and ngrx:
Chrome 63, Ubuntu 16.04, npm 5.6, node 8.9.4, ngrx 4.1.1
Other information:
The text was updated successfully, but these errors were encountered: