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
9 changes: 5 additions & 4 deletions .github/skills/csharp-spector-coverage-gaps/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,12 @@ The test directory structure mirrors the spec path with these transformations:
**Namespace pattern**: `TestProjects.Spector.Tests.Http.<PascalCasePath>`

Example mappings:
| Spec path | Test directory | Namespace |
|-----------|---------------|-----------|
| `http/encode/duration` | `Http/Encode/Duration/` | `TestProjects.Spector.Tests.Http.Encode.Duration` |

| Spec path | Test directory | Namespace |
| ------------------------------- | --------------------------------- | ----------------------------------------------------------- |
| `http/encode/duration` | `Http/Encode/Duration/` | `TestProjects.Spector.Tests.Http.Encode.Duration` |
| `http/type/union/discriminated` | `Http/_Type/Union/Discriminated/` | `TestProjects.Spector.Tests.Http._Type.Union.Discriminated` |
| `http/special-words` | `Http/SpecialWords/` | `TestProjects.Spector.Tests.Http.SpecialWords` |
| `http/special-words` | `Http/SpecialWords/` | `TestProjects.Spector.Tests.Http.SpecialWords` |

### Test file template

Expand Down
1 change: 1 addition & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ Your training data may be outdated — these docs match your installed version.

- [@alloy-js/core](./packages/http-server-csharp/node_modules/@alloy-js/core/docs/index.md)
- [@alloy-js/cli](./packages/http-server-csharp/node_modules/@alloy-js/cli/docs/index.md) — Alloy cli for building alloy components

<!-- END:alloy-docs -->
3 changes: 2 additions & 1 deletion eng/common/scripts/labels/policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ export type IsActivitySender = {

export type IsAction = {
isAction: {
action: // Issues
action:
// Issues
| "Opened"
| "Closed"
| "Reopened"
Expand Down
4 changes: 1 addition & 3 deletions packages/asset-emitter/src/builders/object-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ export class ObjectBuilder<T> {

constructor(
initializer:
| Record<string, unknown>
| Placeholder<Record<string, unknown>>
| ObjectBuilder<T> = {},
Record<string, unknown> | Placeholder<Record<string, unknown>> | ObjectBuilder<T> = {},
) {
const copyProperties = (source: Record<string, unknown>) => {
for (const [key, value] of Object.entries(source)) {
Expand Down
8 changes: 1 addition & 7 deletions packages/asset-emitter/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,7 @@ export type AssetTagFactory = {
};

export type TypeSpecDeclaration =
| Model
| Interface
| Union
| Operation
| Enum
| Scalar
| IntrinsicType;
Model | Interface | Union | Operation | Enum | Scalar | IntrinsicType;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I feel like this is a downgrade but there is no flag to control


export interface ContextState {
lexicalContext: Record<string, any>;
Expand Down
8 changes: 4 additions & 4 deletions packages/compiler/src/core/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -355,10 +355,10 @@ export interface Checker {
resolveRelatedSymbols(node: IdentifierNode): Sym[] | undefined;
/** @internal */
resolveCompletions(node: IdentifierNode): Map<string, TypeSpecCompletionItem>;
createType<T extends Type extends any ? CreateTypeProps : never>(
createType<T extends (Type extends any ? CreateTypeProps : never)>(
typeDef: T,
): T & TypePrototype & { isFinished: boolean; readonly entityKind: "Type" };
createAndFinishType<T extends Type extends any ? CreateTypeProps : never>(
createAndFinishType<T extends (Type extends any ? CreateTypeProps : never)>(
typeDef: T,
): T & TypePrototype;
finishType<T extends Type>(typeDef: T): T;
Expand Down Expand Up @@ -7959,7 +7959,7 @@ export function createChecker(program: Program, resolver: NameResolver): Checker

// the types here aren't ideal and could probably be refactored.

function createAndFinishType<T extends Type extends any ? CreateTypeProps : never>(
function createAndFinishType<T extends (Type extends any ? CreateTypeProps : never)>(
typeDef: T,
): T & TypePrototype & { isFinished: boolean; readonly entityKind: "Type" } {
createType(typeDef);
Expand All @@ -7983,7 +7983,7 @@ export function createChecker(program: Program, resolver: NameResolver): Checker
/**
* Given the own-properties of a type, returns a fully-initialized type.
*/
function createType<T extends Type extends any ? CreateTypeProps : never>(
function createType<T extends (Type extends any ? CreateTypeProps : never)>(
typeDef: T,
): T & TypePrototype & { isFinished: boolean; entityKind: "Type" } {
stats.createdTypes++;
Expand Down
3 changes: 1 addition & 2 deletions packages/compiler/src/core/name-resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1079,8 +1079,7 @@ export function createResolver(program: Program): NameResolver {
if (binding) {
if (binding.flags & SymbolFlags.Using && binding.symbolSource) {
const fileNode = getFirstAncestor(node, (n) => n.kind === SyntaxKind.TypeSpecScript) as
| TypeSpecScriptNode
| undefined;
TypeSpecScriptNode | undefined;
if (fileNode) {
usedUsingSym.get(fileNode)?.add(binding.symbolSource) ??
usedUsingSym.set(fileNode, new Set([binding.symbolSource]));
Expand Down
4 changes: 1 addition & 3 deletions packages/compiler/src/core/scanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,7 @@ export type DocToken =
| Token.EndOfFile;

export type StringTemplateToken =
| Token.StringTemplateHead
| Token.StringTemplateMiddle
| Token.StringTemplateTail;
Token.StringTemplateHead | Token.StringTemplateMiddle | Token.StringTemplateTail;

/** @internal */
export const TokenDisplay = getTokenDisplayTable([
Expand Down
19 changes: 3 additions & 16 deletions packages/compiler/src/core/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,7 @@ export interface DecoratorArgument {
* Marshalled value for use in Javascript.
*/
jsValue:
| Type
| Value
| Record<string, unknown>
| unknown[]
| string
| number
| boolean
| Numeric
| null;
Type | Value | Record<string, unknown> | unknown[] | string | number | boolean | Numeric | null;
node?: Node;
}

Expand Down Expand Up @@ -1516,11 +1508,7 @@ export type Expression =
export type ParenthesizedExpression = Expression & { readonly parenthesized: true };

export type ReferenceExpression =
| TypeReferenceNode
| MemberExpressionNode
| IdentifierNode
| VoidKeywordNode
| NeverKeywordNode;
TypeReferenceNode | MemberExpressionNode | IdentifierNode | VoidKeywordNode | NeverKeywordNode;

export interface MemberExpressionNode extends BaseNode {
readonly kind: SyntaxKind.MemberExpression;
Expand Down Expand Up @@ -1555,8 +1543,7 @@ export interface OperationSignatureReferenceNode extends BaseNode {
}

export type OperationSignature =
| OperationSignatureDeclarationNode
| OperationSignatureReferenceNode;
OperationSignatureDeclarationNode | OperationSignatureReferenceNode;

export interface OperationStatementNode extends BaseNode, DeclarationNode, TemplateDeclarationNode {
readonly kind: SyntaxKind.OperationStatement;
Expand Down
4 changes: 1 addition & 3 deletions packages/compiler/src/experimental/mutators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ import { Realm } from "./realm.js";
* @experimental
*/
export type MutatorRecord<T extends Type> =
| MutatorReplaceRecord<T>
| MutatorMutateRecord<T>
| MutatorFn<T>;
MutatorReplaceRecord<T> | MutatorMutateRecord<T> | MutatorFn<T>;

/**
* Common functionality for mutator records.
Expand Down
4 changes: 1 addition & 3 deletions packages/compiler/src/server/serverlib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1588,9 +1588,7 @@ export function createServer(
}

type SignatureHelpNode =
| DecoratorExpressionNode
| AugmentDecoratorStatementNode
| TypeReferenceNode;
DecoratorExpressionNode | AugmentDecoratorStatementNode | TypeReferenceNode;

function getSignatureHelpNodeAtPosition(
script: TypeSpecScriptNode,
Expand Down
8 changes: 2 additions & 6 deletions packages/compiler/src/server/tmlanguage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,12 @@ const anyNumber = `(?:${hexNumber}|${binaryNumber}|${decimalNumber})`;

const expression: IncludeRule = {
key: "expression",
patterns: [
/* placeholder filled later due to cycle*/
],
patterns: [/* placeholder filled later due to cycle*/],
};

const statement: IncludeRule = {
key: "statement",
patterns: [
/*placeholder filled later due to cycle*/
],
patterns: [/*placeholder filled later due to cycle*/],
};

const booleanLiteral: MatchRule = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ export interface MethodPropsWithType extends Omit<py.MethodDeclarationBaseProps,
}

export type MethodProps =
| MethodPropsWithType
| (py.MethodDeclarationBaseProps & { decorators?: Children[] });
MethodPropsWithType | (py.MethodDeclarationBaseProps & { decorators?: Children[] });

/**
* Get the method component based on the resolved method type.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ export interface PydanticClassDeclarationPropsWithType extends Omit<
}

export type PydanticClassDeclarationProps =
| PydanticClassDeclarationPropsWithType
| PydanticClassDeclarationBaseProps;
PydanticClassDeclarationPropsWithType | PydanticClassDeclarationBaseProps;

function isTypedPydanticClassDeclarationProps(
props: PydanticClassDeclarationProps,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ export interface FunctionDeclarationPropsWithType extends Omit<
}

export type FunctionDeclarationProps =
| FunctionDeclarationPropsWithType
| py.FunctionDeclarationProps;
FunctionDeclarationPropsWithType | py.FunctionDeclarationProps;

/**
* A Python function declaration. Pass the `type` prop to create the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ export interface FunctionDeclarationPropsWithType extends Omit<
}

export type FunctionDeclarationProps =
| FunctionDeclarationPropsWithType
| ts.FunctionDeclarationProps;
FunctionDeclarationPropsWithType | ts.FunctionDeclarationProps;

/**
* A TypeScript function declaration. Pass the `type` prop to create the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ export interface TypedInterfaceDeclarationProps extends Omit<ts.InterfaceDeclara
}

export type InterfaceDeclarationProps =
| TypedInterfaceDeclarationProps
| ts.InterfaceDeclarationProps;
TypedInterfaceDeclarationProps | ts.InterfaceDeclarationProps;

export function InterfaceDeclaration(props: InterfaceDeclarationProps) {
const { $ } = useTsp();
Expand Down
10 changes: 2 additions & 8 deletions packages/html-program-viewer/src/react/type-config.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
import type { Entity, Type } from "@typespec/compiler";

export type PropertyRendering<T> =
| { kind: "parent" | "nested-items" | "ref" | "value" | "skip" }
| NestedPropertyRendering<T>;
{ kind: "parent" | "nested-items" | "ref" | "value" | "skip" } | NestedPropertyRendering<T>;
export type PropertyRenderingRaw<T> =
| "parent"
| "nested-items"
| "ref"
| "value"
| "skip"
| NestedPropertyRenderingRaw<T>;
"parent" | "nested-items" | "ref" | "value" | "skip" | NestedPropertyRenderingRaw<T>;

export type PropertiesRenderingRaw<T> = { [K in keyof T]: PropertyRenderingRaw<T[K]> };
export type PropertiesRendering<T> = { [K in keyof T]: PropertyRendering<T[K]> };
Expand Down
13 changes: 4 additions & 9 deletions packages/http-canonicalization/src/operation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,7 @@ export interface CanonicalHttpOperationResponseContent {
}

export type CanonicalHttpPayloadBody =
| CanonicalHttpOperationBody
| CanonicalHttpOperationMultipartBody
| CanonicalHttpOperationFileBody;
CanonicalHttpOperationBody | CanonicalHttpOperationMultipartBody | CanonicalHttpOperationFileBody;

export interface CanonicalHttpOperationBodyBase {
/** Content types. */
Expand Down Expand Up @@ -204,8 +202,7 @@ export interface CanonicalHttpOperationBody
}

export type CanonicalHttpOperationMultipartBody =
| CanonicalHttpOperationMultipartBodyModel
| CanonicalHttpOperationMultipartBodyTuple;
CanonicalHttpOperationMultipartBodyModel | CanonicalHttpOperationMultipartBodyTuple;

export interface CanonicalHttpOperationMultipartBodyCommon extends CanonicalHttpOperationBodyBase {
readonly bodyKind: "multipart";
Expand All @@ -227,8 +224,7 @@ export interface CanonicalHttpOperationMultipartBodyTuple extends CanonicalHttpO
}

export type CanonicalHttpOperationMultipartPartBody =
| CanonicalHttpOperationBody
| CanonicalHttpOperationFileBody;
CanonicalHttpOperationBody | CanonicalHttpOperationFileBody;

export interface CanonicalHttpOperationPartCommon {
/** Part body */
Expand All @@ -246,8 +242,7 @@ export interface CanonicalHttpOperationPartCommon {
}

export type CanonicalHttpOperationPart =
| CanonicalHttpOperationModelPart
| CanonicalHttpOperationTuplePart;
CanonicalHttpOperationModelPart | CanonicalHttpOperationTuplePart;

export interface CanonicalHttpOperationModelPart extends CanonicalHttpOperationPartCommon {
readonly partKind: "model";
Expand Down
8 changes: 1 addition & 7 deletions packages/http-canonicalization/src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,7 @@ import { MutationOptions } from "@typespec/mutator-framework";
import type { HttpCanonicalization } from "./http-canonicalization-classes.js";

export type HttpCanonicalizationLocation =
| "header"
| "header-explode"
| "query"
| "query-explode"
| "path"
| "path-explode"
| "body";
"header" | "header-explode" | "query" | "query-explode" | "path" | "path-explode" | "body";

export interface HttpCanonicalizationOptionsInit {
visibility?: Visibility;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,7 @@ function fromSdkModelProperty(
const diagnostics = createDiagnosticCollector();
// TODO -- this returns undefined because some properties we do not support yet.
let property = sdkContext.__typeCache.properties.get(sdkProperty) as
| InputModelProperty
| undefined;
InputModelProperty | undefined;
if (property) {
return diagnostics.wrap(property);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,7 @@ export interface InputModelProperty extends InputPropertyTypeBase {
export type InputProperty = InputModelProperty | InputParameter;

export type InputHttpParameter =
| InputQueryParameter
| InputPathParameter
| InputHeaderParameter
| InputBodyParameter;
InputQueryParameter | InputPathParameter | InputHeaderParameter | InputBodyParameter;

export type InputParameter = InputMethodParameter | InputEndpointParameter | InputHttpParameter;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,7 @@ describe("ClientInitialization", () => {

// Find the method parameter with paramAlias
const blobParam = client.parameters.find((p) => p.kind === "method" && p.name === "blob") as
| InputMethodParameter
| undefined;
InputMethodParameter | undefined;
ok(blobParam, "Should have a 'blob' method parameter");
strictEqual(blobParam.paramAlias, "blobName", "paramAlias should be 'blobName'");
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,7 @@ describe.skip("Payload.MultiPart", () => {
const address = { city: "X" };
await client.jsonPart({
address,
profileImage: new Uint8Array([
/* file content */
]),
profileImage: new Uint8Array([/* file content */]),
});
});

Expand Down
3 changes: 1 addition & 2 deletions packages/http-client-python/emitter/src/code-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,7 @@ function emitClient<TServiceOperation extends SdkServiceOperation>(
.reduce((a, b) => [...a, ...b]) ?? [];

const endpointParameter = initParameters.find((x) => x.kind === "endpoint") as
| SdkEndpointParameter
| undefined;
SdkEndpointParameter | undefined;
const operationGroups = emitOperationGroups(context, client, client, "", client.apiVersions);
let url: string | undefined;
if (endpointParameter?.type.kind === "union") {
Expand Down
2 changes: 1 addition & 1 deletion packages/http-server-js/generated-defs/package.json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ export const hsjsDependencies: Record<string, string> = {
"typescript": "~6.0.2",
"vitest": "^4.1.3",
"yargs": "^18.0.0",
"prettier": "^3.8.1",
"prettier": "^3.9.5",
"yaml": "^2.8.3",
};
3 changes: 1 addition & 2 deletions packages/http-server-js/src/util/differentiate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,7 @@ export function differentiateUnion(
},
cases: variants.map((v) => {
const discriminatorPropertyType = (v.type as Model).properties.get(discriminator)!.type as
| JsLiteralType
| EnumMember;
JsLiteralType | EnumMember;

return {
value: { kind: "literal", value: getJsValue(ctx, discriminatorPropertyType) },
Expand Down
Loading
Loading