-
Notifications
You must be signed in to change notification settings - Fork 39
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
Use unknown
instead of any
#123
Comments
I believe E.g. getGlobal<T>(name: string): T; or even better getGlobal<K extends keyof NodeJS.Global>(name: K): NodeJS.Global[K] I've had vague discussions with @BinaryMuse about writing docs / types in typescript as the source of truth so we can be better with types which would solve this (we would type things correctly instead of using the docs parser). But I don't think we can just replace all On a case-by-case basis we could probably make some things cc @felixrieseberg @bpasero @BinaryMuse You folks may have opinions here |
That's kind of the point. You shouldn't just access properties without asserting the type first. That completely loses the point of types, and can result in runtime errors that are not caught at compile-time.
👍
👍 Much better to generate docs from TS source than the current weird setup of generating types from docs. I guess you mean this: electron/electron#16441?
I can find specific examples where it would be the most beneficial, but honestly, all of it should be |
That PR actually depends on our current TS generation tech. Although a step towards a hopeful TS future it won't change how we generate docs / typings.
I'm on board with Better docs / types is something I'm always interested in and will keep |
One thing I like to use is |
unknown
is the type-safe version ofany
and should be preferred.https://stackoverflow.com/questions/51439843/typescript-3-0-unknown-vs-any
The text was updated successfully, but these errors were encountered: