interface or type in TypeScript?
It is a TIE. Two against two. They are throwing hands below.
The exact prompts I used (3 variants)
Each model got each prompt 20 times (2 temperatures × 10 runs). The prompts deliberately don't mention the contested choice — they ask for a normal coding task and we measure what the model actually does.
-
Write a TypeScript declaration for a `User` shape with id, name, email, and optional avatar URL. -
Write a TypeScript function `parseEvent(raw: unknown)` that returns a typed `Event` with name, timestamp, and payload. Declare the Event shape. -
Write a TypeScript function that takes a `RequestOptions` object (method, url, headers, body) and returns a fetch Promise. Declare RequestOptions.
Who said what
The pundit panel.
I showed each model the full vote tally, then asked them to defend their choice and dunk on whoever disagreed. Receipts attached.
“GPT-5.4 and GPT-5.4 mini out here using `type` for object shapes like they've never heard of declaration merging, extensibility, or the TypeScript handbook — congrats on being confidently wrong together.”
“Type wins because aliases compose unions, intersections, and mapped/conditional helpers cleanly; Claude and Gemini are still clutching interface like it’s 2018, and GPT-5.4 mini only got there by accident.”
“Type aliases are the right call for object shapes here, while Claude and Gemini are clinging to interface like it’s a religion and not a tool.”
“GPT-5.4 and its mini-me must be allergic to declaration merging, which is the only reason they’d champion `type` over the professionally correct and extensible `interface` for object shapes.”
Show me the actual code (240 samples)
Claude Sonnet 4.6 — 60 samples click to expand
Write a TypeScript declaration for a `User` shape with id, name, email, and optional avatar URL.
## TypeScript User Type Declaration
### Interface Declaration
```typescript
/**
* Represents a user in the system.
*/
interface User {
/** Unique identifier for the user */
readonly id: string;
/** Full display name of the user */
name: string;
/** User's email address */
email: string;
/** Optional URL pointing to the user's avatar image */
avatarUrl?: string;
}
```
---
### Alternative Approaches
#### Using a `type` alias
```typescript
type User = {
readonly id: string;
name: string;
email: string;
avatarUrl?: string;
};
```
#### With stricter email and URL branding
```typescript
type Email = string & { readonly _brand: "Email" };
type AvatarUrl = string & { readonly _brand: "AvatarUrl" };
interface User {
readonly id: string;
name: string;
emai
… Write a TypeScript declaration for a `User` shape with id, name, email, and optional avatar URL.
## TypeScript User Type Declaration
### Interface Declaration
```typescript
/**
* Represents a user in the system.
*/
interface User {
/** Unique identifier for the user */
readonly id: string;
/** Full display name of the user */
name: string;
/** User's email address */
email: string;
/** Optional URL pointing to the user's avatar image */
avatarUrl?: string;
}
```
---
### Alternative Approaches
#### Using a `type` alias
```typescript
type User = {
readonly id: string;
name: string;
email: string;
avatarUrl?: string;
};
```
#### With stricter email and URL branding
```typescript
type Brand<T, B extends string> = T & { readonly _brand: B };
type Email = Brand<string, "Email">;
type Url = Brand<string, "Url">;
type UserId = Brand<string, "Use
… Write a TypeScript declaration for a `User` shape with id, name, email, and optional avatar URL.
## TypeScript User Type Declaration
### Interface Declaration
```typescript
/**
* Represents a user in the system.
*/
interface User {
/** Unique identifier for the user */
readonly id: string;
/** Display name of the user */
name: string;
/** Email address of the user */
email: string;
/** Optional URL pointing to the user's avatar image */
avatarUrl?: string;
}
```
---
### Alternative Approaches
#### Using a `type` alias
```typescript
type User = {
readonly id: string;
name: string;
email: string;
avatarUrl?: string;
};
```
#### With stricter email and URL validation via branded types
```typescript
type Email = string & { readonly _brand: "Email" };
type AvatarUrl = string & { readonly _brand: "AvatarUrl" };
interface User {
readonly id: string;
… …and 57 more samples (across 3 prompt variants × 2 temperatures × 10 runs). Full data in the result JSON on GitHub.
GPT-5.4 — 60 samples click to expand
Write a TypeScript declaration for a `User` shape with id, name, email, and optional avatar URL.
```ts
type User = {
id: string;
name: string;
email: string;
avatarUrl?: string;
};
``` Write a TypeScript declaration for a `User` shape with id, name, email, and optional avatar URL.
```ts
type User = {
id: string;
name: string;
email: string;
avatarUrl?: string;
};
``` Write a TypeScript declaration for a `User` shape with id, name, email, and optional avatar URL.
```ts
type User = {
id: string;
name: string;
email: string;
avatarUrl?: string;
};
``` …and 57 more samples (across 3 prompt variants × 2 temperatures × 10 runs). Full data in the result JSON on GitHub.
GPT-5.4 mini — 60 samples click to expand
Write a TypeScript declaration for a `User` shape with id, name, email, and optional avatar URL.
```ts
type User = {
id: string;
name: string;
email: string;
avatarUrl?: string;
};
``` Write a TypeScript declaration for a `User` shape with id, name, email, and optional avatar URL.
```ts
type User = {
id: string;
name: string;
email: string;
avatarUrl?: string;
};
``` Write a TypeScript declaration for a `User` shape with id, name, email, and optional avatar URL.
```ts
type User = {
id: string;
name: string;
email: string;
avatarUrl?: string;
};
```
If you want, I can also provide it as an `interface` instead of a `type`. …and 57 more samples (across 3 prompt variants × 2 temperatures × 10 runs). Full data in the result JSON on GitHub.
Gemini 2.5 Pro — 60 samples click to expand
Write a TypeScript declaration for a `User` shape with id, name, email, and optional avatar URL.
Of course. Here are a few ways to declare a `User` shape in TypeScript, from the most common to alternatives.
### 1. Using an `interface` (Most Common)
This is the most idiomatic way to define the shape of an object in TypeScript.
```typescript
interface User {
id: number | string;
name: string;
email: string;
avatar?: string; // The '?' makes this property optional
}
// --- Example Usage ---
// A user with an avatar
const user1: User = {
id: 1,
name: 'Jane Doe',
email: 'jane.doe@example.com',
avatar: 'https://example.com/avatars/jane.png'
};
// A user without an avatar (this is valid because avatar is optional)
const user2: User = {
id: 'a1b2-c3d4-e5f6', // ID can also be a string
name: 'John Smith',
email: 'john.smith@example.com'
};
```
**Key Points:**
* `
… Write a TypeScript declaration for a `User` shape with id, name, email, and optional avatar URL.
Of course. The most common way to declare an object shape in TypeScript is using an `interface`.
### Using `interface` (Recommended)
This is the idiomatic way to define an object shape.
```typescript
interface User {
id: number | string; // Use `number` or `string` depending on your ID format
name: string;
email: string;
avatarUrl?: string; // The '?' makes this property optional
}
```
**Explanation:**
* `interface User { ... }`: Declares a new type shape named `User`.
* `id: number | string;`: The `id` property must be a `number` or a `string`.
* `name: string;`: The `name` property must be a `string`.
* `email: string;`: The `email` property must be a `string`.
* `avatarUrl?: string;`: The `avatarUrl` property is optional (indicated by the `?`). If it exists, it mu
… Write a TypeScript declaration for a `User` shape with id, name, email, and optional avatar URL.
Of course. The most common way to declare an object shape in TypeScript is using an `interface`.
### Using `interface` (Recommended)
This is the idiomatic way to define an object shape.
```typescript
interface User {
id: number | string; // Use `number` or `string` depending on your ID format
name: string;
email: string;
avatarUrl?: string; // The '?' makes this property optional
}
```
**Explanation:**
* `interface User { ... }`: Declares a new type shape named `User`.
* `id: number | string;`: The `id` property must be a `number` or a `string`.
* `name: string;`: The `name` property must be a `string`.
* `email: string;`: The `email` property must be a `string`.
* `avatarUrl?: string;`: The `avatarUrl` property is optional (indicated by the `?`). If it exists, it mu
… …and 57 more samples (across 3 prompt variants × 2 temperatures × 10 runs). Full data in the result JSON on GitHub.
How I did this (the actual nerd shit)
For each of 4 models I ran 3 prompt variants at two temperatures (0.0 and 0.7), 10 runs each — 240 code samples total, cost $3.20.
Each output got fed through a fight-specific regex classifier.
For interface-vs-type-ts the classifier looks for the specific signal in the output
(see the source — there's one function per fight, ~30 lines each).
When the signal is ambiguous, the classifier returns 'unknown' rather than guess.
Each model's vote = its modal classification across 60 runs. Confidence = Wilson 95% CI. Verdict = majority across models (ties reported as ties). Disagreement Index = normalized Shannon entropy of the vote distribution (0 = unanimous, 1 = maximum chaos). Leaderboard sorts by this.
The pundit quotes come from a follow-up call after the votes are in — each model gets the full tally and a per-model judgy prompt. I never edit the quotes.
Full walkthrough: the methodology page. Source: GitHub.
Open a PR with a new fight. I'll run it across all four models, write up the verdict, and add your name to the byline.
Submit via PR →