microsoft / microsoft/typespec
[Feature] Improve PickProperties type-safety.
- Dominant language
- Java
- Stars
- 5.9k
- Forks
- 394
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 104
Description
### PickProperties
At this moment the [PickProperties](https://typespec.io/docs/standard-library/built-in-data-types#PickProperties) data type lacks any form of type-safety for its keys. It is possible to define keys that don't exist on the source model and the IDE doesn't suggest any of the picked keys. I would expect the behaviour to be the same as TypeScript [Pick](https://www.typescriptlang.org/docs/handbook/utility-types.html#picktype-keys).
[Playground](https://typespec.io/playground?c=bW9kZWwgQSB7CiAgZmllbGRfb25lOiBzdHJpbmc7yRV0d286IG51bWVyaWPLFmhyZcktW107Cn0KCi8vIFR5cG8gZm9yyjwgaXMgbm90IGNhdWdodMQkS2V5IGFiY2TEGmFsbG93ZWTEF05vIGNvZGUgc3VnZ2VzdGlvbsVJdGhlIHBpY2tlZCBrZXlzIHdoZW4gZWRpdGluZyDmAMNCLgrHCSBleHRlbmRzIFBpY2tQcm9wZXJ0aWVzPEEsICLpAOMiIHzIDnR3d2%2FFD%2BQAkCI%2B5AEKYW5vdGhlcl%2FFIeoBDn0%3D&e=%40typespec%2Fopenapi3&options=%7B%7D)
### Checklist
- [X] Follow our [Code of Conduct](https://github.com/microsoft/typespec/blob/main/CODE_OF_CONDUCT.md)
- [X] Read the [docs](https://typespec.io/docs/).
- [X] Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
Contributor guide
Assessment
This issue has not been assessed yet.