-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
ThisType
should use the intrinsic
keyword
#46836
Comments
Ironically |
from typing import Union, NoReturn
NoReturn2 = Union[None]
foo: NoReturn
foo2: NoReturn2
bar: int = foo # no error
bar2: int = foo2 # error: Incompatible types in assignment (expression has type "None", variable has type "int") and this is what i mean by secret intrinsic behavior. interface Foo {
a: () => void
foo: number
}
interface Bar {
a: () => void
bar: number
}
interface ThisType2<T> { }
type Baz = Foo & ThisType<Bar>
type Baz2 = Foo & ThisType2<Bar>
const foo: Baz = {
foo: 1,
a() {
this.bar //no error
}
}
const foo2: Baz2 = {
foo: 1,
a() {
this.bar //Property 'bar' does not exist on type 'Foo & ThisType2<Bar>'.(2339)
}
} i thought maybe |
Python type machinery (like And the So despite how it might read, |
I don't think this would be problematic, but it seems like the easier fix would be to just put a comment above the declaration, since neither declaration form is going to tell you what's going on. Why is everyone talking about Python unions? π |
Because python's typing is cringe, not based. And this particular definition looks like something straight outta python |
I guess It's just a very small thing that can but not must be done. |
Suggestion
π Search Terms
thistype intrinsic
β Viability Checklist
My suggestion meets these guidelines:
β Suggestion
ThisType
is quite confusing in that it appears to do nothing when you go to its definition:but it actually has secret intrinsic functionality? so imo it should use the
intrinsic
keyword:or better yet, why not implement it in the language?
(though that would probably break existing code)
motivation
it's misleading in a language when a symbol has a "fake" implementation you can look at, but its behavior is actually defined intrinsically somewhere else. for example, the
NoReturn
type in python:this is as non-sensical as its typescript equivalent:
Union[None]
has nothing to do withNoReturn
. its behavior is actually intrinsically defined in type checkers such as mypy. ifnever
had a fake definition like this, it would be extremely confusing and it would blur the lines between what's intrinsic and what isn't.The text was updated successfully, but these errors were encountered: