Skip to content
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

Merged
merged 3 commits into from
Apr 11, 2021
Merged

Add ambient $app types #917

merged 3 commits into from
Apr 11, 2021

Conversation

dummdidumm
Copy link
Member

@dummdidumm dummdidumm commented Apr 7, 2021

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".

Simon Holthausen added 3 commits April 7, 2021 17:41
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.
Copy link
Member

@benmccann benmccann left a 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';
Copy link
Member

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?

Copy link
Member Author

@dummdidumm dummdidumm Apr 10, 2021

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

Copy link
Member

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

Copy link
Member Author

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.

@dummdidumm dummdidumm merged commit 39b6967 into master Apr 11, 2021
@dummdidumm dummdidumm deleted the ambient-types branch April 11, 2021 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants