Comprehensive TypeScript guidance covering compiler configuration, advanced types, utility types, type guards, strict mode workflows, and documentation patterns; use when configuring tsconfig, designing complex generics, making illegal states unrepresentable, fixing type errors, or writing testable and maintainable type-safe APIs.
Overall
score
99%
Does it follow best practices?
Validation for skill structure
Create modules with full type safety and encapsulation.
// math.ts
export interface MathOperations {
add(a: number, b: number): number;
subtract(a: number, b: number): number;
}
const createMath = (): MathOperations => {
// Private implementation
const cache = new Map<string, number>();
const getCacheKey = (op: string, a: number, b: number) =>
`${op}:${a}:${b}`;
return {
add(a, b) {
const key = getCacheKey('add', a, b);
if (!cache.has(key)) {
cache.set(key, a + b);
}
return cache.get(key)!;
},
subtract(a, b) {
const key = getCacheKey('sub', a, b);
if (!cache.has(key)) {
cache.set(key, a - b);
}
return cache.get(key)!;
}
};
};
export const math = createMath();interface Plugin<TConfig = unknown> {
name: string;
version: string;
init(config: TConfig): Promise<void>;
cleanup(): Promise<void>;
}
interface PluginRegistry {
register<TConfig>(plugin: Plugin<TConfig>): void;
get<TConfig>(name: string): Plugin<TConfig> | undefined;
unregister(name: string): void;
}
const createPluginRegistry = (): PluginRegistry => {
const plugins = new Map<string, Plugin>();
return {
register(plugin) {
if (plugins.has(plugin.name)) {
throw new Error(`Plugin ${plugin.name} already registered`);
}
plugins.set(plugin.name, plugin);
},
get(name) {
return plugins.get(name);
},
unregister(name) {
const plugin = plugins.get(name);
if (plugin) {
plugin.cleanup();
plugins.delete(name);
}
}
};
};export type UserId = string & { readonly __brand: 'UserId' };
export interface UserModule {
create(email: string): UserId;
get(id: UserId): { id: UserId; email: string } | undefined;
delete(id: UserId): boolean;
}
const createUserModule = (): UserModule => {
let counter = 0;
const users = new Map<UserId, { id: UserId; email: string }>();
const createUserId = (): UserId => {
return `user-${++counter}` as UserId;
};
return {
create(email) {
const id = createUserId();
users.set(id, { id, email });
return id;
},
get(id) {
return users.get(id);
},
delete(id) {
return users.delete(id);
}
};
};
export const userModule = createUserModule();Install with Tessl CLI
npx tessl i pantheon-ai/typescript-advancedreferences