From harness-claude
Extends TypeScript interfaces, modules (Express Request, Next.js Metadata), globals (Window, ProcessEnv), and untyped JS modules via declaration merging and augmentation. Use for custom properties on third-party libs and safe env vars.
npx claudepluginhub intense-visions/harness-engineering --plugin harness-claudeThis skill uses the workspace's default tool permissions.
> Extend existing types, modules, and namespaces via declaration merging and augmentation
Masters advanced TypeScript typing with generics, conditional types, decorators, strict configs, and enterprise patterns for architecture design and inference optimization.
Masters advanced TypeScript types, generics, conditional types, decorators, strict configs for enterprise architectures and production type safety hardening.
Designs complex TypeScript generics and utility types, refactors 'any' to strict alternatives, creates type guards, and resolves compiler errors for inference, conditional types, and more.
Share bugs, ideas, or general feedback.
Extend existing types, modules, and namespaces via declaration merging and augmentation
Request, Next.js Metadata)Window, ProcessEnv, or other global interfacesinterface User {
id: string;
name: string;
}
// Later, in another file or declaration
interface User {
email: string;
}
// Merged: { id: string; name: string; email: string }
// types/express.d.ts
import 'express';
declare module 'express' {
interface Request {
userId?: string;
tenantId?: string;
}
}
Now req.userId is available in all Express route handlers.
// types/global.d.ts
declare global {
interface Window {
analytics: AnalyticsClient;
}
namespace NodeJS {
interface ProcessEnv {
DATABASE_URL: string;
API_KEY: string;
NODE_ENV: 'development' | 'production' | 'test';
}
}
}
export {}; // Required to make this a module
// types/untyped-lib.d.ts
declare module 'untyped-lib' {
export function doSomething(input: string): number;
export interface Config {
verbose: boolean;
}
}
// types/assets.d.ts
declare module '*.svg' {
const content: string;
export default content;
}
declare module '*.css' {
const classes: Record<string, string>;
export default classes;
}
enum Color {
Red = 'red',
Blue = 'blue',
}
namespace Color {
export function fromHex(hex: string): Color {
// ...
}
}
Color.fromHex('#ff0000'); // Works
// env.d.ts
declare namespace NodeJS {
interface ProcessEnv {
DATABASE_URL: string;
REDIS_URL: string;
PORT: string;
}
}
{
"compilerOptions": {
"typeRoots": ["./node_modules/@types", "./types"]
},
"include": ["src", "types"]
}
Declaration merging is TypeScript's mechanism for combining multiple declarations of the same entity into a single definition. It enables extending types without modifying source code.
What merges:
What does NOT merge:
type X = ...) — redeclaring causes an errorModule augmentation requirements:
import or export)declare module 'name' must match the module specifier exactlyGlobal augmentation requirements:
declare global { } when in a module fileexport {} at the bottom if the file has no other imports/exportsTrade-offs:
https://typescriptlang.org/docs/handbook/declaration-merging.html