Skip to content

unable compile with clear type, got property 'data' does not exist on type 'T'  #31030

@Akimotorakiyu

Description

@Akimotorakiyu

TypeScript Version: 3.4.4

Search Terms:

ReactiveX/rxjs#4718

Code

{
  "scripts": {
    "dev": "ts-node ."
  },
  "dependencies": {
    "axios": "^0.18.0",
    "rxjs": "^6.4.0",
    "ts-node": "^8.1.0",
    "typescript": "^3.4.4"
  }
}
import * as rxjs from "rxjs";
import axios from "axios"

interface res {
    data: any[],
    count: number
}

let promiseSource$ = rxjs.from(axios.get<res>("http://govapi.pinza.com.cn/newsList"))

promiseSource$.subscribe((res) => { console.log(res.data.count) })

Expected behavior:
compiled

the answer
ReactiveX/rxjs#4718 (comment)

It's working in the IDE - TypeScript is inferring the type of data - so the problem is most likely related to the version of TypeScript that you are using with ts-node, etc.

In short, this does not seem to be an issue with RxJS.

Actual behavior:

图片

Related Issues:
ReactiveX/rxjs#4718

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