Skip to content
Open
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: fix
packages:
- "@typespec/emitter-framework"
---

Make language-specific Alloy peer dependencies optional so emitters only need to install the language packages they use, while keeping Alloy core and the TypeSpec compiler required. The TypeScript-specific `Experimental_CustomTypeToProps` type is exported from the TypeScript entry point rather than the root entry point.
17 changes: 17 additions & 0 deletions packages/emitter-framework/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,23 @@
"@alloy-js/typescript": "catalog:",
"@typespec/compiler": "workspace:^"
},
"peerDependenciesMeta": {
"@alloy-js/core": {
"optional": false
},
"@alloy-js/csharp": {
"optional": true
},
"@alloy-js/python": {
"optional": true
},
"@alloy-js/typescript": {
"optional": true
Comment on lines +89 to +90

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot looks like we might need to reorganize somethings to make this work

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved Experimental_CustomTypeToProps to the TypeScript entry point, keeping the root declarations independent of @alloy-js/typescript. Verified with commit 25a0fce7.

},
"@typespec/compiler": {
"optional": false
}
},
Comment on lines +79 to +95
"devDependencies": {
"@alloy-js/cli": "catalog:",
"@alloy-js/core": "catalog:",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
import { type Children, type ComponentDefinition } from "@alloy-js/core";
import type { ObjectPropertyProps, VarDeclarationProps } from "@alloy-js/typescript";
import type {
Enum,
EnumMember,
Model,
ModelProperty,
Scalar,
Type,
Union,
UnionVariant,
} from "@typespec/compiler";
import type { ModelProperty, Type } from "@typespec/compiler";
import { useTsp } from "../../context/index.js";
import { type Experimental_ComponentOverridesConfig, getOverrideComponent } from "./config.js";
import { type ComponentOverridesContext, OverridesContext, useOverrides } from "./context.js";
Comment on lines 1 to 5
Expand All @@ -27,21 +17,6 @@ export interface Experimental_OverrideEmitPropsBase<TCustomType extends Type> {
default: Children;
}

/**
* Maps TypeSpec shapes to the corresponding TypeScript declaration props.
* This mapping is TypeScript-specific; use an explicit declaration props type for other languages.
*/
export type Experimental_CustomTypeToProps<TCustomType extends Type> =
TCustomType extends ModelProperty
? ObjectPropertyProps
: TCustomType extends EnumMember
? {}
: TCustomType extends UnionVariant
? {}
: TCustomType extends Model | Scalar | Union | Enum
? VarDeclarationProps
: VarDeclarationProps | ObjectPropertyProps;

/** Inputs to a reference override, including the property that uses the referenced type when available. */
export interface Experimental_OverrideReferenceProps<
TCustomType extends Type,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import type { ObjectPropertyProps, VarDeclarationProps } from "@alloy-js/typescript";
import type {
Enum,
EnumMember,
Model,
ModelProperty,
Scalar,
Type,
Union,
UnionVariant,
} from "@typespec/compiler";

/** Maps TypeSpec shapes to the corresponding TypeScript declaration props. */
export type Experimental_CustomTypeToProps<TCustomType extends Type> =
TCustomType extends ModelProperty
? ObjectPropertyProps
: TCustomType extends EnumMember
? {}
: TCustomType extends UnionVariant
? {}
Comment on lines +18 to +20
: TCustomType extends Model | Scalar | Union | Enum
? VarDeclarationProps
: VarDeclarationProps | ObjectPropertyProps;
1 change: 1 addition & 0 deletions packages/emitter-framework/src/typescript/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from "./component-overrides.js";
export * from "./components/index.js";
export * from "./utils/index.js";
Loading