diff --git a/.chronus/changes/copilot-make-alloy-peer-dependencies-optional-2026-10-4-20-9-29.md b/.chronus/changes/copilot-make-alloy-peer-dependencies-optional-2026-10-4-20-9-29.md new file mode 100644 index 00000000000..73179b33da9 --- /dev/null +++ b/.chronus/changes/copilot-make-alloy-peer-dependencies-optional-2026-10-4-20-9-29.md @@ -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. \ No newline at end of file diff --git a/packages/emitter-framework/package.json b/packages/emitter-framework/package.json index ebf96e8acb7..68da1ee1877 100644 --- a/packages/emitter-framework/package.json +++ b/packages/emitter-framework/package.json @@ -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 + }, + "@typespec/compiler": { + "optional": false + } + }, "devDependencies": { "@alloy-js/cli": "catalog:", "@alloy-js/core": "catalog:", diff --git a/packages/emitter-framework/src/core/components/overrides/component-overrides.tsx b/packages/emitter-framework/src/core/components/overrides/component-overrides.tsx index 22316b69a8f..6a713cd6a29 100644 --- a/packages/emitter-framework/src/core/components/overrides/component-overrides.tsx +++ b/packages/emitter-framework/src/core/components/overrides/component-overrides.tsx @@ -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"; @@ -27,21 +17,6 @@ export interface Experimental_OverrideEmitPropsBase { 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 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, diff --git a/packages/emitter-framework/src/typescript/component-overrides.ts b/packages/emitter-framework/src/typescript/component-overrides.ts new file mode 100644 index 00000000000..87b5801ade9 --- /dev/null +++ b/packages/emitter-framework/src/typescript/component-overrides.ts @@ -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 ModelProperty + ? ObjectPropertyProps + : TCustomType extends EnumMember + ? {} + : TCustomType extends UnionVariant + ? {} + : TCustomType extends Model | Scalar | Union | Enum + ? VarDeclarationProps + : VarDeclarationProps | ObjectPropertyProps; diff --git a/packages/emitter-framework/src/typescript/index.ts b/packages/emitter-framework/src/typescript/index.ts index be95a933d22..dd16ac754f1 100644 --- a/packages/emitter-framework/src/typescript/index.ts +++ b/packages/emitter-framework/src/typescript/index.ts @@ -1,2 +1,3 @@ +export * from "./component-overrides.js"; export * from "./components/index.js"; export * from "./utils/index.js";