Skip to content

Commit dd6aad4

Browse files
TSPD make use of alloy (#7083)
This only convert the decorator generation to tspd
1 parent 58f0fee commit dd6aad4

File tree

31 files changed

+838
-437
lines changed

31 files changed

+838
-437
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking
3+
changeKind: feature
4+
packages:
5+
- "@typespec/tspd"
6+
---
7+
8+
Migrate internal decorator signature generation to alloy
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking
3+
changeKind: internal
4+
packages:
5+
- "@typespec/compiler"
6+
- "@typespec/events"
7+
- "@typespec/http"
8+
- "@typespec/json-schema"
9+
- "@typespec/openapi"
10+
- "@typespec/openapi3"
11+
- "@typespec/protobuf"
12+
- "@typespec/rest"
13+
- "@typespec/spector"
14+
- "@typespec/sse"
15+
- "@typespec/streams"
16+
- "@typespec/versioning"
17+
- "@typespec/xml"
18+
---
19+
20+
Update to the generated tspd decorator test

.chronus/changes/upgrade-alloy-12-2025-3-30-17-41-55.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ packages:
88
---
99

1010
Upgrade to alloy 15
11+
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
/** An error here would mean that the decorator is not exported or doesn't have the right name. */
1+
// An error in the imports would mean that the decorator is not exported or
2+
// doesn't have the right name.
3+
24
import { $decorators } from "../src/index.js";
35
import type { TypeSpecPrototypesDecorators } from "./TypeSpec.Prototypes.js";
4-
/** An error here would mean that the exported decorator is not using the same signature. Make sure to have export const $decName: DecNameDecorator = (...) => ... */
6+
7+
/**
8+
* An error here would mean that the exported decorator is not using the same signature. Make sure to have export const $decName: DecNameDecorator = (...) => ...
9+
*/
510
const _: TypeSpecPrototypesDecorators = $decorators["TypeSpec.Prototypes"];
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
/** An error here would mean that the decorator is not exported or doesn't have the right name. */
1+
// An error in the imports would mean that the decorator is not exported or
2+
// doesn't have the right name.
3+
24
import { $decorators } from "../src/index.js";
35
import type { TypeSpecDecorators } from "./TypeSpec.js";
4-
/** An error here would mean that the exported decorator is not using the same signature. Make sure to have export const $decName: DecNameDecorator = (...) => ... */
6+
7+
/**
8+
* An error here would mean that the exported decorator is not using the same signature. Make sure to have export const $decName: DecNameDecorator = (...) => ...
9+
*/
510
const _: TypeSpecDecorators = $decorators["TypeSpec"];
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
/** An error here would mean that the decorator is not exported or doesn't have the right name. */
1+
// An error in the imports would mean that the decorator is not exported or
2+
// doesn't have the right name.
3+
24
import { $decorators } from "@typespec/events";
35
import type { TypeSpecEventsDecorators } from "./TypeSpec.Events.js";
4-
/** An error here would mean that the exported decorator is not using the same signature. Make sure to have export const $decName: DecNameDecorator = (...) => ... */
6+
7+
/**
8+
* An error here would mean that the exported decorator is not using the same signature. Make sure to have export const $decName: DecNameDecorator = (...) => ...
9+
*/
510
const _: TypeSpecEventsDecorators = $decorators["TypeSpec.Events"];

packages/http-client-js/src/components/models.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export function Models(props: ModelsProps) {
1515
const dataTypes = clientLibrary.dataTypes;
1616
return (
1717
<ts.SourceFile path={props.path ?? "models.ts"}>
18-
<For each={dataTypes} joiner={"\n"} hardline>
18+
<For each={dataTypes} hardline>
1919
{(type) => {
2020
if ($.model.is(type) && $.model.isHttpFile(type)) {
2121
return (
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
/** An error here would mean that the decorator is not exported or doesn't have the right name. */
1+
// An error in the imports would mean that the decorator is not exported or
2+
// doesn't have the right name.
3+
24
import { $decorators } from "@typespec/http";
35
import type { TypeSpecHttpDecorators } from "./TypeSpec.Http.js";
4-
/** An error here would mean that the exported decorator is not using the same signature. Make sure to have export const $decName: DecNameDecorator = (...) => ... */
6+
7+
/**
8+
* An error here would mean that the exported decorator is not using the same signature. Make sure to have export const $decName: DecNameDecorator = (...) => ...
9+
*/
510
const _: TypeSpecHttpDecorators = $decorators["TypeSpec.Http"];
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
/** An error here would mean that the decorator is not exported or doesn't have the right name. */
1+
// An error in the imports would mean that the decorator is not exported or
2+
// doesn't have the right name.
3+
24
import { $decorators } from "@typespec/json-schema";
35
import type { TypeSpecJsonSchemaDecorators } from "./TypeSpec.JsonSchema.js";
4-
/** An error here would mean that the exported decorator is not using the same signature. Make sure to have export const $decName: DecNameDecorator = (...) => ... */
6+
7+
/**
8+
* An error here would mean that the exported decorator is not using the same signature. Make sure to have export const $decName: DecNameDecorator = (...) => ...
9+
*/
510
const _: TypeSpecJsonSchemaDecorators = $decorators["TypeSpec.JsonSchema"];
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
/** An error here would mean that the decorator is not exported or doesn't have the right name. */
1+
// An error in the imports would mean that the decorator is not exported or
2+
// doesn't have the right name.
3+
24
import { $decorators } from "@typespec/openapi";
35
import type { TypeSpecOpenAPIDecorators } from "./TypeSpec.OpenAPI.js";
4-
/** An error here would mean that the exported decorator is not using the same signature. Make sure to have export const $decName: DecNameDecorator = (...) => ... */
6+
7+
/**
8+
* An error here would mean that the exported decorator is not using the same signature. Make sure to have export const $decName: DecNameDecorator = (...) => ...
9+
*/
510
const _: TypeSpecOpenAPIDecorators = $decorators["TypeSpec.OpenAPI"];
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
/** An error here would mean that the decorator is not exported or doesn't have the right name. */
1+
// An error in the imports would mean that the decorator is not exported or
2+
// doesn't have the right name.
3+
24
import { $decorators } from "@typespec/openapi3";
35
import type { TypeSpecOpenAPIDecorators } from "./TypeSpec.OpenAPI.js";
4-
/** An error here would mean that the exported decorator is not using the same signature. Make sure to have export const $decName: DecNameDecorator = (...) => ... */
6+
7+
/**
8+
* An error here would mean that the exported decorator is not using the same signature. Make sure to have export const $decName: DecNameDecorator = (...) => ...
9+
*/
510
const _: TypeSpecOpenAPIDecorators = $decorators["TypeSpec.OpenAPI"];
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
/** An error here would mean that the decorator is not exported or doesn't have the right name. */
1+
// An error in the imports would mean that the decorator is not exported or
2+
// doesn't have the right name.
3+
24
import { $decorators } from "@typespec/protobuf";
35
import type { TypeSpecProtobufDecorators } from "./TypeSpec.Protobuf.js";
4-
/** An error here would mean that the exported decorator is not using the same signature. Make sure to have export const $decName: DecNameDecorator = (...) => ... */
6+
7+
/**
8+
* An error here would mean that the exported decorator is not using the same signature. Make sure to have export const $decName: DecNameDecorator = (...) => ...
9+
*/
510
const _: TypeSpecProtobufDecorators = $decorators["TypeSpec.Protobuf"];
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
/** An error here would mean that the decorator is not exported or doesn't have the right name. */
1+
// An error in the imports would mean that the decorator is not exported or
2+
// doesn't have the right name.
3+
24
import { $decorators } from "@typespec/rest";
35
import type { TypeSpecRestDecorators } from "./TypeSpec.Rest.js";
4-
/** An error here would mean that the exported decorator is not using the same signature. Make sure to have export const $decName: DecNameDecorator = (...) => ... */
6+
7+
/**
8+
* An error here would mean that the exported decorator is not using the same signature. Make sure to have export const $decName: DecNameDecorator = (...) => ...
9+
*/
510
const _: TypeSpecRestDecorators = $decorators["TypeSpec.Rest"];
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
/** An error here would mean that the decorator is not exported or doesn't have the right name. */
1+
// An error in the imports would mean that the decorator is not exported or
2+
// doesn't have the right name.
3+
24
import { $decorators } from "@typespec/spector";
35
import type { TypeSpecSpectorDecorators } from "./TypeSpec.Spector.js";
4-
/** An error here would mean that the exported decorator is not using the same signature. Make sure to have export const $decName: DecNameDecorator = (...) => ... */
6+
7+
/**
8+
* An error here would mean that the exported decorator is not using the same signature. Make sure to have export const $decName: DecNameDecorator = (...) => ...
9+
*/
510
const _: TypeSpecSpectorDecorators = $decorators["TypeSpec.Spector"];
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
/** An error here would mean that the decorator is not exported or doesn't have the right name. */
1+
// An error in the imports would mean that the decorator is not exported or
2+
// doesn't have the right name.
3+
24
import { $decorators } from "@typespec/sse";
35
import type { TypeSpecSSEDecorators } from "./TypeSpec.SSE.js";
4-
/** An error here would mean that the exported decorator is not using the same signature. Make sure to have export const $decName: DecNameDecorator = (...) => ... */
6+
7+
/**
8+
* An error here would mean that the exported decorator is not using the same signature. Make sure to have export const $decName: DecNameDecorator = (...) => ...
9+
*/
510
const _: TypeSpecSSEDecorators = $decorators["TypeSpec.SSE"];
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
/** An error here would mean that the decorator is not exported or doesn't have the right name. */
1+
// An error in the imports would mean that the decorator is not exported or
2+
// doesn't have the right name.
3+
24
import { $decorators } from "@typespec/streams";
35
import type { TypeSpecStreamsDecorators } from "./TypeSpec.Streams.js";
4-
/** An error here would mean that the exported decorator is not using the same signature. Make sure to have export const $decName: DecNameDecorator = (...) => ... */
6+
7+
/**
8+
* An error here would mean that the exported decorator is not using the same signature. Make sure to have export const $decName: DecNameDecorator = (...) => ...
9+
*/
510
const _: TypeSpecStreamsDecorators = $decorators["TypeSpec.Streams"];

packages/tspd/package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
},
4141
"scripts": {
4242
"clean": "rimraf ./dist ./temp",
43-
"build": "tsc -p .",
44-
"watch": "tsc -p . --watch",
43+
"build": "alloy build",
44+
"watch": "alloy build --watch",
4545
"test": "vitest run",
4646
"test:watch": "vitest --watch",
4747
"test:ui": "vitest --ui",
@@ -55,6 +55,8 @@
5555
"!dist/test/**"
5656
],
5757
"dependencies": {
58+
"@alloy-js/core": "^0.15.0",
59+
"@alloy-js/typescript": "^0.15.0",
5860
"@typespec/compiler": "workspace:^",
5961
"picocolors": "~1.1.1",
6062
"prettier": "~3.5.3",
@@ -64,6 +66,8 @@
6466
"typedoc-plugin-markdown": "^4.5.2"
6567
},
6668
"devDependencies": {
69+
"@alloy-js/cli": "^0.15.0",
70+
"@alloy-js/rollup-plugin": "^0.1.0",
6771
"@types/node": "~22.13.11",
6872
"@types/yargs": "~17.0.33",
6973
"@typespec/compiler": "workspace:^",
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import * as ay from "@alloy-js/core";
2+
import * as ts from "@alloy-js/typescript";
3+
4+
export interface DecoratorSignatureTests {
5+
namespaceName: string;
6+
dollarDecoratorRefKey: ay.Refkey;
7+
dollarDecoratorsTypeRefKey: ay.Refkey;
8+
}
9+
10+
export function DecoratorSignatureTests({
11+
namespaceName,
12+
dollarDecoratorRefKey,
13+
dollarDecoratorsTypeRefKey,
14+
}: Readonly<DecoratorSignatureTests>) {
15+
return (
16+
<>
17+
<hbr />
18+
<hbr />
19+
<ts.VarDeclaration
20+
name="_"
21+
type={dollarDecoratorsTypeRefKey}
22+
doc="An error here would mean that the exported decorator is not using the same signature. Make sure to have export const $decName: DecNameDecorator = (...) => ..."
23+
>
24+
{dollarDecoratorRefKey}
25+
{`["${namespaceName}"]`}
26+
</ts.VarDeclaration>
27+
</>
28+
);
29+
}

0 commit comments

Comments
 (0)