Revisit `as "id"` syntax / "as" keyword is confusing

Open
#4,604 40 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
20/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
typescript
Domain
compilers

Research direction

No files, tests, or entry points are named in the issue. First resolve whether the identifier syntax should use is or an initializer id parameter, then identify the compiler and preflight-class tests that define the current as "id" behavior.

Written by the indexing model from the issue text.

Description

✨ enhancement 📐 language-design 🛠️ compiler needs-discussion

We want to use as for casting, so let's revisit the way we specify an identifier for preflight objects.

One option is to replace the current usage with is:

new Bucket() is "myBucket";
new Bucket() is "yourBucket";

Another alternative is to add a synthetic keyword optional parameter called id to every preflight class initializer and plug it in:

new cloud.Bucket(); // defaults to "cloud.Bucket"

new cloud.Bucket(id: "my-bucket");

See below for some discussion.

Thoughts?

Dominant language
TypeScript
Stars
5.4k
Forks
215
Avg merge
2h 9m
Merged PRs (30d)
27

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from winglang/wing

All issues in winglang/wing

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.