ionic-team / ionic-react-conference-app

The Ionic Conference Demo App - Now in React

Home Page:https://ionic-react-conference-app.firebaseapp.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TypeScript 3.9

jayenashar opened this issue · comments

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';

have you been able to fix it

i upgraded to 3.7 only

I guess I will use the same version thanks

So do you all not get the error if you run typescript version 3.7? I tried that and I kept getting the error, so I'm not sure how to move forward. Does anyone know what the actual fix is?

i do not get the error with ts 3.7.

the actual fix is to not use typescript. i.e. rename the file to .js and remove all the types.

I just want to mention typescript 3.8.3 (with this project setup) works fine for me.

use ts 3.8.3 and set const [popoverEvent, setPopoverEvent] = useState<any>();

It's so easy to solve "Type 'R[K]' does not satisfy the constraint '(...args: any) => any'".
Just change "combineReducers" function signature -- function combineReducers<R extends any>(reducers: R)
to function combineReducers<R extends { [key: string]: any }>(reducers: R)

It's so easy to solve "Type 'R[K]' does not satisfy the constraint '(...args: any) => any'".
Just change "combineReducers" function signature -- function combineReducers<R extends any>(reducers: R)
to function combineReducers<R extends { [key: string]: any }>(reducers: R)

Simple but beautiful. Thanks alot