improve error message when accessing an optional map property
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 5.4k
- Forks
- 215
- Avg merge
- 2h 9m
- Merged PRs (30d)
- 27
Description
Feature Spec
Assuming we have an optional Map, and we want to access one of its properties,
optional_map.get("property") (or even optional_map?.get("property")) will throw the following error: "property access unsupported on type Map?"
this error message might not be clear enough to guide the user on how to fix the error.
(At the end I solved it this way:
let m = optional_map ?? {property: "x"};
m.get("property");
)
Use Cases
accessing a property on an optional map
Implementation Notes
We will also support optional_map?.property in the future
Component
Language Design
Community Note
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.
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
No file, test, or entry point is named. Start by locating the compiler diagnostic for property access on an optional Map, then define a clearer correction-oriented message for the shown access patterns and verify that the optional-map examples produce it.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100