-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Add ambient $app
types
#917
Conversation
This adds ambient type definitions for `$app/..` imports. This removes the need for a funky tsconfig referencing stuff from the generated code. Another benefit is the better type definitions and proper documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this generally looks good to me
@@ -1,3 +1,4 @@ | |||
import './types.ambient'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand what "ambient" means here. It means the types are just defined in a .d.ts
file? But aren't the types in this file also ambient types?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I adopted the word "ambient" since the official TS docs also use it when declaring modules: https://www.typescriptlang.org/docs/handbook/modules.html#ambient-modules
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not quite following why the types are split into two files and how it's decided what is in each file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything in ambient needs to be in its own file because this file cannot have top level imports or it no longer works (this is how ts works, don't ask me why). The split between internal and public - I don't know.
This adds ambient type definitions for
$app/..
imports. This removes the need for a funky tsconfig referencing stuff from the generated code. Another benefit is the better type definitions and proper documentation.I also connected the type definitions in the JS files to that ambient definition, which uncovered a small inconsistency in the JS typings and moved a type definition into the public types because .. well, they are - we really need to be extra careful here to always keep types up to date if they are defined "by hand".