Skip to content

Typescript 4.4 breaking change affect retry #83

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
chengB12 opened this issue Nov 5, 2021 · 1 comment
Open

Typescript 4.4 breaking change affect retry #83

chengB12 opened this issue Nov 5, 2021 · 1 comment

Comments

@chengB12
Copy link

chengB12 commented Nov 5, 2021

This is doc about typescript 4.4 breaking change:
https://devblogs.microsoft.com/typescript/announcing-typescript-4-4/#more-compliant-indirect-calls-for-imported-functions

for this code

import { timeouts} from 'retry'

console.log(timeouts({
    retries: 5,
}))

typescript will compile it to

"use strict";
exports.__esModule = true;
var retry_1 = require("retry");
console.log((0, retry_1.timeouts)({
    retries: 5
}));

note it is (0, retry_1.timeouts)(...)
and it will have different "this" context

and it will throw error:

**\node_modules\retry\lib\retry.js:34
    timeouts.push(this.createTimeout(i, opts));
                       ^

TypeError: this.createTimeout is not a function
    at exports.timeouts (**\node_modules\retry\lib\retry.js:34:24)
    at Object.<anonymous> (**\test-fail.js:7:34)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:17:47

workaround is use import * as retry from 'retry' instead

laktek added a commit to SeedleFinance/uniswap-v3-pools that referenced this issue Feb 17, 2022
This was to prevent an issue with retry module -
tim-kos/node-retry#83
@leaumar
Copy link

leaumar commented Feb 7, 2023

The umpteenth error blocking us from upgrading/migrating things... Guess p-retry is the next tool we're replacing, since it depends on this and it doesn't seem this lib is actively maintained, this issue being open for a year and change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants