Skip to content
Merged
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
10 changes: 10 additions & 0 deletions .chronus/changes/alloy-0.22-2025-11-12-13-21-52.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
changeKind: dependencies
packages:
- "@typespec/emitter-framework"
- "@typespec/http-client-js"
- "@typespec/http-client"
- "@typespec/tspd"
---

Update to alloy 0.22
12 changes: 6 additions & 6 deletions packages/emitter-framework/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,16 @@
"license": "MIT",
"description": "",
"peerDependencies": {
"@alloy-js/core": "^0.21.0",
"@alloy-js/csharp": "^0.21.0",
"@alloy-js/typescript": "^0.21.0",
"@alloy-js/core": "^0.22.0",
"@alloy-js/csharp": "^0.22.0",
"@alloy-js/typescript": "^0.22.0",
"@typespec/compiler": "workspace:^"
},
"devDependencies": {
"@alloy-js/cli": "^0.21.0",
"@alloy-js/core": "^0.21.0",
"@alloy-js/cli": "^0.22.0",
"@alloy-js/core": "^0.22.0",
"@alloy-js/rollup-plugin": "^0.1.0",
"@alloy-js/typescript": "^0.21.0",
"@alloy-js/typescript": "^0.22.0",
"@typespec/compiler": "workspace:^",
"concurrently": "^9.1.2",
"pathe": "^2.0.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ it("renders an empty class declaration", async () => {
<ClassDeclaration type={TestModel} />
</Wrapper>,
).toRenderTo(`
class TestModel
{

}
class TestModel {}
`);
});

Expand Down Expand Up @@ -88,14 +85,8 @@ it("renders a class declaration with properties using component override", async
</TestClientOverrides>
</Wrapper>,
).toRenderTo(d`
class Foo
{

}
class Bar
{

}
class Foo {}
class Bar {}
class TestModel
{
public required string Prop1 { get; set; }
Expand Down Expand Up @@ -150,10 +141,7 @@ it("can override class name", async () => {
<ClassDeclaration type={TestModel} name="CustomClassName" />
</Wrapper>,
).toRenderTo(`
class CustomClassName
{

}
class CustomClassName {}
`);
});

Expand All @@ -168,10 +156,7 @@ it("renders a class with access modifiers", async () => {
<ClassDeclaration type={TestModel} protected />
</Wrapper>,
).toRenderTo(`
protected class TestModel
{

}
protected class TestModel {}
`);
});

Expand All @@ -187,10 +172,7 @@ describe("from an interface", () => {
<ClassDeclaration type={TestInterface} />
</Wrapper>,
).toRenderTo(`
class TestInterface
{

}
class TestInterface {}
`);
});

Expand Down Expand Up @@ -229,10 +211,7 @@ it("renders a class with model members", async () => {
<ClassDeclaration type={TestModel} />
</Wrapper>,
).toRenderTo(`
class TestReference
{

}
class TestReference {}
class TestModel
{
public required TestReference Prop1 { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,7 @@ it("renders an empty enum declaration", async () => {
<EnumDeclaration type={TestEnum} />
</Wrapper>,
).toRenderTo(`
enum TestEnum
{

}
enum TestEnum {}
`);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ it("Resolve custom converter", async () => {
[JsonConverter(typeof(FakeJsonConverter))]
public required string Prop1 { get; set; }


internal sealed class FakeJsonConverter : JsonConverter<string>
{
public override string Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,6 @@ describe("jsonAttributes", () => {
[JsonConverter(typeof(TimeSpanIso8601JsonConverter))]
public required TimeSpan Prop3 { get; set; }


// JsonConverter wont work as nested class, but good enough for test to verify the generated code.
internal sealed class TimeSpanSecondsInt32JsonConverter : JsonConverter<TimeSpan>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,7 @@ describe("Record map to IDictionary", () => {
<TypeExpression type={test.type} />
</Wrapper>,
).toRenderTo(`
class Pet
{

}
class Pet {}
IDictionary<string, Pet>
`);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,17 +213,15 @@ describe("Typescript Interface", () => {
</SourceFile>
</Output>,
).toRenderTo(`
export interface Foo extends Array<string> {

}`);
export interface Foo extends Array<string> {}`);
});

it("creates an interface for a model that 'is' a record ", async () => {
const program = await getProgram(`
namespace DemoService;

model Foo is Record<string>;
`);
`);

const [namespace] = program.resolveTypeReference("DemoService");
const models = (namespace as Namespace).models;
Expand Down Expand Up @@ -421,9 +419,7 @@ describe("Typescript Interface", () => {
</SourceFile>
</Output>,
).toRenderTo(`
export interface Widget {

}`);
export interface Widget {}`);
});

it("can override interface name", async () => {
Expand Down
6 changes: 3 additions & 3 deletions packages/http-client-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@
"@typespec/rest": "workspace:^"
},
"dependencies": {
"@alloy-js/core": "^0.21.0",
"@alloy-js/typescript": "^0.21.0",
"@alloy-js/core": "^0.22.0",
"@alloy-js/typescript": "^0.22.0",
"@typespec/emitter-framework": "workspace:^",
"@typespec/http-client": "workspace:^",
"prettier": "~3.6.2"
},
"devDependencies": {
"@alloy-js/cli": "^0.21.0",
"@alloy-js/cli": "^0.22.0",
"@alloy-js/rollup-plugin": "^0.1.0",
"@types/yargs": "~17.0.33",
"@typespec/http": "workspace:^",
Expand Down
3 changes: 2 additions & 1 deletion packages/http-client-js/src/components/http-request.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ export function HttpRequest(props: HttpRequestProps) {
await client.pathUnchecked(${(<Reference refkey={operationUrlRefkey} />)}).${verb}(${(<Reference refkey={requestOptionsVarRefkey} />)})
`}
</ts.VarDeclaration>
<hbr />
</StatementList>
<hbr />
<hbr />
{code`
if (typeof options?.operationOptions?.onResponse === "function") {
options?.operationOptions?.onResponse(response);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ The client signature should include a positional parameter for credential of typ
```ts src/testClient.ts class TestClient
export class TestClient {
#context: TestClientContext;

constructor(endpoint: string, credential: BasicCredential, options?: TestClientOptions) {
this.#context = createTestClientContext(endpoint, credential, options);
}
Expand Down
1 change: 0 additions & 1 deletion packages/http-client-js/test/scenarios/auth/bearer.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ The client signature should include a positional parameter for credential of typ
```ts src/testClient.ts class TestClient
export class TestClient {
#context: TestClientContext;

constructor(endpoint: string, credential: BasicCredential, options?: TestClientOptions) {
this.#context = createTestClientContext(endpoint, credential, options);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ TODO: Revisit if we need additional types since it will be difficult at runtime
```ts src/testClient.ts class TestClient
export class TestClient {
#context: TestClientContext;

constructor(
endpoint: string,
credential: BearerTokenCredential | ApiKeyCredential,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ The client signature should include a positional parameter for credential of typ
```ts src/testClient.ts class TestClient
export class TestClient {
#context: TestClientContext;

constructor(endpoint: string, credential: ApiKeyCredential, options?: TestClientOptions) {
this.#context = createTestClientContext(endpoint, credential, options);
}
Expand Down
1 change: 0 additions & 1 deletion packages/http-client-js/test/scenarios/auth/oauth2.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ The client signature should include a positional parameter for credential of typ
```ts src/testClient.ts class TestClient
export class TestClient {
#context: TestClientContext;

constructor(
endpoint: string,
credential: OAuth2TokenCredential<ClientCredentialsFlow>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ The subclient is not a child of the TestClient because they have different param
```ts src/testClient.ts class TestClient
export class TestClient {
#context: TestClientContext;

constructor(endpoint: string, credential: BasicCredential, options?: TestClientOptions) {
this.#context = createTestClientContext(endpoint, credential, options);
}
Expand All @@ -49,7 +48,6 @@ The sub client shouldn't take a credential
```ts src/testClient.ts class SubClient
export class SubClient {
#context: SubClientContext;

constructor(endpoint: string, options?: SubClientOptions) {
this.#context = createSubClientContext(endpoint, options);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ The client should match the last namespace.
```ts src/bazClient.ts class BazClient
export class BazClient {
#context: BazClientContext;

constructor(endpoint: string, options?: BazClientOptions) {
this.#context = createBazClientContext(endpoint, options);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ It should generate a client for the Global Namespace with a single operation `fo
```ts src/client.ts class Client
export class Client {
#context: ClientContext;

constructor(endpoint: string, options?: ClientOptions) {
this.#context = createClientContext(endpoint, options);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import { get, type GetOptions } from "./api/fooClientOperations.js";

export class FooClient {
#context: FooClientContext;

constructor(endpoint: string, options?: FooClientOptions) {
this.#context = createFooClientContext(endpoint, options);
}
Expand All @@ -60,7 +59,6 @@ import type { BarItem } from "./models/models.js";

export class BarClient {
#context: BarClientContext;

constructor(endpoint: string, options?: BarClientOptions) {
this.#context = createBarClientContext(endpoint, options);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ export class DemoServiceClient {
}
export class WidgetsClient {
#context: WidgetsClientContext;

constructor(endpoint: string, options?: WidgetsClientOptions) {
this.#context = createWidgetsClientContext(endpoint, options);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import { foo, type FooOptions } from "./api/testClientOperations.js";

export class TestClient {
#context: TestClientContext;

constructor(endpoint: string, options?: TestClientOptions) {
this.#context = createTestClientContext(endpoint, options);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ export interface LinkPageResponse {
```ts src/testClient.ts class TestClient
export class TestClient {
#context: TestClientContext;

constructor(endpoint: string, options?: TestClientOptions) {
this.#context = createTestClientContext(endpoint, options);
}
Expand Down Expand Up @@ -233,7 +232,6 @@ export interface LinkPageResponse {
```ts src/testClient.ts class TestClient
export class TestClient {
#context: TestClientContext;

constructor(endpoint: string, options?: TestClientOptions) {
this.#context = createTestClientContext(endpoint, options);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ It should generate the client class with the read operation that calls the opera
```ts src/demoServiceClient.ts class WidgetsClient
export class WidgetsClient {
#context: WidgetsClientContext;

constructor(endpoint: string, options?: WidgetsClientOptions) {
this.#context = createWidgetsClientContext(endpoint, options);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ export interface CreateOptions extends OperationOptions {
```ts src/testClient.ts class TestClient
export class TestClient {
#context: TestClientContext;

constructor(endpoint: string, options?: TestClientOptions) {
this.#context = createTestClientContext(endpoint, options);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export interface GetOptions extends OperationOptions {
```ts src/testClient.ts class TestClient
export class TestClient {
#context: TestClientContext;

constructor(endpoint: string, options?: TestClientOptions) {
this.#context = createTestClientContext(endpoint, options);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export interface GetOptions extends OperationOptions {
```ts src/testClient.ts class TestClient
export class TestClient {
#context: TestClientContext;

constructor(endpoint: string, options?: TestClientOptions) {
this.#context = createTestClientContext(endpoint, options);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ export interface GetOptions extends OperationOptions {}
```ts src/testClient.ts class TestClient
export class TestClient {
#context: TestClientContext;

constructor(endpoint: string, options?: TestClientOptions) {
this.#context = createTestClientContext(endpoint, options);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ export interface GetOptions extends OperationOptions {}
```ts src/testClient.ts class TestClient
export class TestClient {
#context: TestClientContext;

constructor(endpoint: string, options?: TestClientOptions) {
this.#context = createTestClientContext(endpoint, options);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ export interface GetWithParamsOptions extends OperationOptions {
```ts src/testClient.ts class TestClient
export class TestClient {
#context: TestClientContext;

constructor(endpoint: string, options?: TestClientOptions) {
this.#context = createTestClientContext(endpoint, options);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ export interface GetWithParamsOptions extends OperationOptions {}
```ts src/testClient.ts class TestClient
export class TestClient {
#context: TestClientContext;

constructor(endpoint: string, options?: TestClientOptions) {
this.#context = createTestClientContext(endpoint, options);
}
Expand Down
Loading
Loading