`Inflight<T>` and `Preflight<T>` type modifiers
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 5.4k
- Forks
- 215
- Avg merge
- 2h 9m
- Merged PRs (30d)
- 27
Description
Feature Spec
Wing now includes Inflight<T> and Preflight<T> type modifiers, which allow the user to filter inflight and preflight methods from a type.
By using Inflight<T> on a type T, all preflight properties will be filtered out from T. The same happens with Preflight<T>, where all inflight properties will be filtered out from T.
It can be used as follows:
bring cloud;
// Our bucket client doesn't require any preflight access to the bucket.
class MyBucketClient {
bucket: Inflight<cloud.Bucket>;
init(bucket: Inflight<cloud.Bucket>) {
// During preflight phase, `bucket` is like an empty object.
this.bucket = bucket;
}
pub inflight putFile(key: str, contents: str) {
return this.bucket.put(key, contents);
}
}
let bucket = new cloud.Bucket();
// Since `cloud.Bucket` is a superset of `Inflight<cloud.Bucket>`, it can be automatically casted.
let client = new MyBucketClient(bucket);
Use Cases
As a developer, sometimes we want to be more explicit of the properties we need from an instance.
For example, it's useful if we're implementing a custom Bucket client that doesn't require any kind of preflight access to a bucket (which is considered elevated permissions, in a way).
Implementation Notes
No response
Component
Language Design
Community Notes
- Please vote by adding a 👍 reaction to the issue to help us prioritize.
- If you are interested to work on this issue, please leave a comment.
- If this issue is labeled needs-discussion, it means the spec has not been finalized yet. Please reach out on the #dev channel in the Wing Slack.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Feature Spec and the language-design discussion; no source file or test entry point is named. Confirm the filtering and automatic-cast behavior for Inflight and Preflight, then define completion through implementation and tests covering the examples in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100