Definitelytyped: Possible regression in @types/request-promise-native 1.10.12 ?

Created on 30 Jan 2018  ·  3Comments  ·  Source: DefinitelyTyped/DefinitelyTyped

FAO @gustavohenke

I'm using request-promise-native 1.0.5. When I tried using @types/request-promise-native 1.0.12 I saw the following compile error:

Property '[Symbol.toStringTag]' is missing in type 'RequestPromise'.

I think TSC believes request-promise-native is returning a "Promise-like" rather than a Promise.

This issue does not exist with @types/request-promise-native 1.0.10

Most helpful comment

This is correct, request-promise-native does not return a Promise.
Check the PR linked above for a description and links to relevant code.

    const rp = requestPromise.get("http://github.com");
    console.log(typeof rp); // object
    console.log(Object.prototype.toString.call(rp)); // [object Object]
    console.log(rp.toString()); // [object Object]
    console.log(rp.toStringTag); // undefined
    console.log(rp.promise().toString()); // [object Promise]

If you need access to the underlying Promise, use rp.promise().

All 3 comments

Same problem here with request-promise-native 1.0.5. Downgrading typing to 1.0.10 works.

See #23087, cc @mastermatt

This is correct, request-promise-native does not return a Promise.
Check the PR linked above for a description and links to relevant code.

    const rp = requestPromise.get("http://github.com");
    console.log(typeof rp); // object
    console.log(Object.prototype.toString.call(rp)); // [object Object]
    console.log(rp.toString()); // [object Object]
    console.log(rp.toStringTag); // undefined
    console.log(rp.promise().toString()); // [object Promise]

If you need access to the underlying Promise, use rp.promise().

Was this page helpful?
0 / 5 - 0 ratings