Skip to content
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

Compilation failures under TS 2.6 #823

Closed
alexeagle opened this issue Feb 15, 2018 · 6 comments
Closed

Compilation failures under TS 2.6 #823

alexeagle opened this issue Feb 15, 2018 · 6 comments

Comments

@alexeagle
Copy link
Contributor

When building with Bazel, I get some errors, eg.

modules/store/src/reducer_manager.ts(68,5): error TS2322: Type 'Partial<ActionReducerMap<any, any>>' is not assignable to type 'ActionReducerMap<any, any>'.
  Index signatures are incompatible.
    Type 'ActionReducer<any, any> | undefined' is not assignable to type 'ActionReducer<any, any>'.
      Type 'undefined' is not assignable to type 'ActionReducer<any, any>'.
modules/store/src/store_module.ts(67,26): error TS2532: Object is possibly 'undefined'.

I am not sure why the normal build doesn't have this problem. I am using the same version of TypeScript as in package.json, and the root tsconfig.json settings. I tried running yarn build but that fails with FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory - maybe someone on the team can diagnose why you don't see this type-check error. Seems legitimate to me.

@MikeRyanDev
Copy link
Member

Problem is that there isn't a good way to type the result of omit until we get mapped types in TypeScript 2.8. Since omit isn't part of our public API I would be fine changing the return type to any for now: https://github.com/ngrx/platform/blob/master/modules/store/src/utils.ts#L46

@alexeagle
Copy link
Contributor Author

Any idea why you don't get this error when you build?

This is just one location affected - I'll send a PR with a temp. fix for all of them, pointing to this issue as the TODO

@MikeRyanDev
Copy link
Member

Best guess is that it is because our build still uses TS 2.4 and the Bazel rules use TS 2.6. When we upgrade to TS 2.6 we see the same error.

@alexeagle
Copy link
Contributor Author

Oh, I probably had some leakage of module resolution - I did switch the Bazel build to TS 2.4 but it might have still picked up a version from rules_typescript. Need to screw down the module resolution tighter...

@alexeagle alexeagle changed the title Compilation failures under Bazel Compilation failures under TS 2.6 Feb 15, 2018
@bossqone
Copy link

bossqone commented Feb 27, 2018

I've upgraded our app from TypeScript 2.5.3 to 2.6.2 (strict mode) and now, there are few issues.

export interface RouterStateProjection {
  url: string | null;
  data: Data;
  params: Params;
  queryParams: Params;
}

export interface RootState {
  routerReducer: RouterReducerState<RouterStateProjection>;
  configInitialized: boolean;
}

export const rootReducers: ActionReducerMap<RootState> = {
  routerReducer: routerReducer, // this line fails
  configInitialized: configInitializedReducer,
};

it results in:

Type '{ routerReducer: <T = RouterStateSnapshot>(state: RouterReducerState<T>, action: RouterAction<any...' is not assignable to type 'ActionReducerMap<RootState, Action>'.
  Types of property 'routerReducer' are incompatible.
    Type '<T = RouterStateSnapshot>(state: RouterReducerState<T>, action: RouterAction<any, T>) => RouterRe...' is not assignable to type 'ActionReducer<RouterReducerState<RouterStateProjection>, Action>'.
      Types of parameters 'state' and 'state' are incompatible.
        Type 'RouterReducerState<RouterStateProjection> | undefined' is not assignable to type 'RouterReducerState<RouterStateProjection>'.
          Type 'undefined' is not assignable to type 'RouterReducerState<RouterStateProjection>'.

export interface State extends RootState {
  campaigns: CampaignState;
}

interface CampaignState {
  list: campaignListReducer.CampaignListState;
  detail: campaignDetailReducer.CampaignDetailState;
  form: campaignFormReducer.CampaignFormState;
  transactionList: campaignTransactionListReducer.CampaignTransactionListState;
  transactionDetail: transactionDetailReducer.TransactionDetailState;
}

export const campaignReducers: ActionReducerMap<CampaignState> = {
  list: campaignListReducer.reducer,
  detail: campaignDetailReducer.reducer,
  form: campaignFormReducer.reducer,
  transactionList: campaignTransactionListReducer.reducer,
  transactionDetail: transactionDetailReducer.reducer,
};
export interface CampaignListState {
  campaigns: Campaign[];
  totalCount: number;
  error: any;
  listingOptions: ListingOptions;
  preloadStatus: StatePreloadStatus;
}

export function reducer(state = initialState, action: CampaignListActions): CampaignListState {
Type '{ list: (state: CampaignListState | undefined, action: CampaignListActions) => CampaignListState;...' is not assignable to type 'ActionReducerMap<CampaignState, Action>'.
  Types of property 'list' are incompatible.
    Type '(state: CampaignListState | undefined, action: CampaignListActions) => CampaignListState' is not assignable to type 'ActionReducer<CampaignListState, Action>'.
      Types of parameters 'action' and 'action' are incompatible.
        Type 'Action' is not assignable to type 'CampaignListActions'.
          Type 'Action' is not assignable to type 'ResetAction'.
            Types of property 'type' are incompatible.
              Type 'string' is not assignable to type 'CampaignListActionTypes.RESET'.

Looks related to: #709 and #693

@alexeagle
Copy link
Contributor Author

I think this is obsolete, TS 2.7 is in the package.json now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants