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

`.call` selects the wrong overload for `String.prototype.replace` #29789

ljharb opened this Issue Feb 7, 2019 · 1 comment


None yet
2 participants
Copy link

ljharb commented Feb 7, 2019

TypeScript Version: v3.3.1 and v3.4.0-dev.20190206

Search Terms: call replace overload

    'one string',
    'two string', // this line errors

It's worth noting that this is in a JS file, not a TS file, but I'm using allowJs and checkJs.

Expected behavior:
No error.

Actual behavior:
errors with error TS2345: Argument of type '"two string"' is not assignable to parameter of type '(substring: string, ...args: any[]) => string'

Playground Link:'one%20string'%2C%0D%0A%20%20%20%20%2Fa%2Fg%2C%0D%0A%20%20%20%20'two%20string'%2C%0D%0A)%3B but the error doesn't seem to show up there.

Related Issues: no


This comment has been minimized.

Copy link

RyanCavanaugh commented Feb 14, 2019

The additional overload in lib.es2015.symbol.wellknown needs to be a full union with the regular overload's parameters so that when .call finds it, the regular invocations are still OK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment