Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .chronus/changes/decl-expr-json-schema-inline-2026-4-18-0-0-1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
changeKind: feature
packages:
- "@typespec/json-schema"
---

Support `model`, `enum`, `union`, and `scalar` declarations used in expression position. Anonymous declaration expressions are inlined, while named ones are hoisted into their own schema.

```tsp
model Foo {
status: enum { active, inactive }; // inlined
unit: scalar extends string; // inlined
inner: model Inner { x: string }; // hoisted as `Inner.json`
}
```
16 changes: 16 additions & 0 deletions .chronus/changes/decl-expr-openapi-inline-2026-4-18-0-0-1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
changeKind: feature
packages:
- "@typespec/openapi"
- "@typespec/openapi3"
---

Support `model`, `enum`, `union`, and `scalar` declarations used in expression position. Anonymous declaration expressions are inlined, while named ones are hoisted into a referenced component.

```tsp
model Foo {
status: enum { active, inactive }; // inlined
unit: scalar extends string; // inlined
inner: model Inner { x: string }; // hoisted as component `Inner`
}
```
7 changes: 7 additions & 0 deletions .chronus/changes/decl-expr-typekit-enum-2026-4-18-0-0-1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: feature
packages:
- "@typespec/compiler"
---

`$.enum.create` now produces an enum expression (`expression: true`) when given an empty `name`, mirroring `$.model.create`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: feature
packages:
- "@typespec/versioning"
---

Validate the variants of a keyword-form union expression (`union { ... }`) used in expression position like the variants of a named union, so versioning incompatibilities on decorated variants are reported.
20 changes: 20 additions & 0 deletions .chronus/changes/declarations-as-expressions-2026-4-18-0-0-0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
changeKind: feature
packages:
- "@typespec/compiler"
---

Allow `model`, `enum`, `union`, and `scalar` declarations to be used as expressions. A declaration used in expression position has its corresponding type marked with `expression: true` and is not registered in the enclosing namespace. It may be named or anonymous (in which case its `name` is `""`).

```tsp
alias Foo = enum {
a,
b,
};

model Bar {
status: enum { active, inactive };
unit: scalar extends string;
inner: model Inner { x: string };
}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: feature
packages:
- "@typespec/html-program-viewer"
---

Display the new `expression` property on `Model`, `Enum`, and `Scalar` types in the program viewer.
Loading
Loading