Typescript: Arrow function - TS2339: Property does not exist on type '{}'

Thibs

Using Angular, I often get typescript compile errors when using fat arrow functions inside an rxjs stream.

I can still run the app and it does transpile, but I would like to know how to get rid of the error and understand it.

Given:

this.data$ = this.route.params
        .switchMap(params =>  
             Observable.forkJoin([
                 Observable.of(params),
                 this.http.get('/api', { param1: params.param1, param2: params.param2 })
        ])
        //**Errors from this part below**
        .map(([params, data]) => data.prop1 + ' - ' + params.param1)

I get the errors:

ERROR in [at-loader] file.ts:xx:xx TS2339: Property 'prop1' does not exist on type '{}'.

ERROR in [at-loader] file.ts:xx:xx TS2339: Property 'param1' does not exist on type '{}'.

Why does it complain about this?

cyr_x

Try this one:

this.data$ = this.route.params
    .switchMap((params: any) =>  
         Observable.forkJoin([
             Observable.of(params),
             this.http.get('/api', { param1: params.param1, param2: params.param2 })
    ])
    //**Errors from this part below**
    .map(([params, data]: [any, any]) => data.prop1 + ' - ' + params.param1)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Typescript Error TS2339: Property 'project' does not exist on type '{}'

From Java

Updating api service to typescript - TS2339: Property 'instance' does not exist on type 'Http'

From Dev

TypeScript | Array.from | error TS2339: Property 'from' does not exist on type 'ArrayConstructor'

From Dev

error TS2339: Property 'results' does not exist on type 'Response'

From Dev

error TS2339: Property 'x' does not exist on type 'Y'

From Java

error TS2339: Property 'for' does not exist on type 'HTMLProps<HTMLLabelElement>'

From Dev

error TS2339: Property 'endsWith' does not exist on type 'string'

From Dev

error TS2339: Property 'loading' does not exist on type 'DiseaseListComponent'

From Dev

TS2339: Property 'getBoundingClientRect' does not exist on type 'never'

From Dev

Error TS2339: Property 'entries' does not exist on type 'FormData'

From Dev

error TS2339: Property 'includes' does not exist on type '{}'

From Dev

How to resolve TypeScript compiler error TS2339: Property 'errorValue' does not exist on type {} in my Angular 5 application

From Dev

angular2: Error:(62, 33) TS2339: Property 'resolveAndCreate' does not exist on type 'typeof Injector'

From Dev

error TS2339: Property 'log' does not exist on type '{ new (): Console; prototype: Console; }'

From Dev

error TS2339: Property 'catch' does not exist on type 'PromiseLike<void>'

From Dev

error TS2339 : Property '' does not exist on type '' Angular2

From Dev

Error :'error TS2339: Property 'data' does not exist on type 'Response'.- Angular

From Dev

TypeScript: Property 'propertyName' does not exist on type 'Function'

From Dev

Error TS2339: Property 'JSON' does not exist on type 'Object'. ".map(resp => resp.JSON())" angular 4

From Java

Property 'hot' does not exist on type 'NodeModule'.ts(2339)

From Java

Property 'allSettled' does not exist on type 'PromiseConstructor'.ts(2339)

From Dev

error TS: 2339 Property "Project" does not exist on type { }

From Java

Property 'value' does not exist on type EventTarget in TypeScript

From Java

jest typescript property mock does not exist on type

From Dev

Typescript property does not exist on type 'ElementFinder'

From Dev

Typescript: Property 'src' does not exist on type 'HTMLElement'

From Dev

TypeScript - Property 'id' does not exist on type 'Node'

From Dev

Property 'load' does not exist on type TypeScript?

From Dev

Typescript property does not exist on type 'ElementFinder'

Related Related

  1. 1

    Typescript Error TS2339: Property 'project' does not exist on type '{}'

  2. 2

    Updating api service to typescript - TS2339: Property 'instance' does not exist on type 'Http'

  3. 3

    TypeScript | Array.from | error TS2339: Property 'from' does not exist on type 'ArrayConstructor'

  4. 4

    error TS2339: Property 'results' does not exist on type 'Response'

  5. 5

    error TS2339: Property 'x' does not exist on type 'Y'

  6. 6

    error TS2339: Property 'for' does not exist on type 'HTMLProps<HTMLLabelElement>'

  7. 7

    error TS2339: Property 'endsWith' does not exist on type 'string'

  8. 8

    error TS2339: Property 'loading' does not exist on type 'DiseaseListComponent'

  9. 9

    TS2339: Property 'getBoundingClientRect' does not exist on type 'never'

  10. 10

    Error TS2339: Property 'entries' does not exist on type 'FormData'

  11. 11

    error TS2339: Property 'includes' does not exist on type '{}'

  12. 12

    How to resolve TypeScript compiler error TS2339: Property 'errorValue' does not exist on type {} in my Angular 5 application

  13. 13

    angular2: Error:(62, 33) TS2339: Property 'resolveAndCreate' does not exist on type 'typeof Injector'

  14. 14

    error TS2339: Property 'log' does not exist on type '{ new (): Console; prototype: Console; }'

  15. 15

    error TS2339: Property 'catch' does not exist on type 'PromiseLike<void>'

  16. 16

    error TS2339 : Property '' does not exist on type '' Angular2

  17. 17

    Error :'error TS2339: Property 'data' does not exist on type 'Response'.- Angular

  18. 18

    TypeScript: Property 'propertyName' does not exist on type 'Function'

  19. 19

    Error TS2339: Property 'JSON' does not exist on type 'Object'. ".map(resp => resp.JSON())" angular 4

  20. 20

    Property 'hot' does not exist on type 'NodeModule'.ts(2339)

  21. 21

    Property 'allSettled' does not exist on type 'PromiseConstructor'.ts(2339)

  22. 22

    error TS: 2339 Property "Project" does not exist on type { }

  23. 23

    Property 'value' does not exist on type EventTarget in TypeScript

  24. 24

    jest typescript property mock does not exist on type

  25. 25

    Typescript property does not exist on type 'ElementFinder'

  26. 26

    Typescript: Property 'src' does not exist on type 'HTMLElement'

  27. 27

    TypeScript - Property 'id' does not exist on type 'Node'

  28. 28

    Property 'load' does not exist on type TypeScript?

  29. 29

    Typescript property does not exist on type 'ElementFinder'

HotTag

Archive