Skip to content

TypeScript 3.9 #50

Open
Open
@jayenashar

Description

@jayenashar

I tried to upgrade to get some esnext features, but there seem to be some breaking changes. I think https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-9.html#type-parameters-that-extend-any-no-longer-act-as-any . Getting errors with combineReducers.ts in various places and About.tsx with setPopoverEvent(e.nativeEvent);

9.chunk.js:113347 src/data/combineReducers.ts
TypeScript error in src/data/combineReducers.ts(3,47):
Type 'R[K]' does not satisfy the constraint '(...args: any) => any'.
  Type 'R[keyof R]' is not assignable to type '(...args: any) => any'.
    Type 'R[string] | R[number] | R[symbol]' is not assignable to type '(...args: any) => any'.
      Type 'R[string]' is not assignable to type '(...args: any) => any'.  TS2344

    1 | export function combineReducers<R extends any>(reducers: R) {
    2 |   type keys = keyof typeof reducers;
  > 3 |   type returnType = { [K in keys]: ReturnType<typeof reducers[K]> }
      |                                               ^
    4 |   const combinedReducer = (state: any, action: any) => {
    5 |     const newState: returnType = {} as any;
    6 |     const keys = Object.keys(reducers);
console.<computed> @ 9.chunk.js:113347
9.chunk.js:113347 src/data/combineReducers.ts
TypeScript error in src/data/combineReducers.ts(6,30):
No overload matches this call.
  Overload 1 of 2, '(o: {}): string[]', gave the following error.
    Argument of type 'R' is not assignable to parameter of type '{}'.
      Type 'unknown' is not assignable to type '{}'.
  Overload 2 of 2, '(o: object): string[]', gave the following error.
    Argument of type 'R' is not assignable to parameter of type 'object'.
      Type 'unknown' is not assignable to type 'object'.  TS2769

    4 |   const combinedReducer = (state: any, action: any) => {
    5 |     const newState: returnType = {} as any;
  > 6 |     const keys = Object.keys(reducers);
      |                              ^
    7 |     keys.forEach(key => {
    8 |       const result = reducers[key](state[key], action);
    9 |       newState[key as keys] = result || state[key];
console.<computed> @ 9.chunk.js:113347
9.chunk.js:113347 src/data/combineReducers.ts
TypeScript error in src/data/combineReducers.ts(8,22):
Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'unknown'.
  No index signature with a parameter of type 'string' was found on type 'unknown'.  TS7053

     6 |     const keys = Object.keys(reducers);
     7 |     keys.forEach(key => {
  >  8 |       const result = reducers[key](state[key], action);
       |                      ^
     9 |       newState[key as keys] = result || state[key];
    10 |     });
    11 |     return newState;
console.<computed> @ 9.chunk.js:113347
9.chunk.js:113347 src/pages/About.tsx
TypeScript error in src/pages/About.tsx(15,21):
Argument of type 'MouseEvent' is not assignable to parameter of type 'SetStateAction<undefined>'.
  Type 'MouseEvent' provides no match for the signature '(prevState: undefined): undefined'.  TS2345

    13 | 
    14 |   const presentPopover = (e: React.MouseEvent) => {
  > 15 |     setPopoverEvent(e.nativeEvent);
       |                     ^
    16 |     setShowPopover(true);
    17 |   };
    18 |   const conferenceDate = '2047-05-17';

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions