Skip to content

TSPD make use of alloy #7083

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 32 commits into from
May 2, 2025
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
af48d1c
basic
timotheeguerin Apr 18, 2025
673cb01
target
timotheeguerin Apr 18, 2025
23356cd
Merge branch 'main' of https://github.com/Microsoft/typespec into tsp…
timotheeguerin Apr 18, 2025
7a05eba
render most things
timotheeguerin Apr 18, 2025
08f660e
local types
timotheeguerin Apr 21, 2025
aecff09
More to alloy
timotheeguerin Apr 22, 2025
2adaa84
tweaks
timotheeguerin Apr 22, 2025
cd0e3cf
Merge branch 'main' of https://github.com/Microsoft/typespec into tsp…
timotheeguerin May 1, 2025
6363606
fix
timotheeguerin May 1, 2025
f52bbdc
generate indexer
timotheeguerin May 1, 2025
95d7043
Create tspd-alloy-2025-4-1-18-13-7.md
timotheeguerin May 1, 2025
5aa11f0
fix union
timotheeguerin May 1, 2025
75150d7
Merge branch 'tspd-alloy' of https://github.com/timotheeguerin/typesp…
timotheeguerin May 1, 2025
7d3d9b3
fixes
timotheeguerin May 1, 2025
c89ef84
Merge branch 'main' of https://github.com/Microsoft/typespec into tsp…
timotheeguerin May 1, 2025
2b1d6bb
.
timotheeguerin May 1, 2025
38babfd
fix
timotheeguerin May 2, 2025
b05015e
update tests
timotheeguerin May 2, 2025
a7f817c
.
timotheeguerin May 2, 2025
f6abbc1
Parity
timotheeguerin May 2, 2025
b253507
Better comment
timotheeguerin May 2, 2025
8047dfd
fix vitest
timotheeguerin May 2, 2025
2400d5d
Create tspd-alloy-2025-4-2-2-58-14.md
timotheeguerin May 2, 2025
f1749f5
fix
timotheeguerin May 2, 2025
5533969
.
timotheeguerin May 2, 2025
cbb4161
.
timotheeguerin May 2, 2025
50f8f6f
.
timotheeguerin May 2, 2025
dee0a77
format
timotheeguerin May 2, 2025
ea846b1
fixes
timotheeguerin May 2, 2025
af6e3cb
more
timotheeguerin May 2, 2025
03d7419
remove commented code
timotheeguerin May 2, 2025
48052a1
simplify
timotheeguerin May 2, 2025
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
8 changes: 8 additions & 0 deletions .chronus/changes/tspd-alloy-2025-4-1-18-13-7.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking
changeKind: feature
packages:
- "@typespec/tspd"
---

Migrate internal decorator signature generation to alloy
20 changes: 20 additions & 0 deletions .chronus/changes/tspd-alloy-2025-4-2-2-58-14.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking
changeKind: internal
packages:
- "@typespec/compiler"
- "@typespec/events"
- "@typespec/http"
- "@typespec/json-schema"
- "@typespec/openapi"
- "@typespec/openapi3"
- "@typespec/protobuf"
- "@typespec/rest"
- "@typespec/spector"
- "@typespec/sse"
- "@typespec/streams"
- "@typespec/versioning"
- "@typespec/xml"
---

Update to the generated tspd decorator test
1 change: 1 addition & 0 deletions .chronus/changes/upgrade-alloy-12-2025-3-30-17-41-55.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ packages:
---

Upgrade to alloy 15

Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
/** An error here would mean that the decorator is not exported or doesn't have the right name. */
// An error in the imports would mean that the decorator is not exported or
// doesn't have the right name.

import { $decorators } from "../src/index.js";
import type { TypeSpecPrototypesDecorators } from "./TypeSpec.Prototypes.js";
/** An error here would mean that the exported decorator is not using the same signature. Make sure to have export const $decName: DecNameDecorator = (...) => ... */

/**
* An error here would mean that the exported decorator is not using the same signature. Make sure to have export const $decName: DecNameDecorator = (...) => ...
*/
const _: TypeSpecPrototypesDecorators = $decorators["TypeSpec.Prototypes"];
9 changes: 7 additions & 2 deletions packages/compiler/generated-defs/TypeSpec.ts-test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
/** An error here would mean that the decorator is not exported or doesn't have the right name. */
// An error in the imports would mean that the decorator is not exported or
// doesn't have the right name.

import { $decorators } from "../src/index.js";
import type { TypeSpecDecorators } from "./TypeSpec.js";
/** An error here would mean that the exported decorator is not using the same signature. Make sure to have export const $decName: DecNameDecorator = (...) => ... */

/**
* An error here would mean that the exported decorator is not using the same signature. Make sure to have export const $decName: DecNameDecorator = (...) => ...
*/
const _: TypeSpecDecorators = $decorators["TypeSpec"];
9 changes: 7 additions & 2 deletions packages/events/generated-defs/TypeSpec.Events.ts-test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
/** An error here would mean that the decorator is not exported or doesn't have the right name. */
// An error in the imports would mean that the decorator is not exported or
// doesn't have the right name.

import { $decorators } from "@typespec/events";
import type { TypeSpecEventsDecorators } from "./TypeSpec.Events.js";
/** An error here would mean that the exported decorator is not using the same signature. Make sure to have export const $decName: DecNameDecorator = (...) => ... */

/**
* An error here would mean that the exported decorator is not using the same signature. Make sure to have export const $decName: DecNameDecorator = (...) => ...
*/
const _: TypeSpecEventsDecorators = $decorators["TypeSpec.Events"];
9 changes: 7 additions & 2 deletions packages/http/generated-defs/TypeSpec.Http.ts-test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
/** An error here would mean that the decorator is not exported or doesn't have the right name. */
// An error in the imports would mean that the decorator is not exported or
// doesn't have the right name.

import { $decorators } from "@typespec/http";
import type { TypeSpecHttpDecorators } from "./TypeSpec.Http.js";
/** An error here would mean that the exported decorator is not using the same signature. Make sure to have export const $decName: DecNameDecorator = (...) => ... */

/**
* An error here would mean that the exported decorator is not using the same signature. Make sure to have export const $decName: DecNameDecorator = (...) => ...
*/
const _: TypeSpecHttpDecorators = $decorators["TypeSpec.Http"];
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
/** An error here would mean that the decorator is not exported or doesn't have the right name. */
// An error in the imports would mean that the decorator is not exported or
// doesn't have the right name.

import { $decorators } from "@typespec/json-schema";
import type { TypeSpecJsonSchemaDecorators } from "./TypeSpec.JsonSchema.js";
/** An error here would mean that the exported decorator is not using the same signature. Make sure to have export const $decName: DecNameDecorator = (...) => ... */

/**
* An error here would mean that the exported decorator is not using the same signature. Make sure to have export const $decName: DecNameDecorator = (...) => ...
*/
const _: TypeSpecJsonSchemaDecorators = $decorators["TypeSpec.JsonSchema"];
9 changes: 7 additions & 2 deletions packages/openapi/generated-defs/TypeSpec.OpenAPI.ts-test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
/** An error here would mean that the decorator is not exported or doesn't have the right name. */
// An error in the imports would mean that the decorator is not exported or
// doesn't have the right name.

import { $decorators } from "@typespec/openapi";
import type { TypeSpecOpenAPIDecorators } from "./TypeSpec.OpenAPI.js";
/** An error here would mean that the exported decorator is not using the same signature. Make sure to have export const $decName: DecNameDecorator = (...) => ... */

/**
* An error here would mean that the exported decorator is not using the same signature. Make sure to have export const $decName: DecNameDecorator = (...) => ...
*/
const _: TypeSpecOpenAPIDecorators = $decorators["TypeSpec.OpenAPI"];
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
/** An error here would mean that the decorator is not exported or doesn't have the right name. */
// An error in the imports would mean that the decorator is not exported or
// doesn't have the right name.

import { $decorators } from "@typespec/openapi3";
import type { TypeSpecOpenAPIDecorators } from "./TypeSpec.OpenAPI.js";
/** An error here would mean that the exported decorator is not using the same signature. Make sure to have export const $decName: DecNameDecorator = (...) => ... */

/**
* An error here would mean that the exported decorator is not using the same signature. Make sure to have export const $decName: DecNameDecorator = (...) => ...
*/
const _: TypeSpecOpenAPIDecorators = $decorators["TypeSpec.OpenAPI"];
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
/** An error here would mean that the decorator is not exported or doesn't have the right name. */
// An error in the imports would mean that the decorator is not exported or
// doesn't have the right name.

import { $decorators } from "@typespec/protobuf";
import type { TypeSpecProtobufDecorators } from "./TypeSpec.Protobuf.js";
/** An error here would mean that the exported decorator is not using the same signature. Make sure to have export const $decName: DecNameDecorator = (...) => ... */

/**
* An error here would mean that the exported decorator is not using the same signature. Make sure to have export const $decName: DecNameDecorator = (...) => ...
*/
const _: TypeSpecProtobufDecorators = $decorators["TypeSpec.Protobuf"];
9 changes: 7 additions & 2 deletions packages/rest/generated-defs/TypeSpec.Rest.ts-test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
/** An error here would mean that the decorator is not exported or doesn't have the right name. */
// An error in the imports would mean that the decorator is not exported or
// doesn't have the right name.

import { $decorators } from "@typespec/rest";
import type { TypeSpecRestDecorators } from "./TypeSpec.Rest.js";
/** An error here would mean that the exported decorator is not using the same signature. Make sure to have export const $decName: DecNameDecorator = (...) => ... */

/**
* An error here would mean that the exported decorator is not using the same signature. Make sure to have export const $decName: DecNameDecorator = (...) => ...
*/
const _: TypeSpecRestDecorators = $decorators["TypeSpec.Rest"];
9 changes: 7 additions & 2 deletions packages/spector/generated-defs/TypeSpec.Spector.ts-test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
/** An error here would mean that the decorator is not exported or doesn't have the right name. */
// An error in the imports would mean that the decorator is not exported or
// doesn't have the right name.

import { $decorators } from "@typespec/spector";
import type { TypeSpecSpectorDecorators } from "./TypeSpec.Spector.js";
/** An error here would mean that the exported decorator is not using the same signature. Make sure to have export const $decName: DecNameDecorator = (...) => ... */

/**
* An error here would mean that the exported decorator is not using the same signature. Make sure to have export const $decName: DecNameDecorator = (...) => ...
*/
const _: TypeSpecSpectorDecorators = $decorators["TypeSpec.Spector"];
9 changes: 7 additions & 2 deletions packages/sse/generated-defs/TypeSpec.SSE.ts-test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
/** An error here would mean that the decorator is not exported or doesn't have the right name. */
// An error in the imports would mean that the decorator is not exported or
// doesn't have the right name.

import { $decorators } from "@typespec/sse";
import type { TypeSpecSSEDecorators } from "./TypeSpec.SSE.js";
/** An error here would mean that the exported decorator is not using the same signature. Make sure to have export const $decName: DecNameDecorator = (...) => ... */

/**
* An error here would mean that the exported decorator is not using the same signature. Make sure to have export const $decName: DecNameDecorator = (...) => ...
*/
const _: TypeSpecSSEDecorators = $decorators["TypeSpec.SSE"];
9 changes: 7 additions & 2 deletions packages/streams/generated-defs/TypeSpec.Streams.ts-test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
/** An error here would mean that the decorator is not exported or doesn't have the right name. */
// An error in the imports would mean that the decorator is not exported or
// doesn't have the right name.

import { $decorators } from "@typespec/streams";
import type { TypeSpecStreamsDecorators } from "./TypeSpec.Streams.js";
/** An error here would mean that the exported decorator is not using the same signature. Make sure to have export const $decName: DecNameDecorator = (...) => ... */

/**
* An error here would mean that the exported decorator is not using the same signature. Make sure to have export const $decName: DecNameDecorator = (...) => ...
*/
const _: TypeSpecStreamsDecorators = $decorators["TypeSpec.Streams"];
8 changes: 6 additions & 2 deletions packages/tspd/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
},
"scripts": {
"clean": "rimraf ./dist ./temp",
"build": "tsc -p .",
"watch": "tsc -p . --watch",
"build": "alloy build",
"watch": "alloy build --watch",
"test": "vitest run",
"test:watch": "vitest --watch",
"test:ui": "vitest --ui",
Expand All @@ -55,6 +55,8 @@
"!dist/test/**"
],
"dependencies": {
"@alloy-js/core": "^0.15.0",
"@alloy-js/typescript": "^0.15.0",
"@typespec/compiler": "workspace:^",
"picocolors": "~1.1.1",
"prettier": "~3.5.3",
Expand All @@ -64,6 +66,8 @@
"typedoc-plugin-markdown": "^4.5.2"
},
"devDependencies": {
"@alloy-js/cli": "^0.15.0",
"@alloy-js/rollup-plugin": "^0.1.0",
"@types/node": "~22.13.11",
"@types/yargs": "~17.0.33",
"@typespec/compiler": "workspace:^",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import * as ay from "@alloy-js/core";
import * as ts from "@alloy-js/typescript";

export interface DecoratorSignatureTests {
namespaceName: string;
dollarDecoratorRefKey: ay.Refkey;
dollarDecoratorsTypeRefKey: ay.Refkey;
}

export function DecoratorSignatureTests({
namespaceName,
dollarDecoratorRefKey,
dollarDecoratorsTypeRefKey,
}: Readonly<DecoratorSignatureTests>) {
return (
<>
<hbr />
<hbr />
<ts.VarDeclaration
name="_"
type={dollarDecoratorsTypeRefKey}
doc="An error here would mean that the exported decorator is not using the same signature. Make sure to have export const $decName: DecNameDecorator = (...) => ..."
>
{dollarDecoratorRefKey}
{`["${namespaceName}"]`}
</ts.VarDeclaration>
</>
);
}
Loading
Loading