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
typeof
typescript 4.9
Playground link with relevant code
interface Object { pipe<U>(fn: (a: any) => U): U; } Object.prototype.pipe = function <U>(fn: (a: typeof this) => U) { return fn(this); };
errors with
error: TS2304 [ERROR]: Cannot find name 'this'. Object.prototype.pipe = function <U>(fn: (a: typeof this) => U) {
It used to typecheck in earlier versions
The text was updated successfully, but these errors were encountered:
This never actually worked
const m = { foo: 3 }.pipe(j => j.baz); // j: any
I think you want
Object.prototype.pipe = function <U, T>(this: T, fn: (a: T) => U) { return fn(this); };
Sorry, something went wrong.
It works, it seems like you have a typo there, baz instead of foo
Maybe you mean the types not working ?
I can close this, if this is just all correct, I just want to bring to notice that 4.8 it had no error and 4.9 it does
4.9 4.8
It was just a bug that this was allowed in the first place. It doesn't "do" anything without a corresponding this parameter
this
thanks
No branches or pull requests
sigmaSd commentedDec 15, 2022
β’
edited by RyanCavanaugh
Bug Report
typeof
typescript 4.9
Playground link with relevant code
errors with
It used to typecheck in earlier versions
The text was updated successfully, but these errors were encountered: