microsoft / microsoft/typespec
[Bug]: Typekits create unfinished types
- Dominant language
- Java
- Stars
- 5.9k
- Forks
- 394
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 104
Description
### Describe the bug
Some typekits (at least `model.create` and `modelProperty.create` from my testing) return _unfinished_ types.
Very bad and difficult to debug things can happen if you forget to finish the Type yourself with `program.finishType`: unfinished types can be passed back into the checker resulting in decorators not running, etc. because the checker believes the types aren't done, but they will _never_ be done unless you manually call `finishType`.
This has bitten me several times. TKs should always return fully checked (finished) instances.
### Reproduction
```ts
$(program).modelProperty.create({
name: "foo",
type: $(program).builtin.string
}).isFinished;
// false
```
### Checklist
- [x] Follow our [Code of Conduct](https://github.com/microsoft/typespec/blob/main/CODE_OF_CONDUCT.md)
- [x] Check that there isn't already an issue that request the same bug to avoid creating a duplicate.
- [x] Check that this is a concrete bug. For Q&A open a [GitHub Discussion](https://github.com/Microsoft/typespec/discussions).
- [x] The provided reproduction is a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) of the bug.
Contributor guide
Assessment
This issue has not been assessed yet.