microsoft / microsoft/typespec

Mechanism to pass equivalent of no optional argument explicitly

Open
#1,955 0 comments 0 reactions 0 assignees View on GitHub
design:needed
Dominant language
Java
Stars
5.9k
Forks
394
Avg merge
1d 23h
Merged PRs (30d)
104

Description

Say you have a decorator with two optional string parameters:

`extern dec test(target: unknown, arg1?: string, arg2?: string);`

How do you pass arg2 without passing arg1? `@test(null, "hello")` doesn't compile and shouldn't compile and even if it did, it would be observably different to the JS implementation than the `undefined` value it gets when the optional args are not passed at all. Do we need `undefined` in TypeSpec? I have long hoped we didn't but this seems like a gap.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.