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 types from string templates:
type World = "world";
type Greeting = `hello ${World}`; // "hello world"
type EmailDomain = "gmail.com" | "yahoo.com";
type Email = `user@${EmailDomain}`;
// "user@gmail.com" | "user@yahoo.com"Built-in type utilities for string transformation:
type Uppercase<S extends string> = intrinsic;
type Lowercase<S extends string> = intrinsic;
type Capitalize<S extends string> = intrinsic;
type Uncapitalize<S extends string> = intrinsic;
type Loud = Uppercase<"hello">; // "HELLO"
type Quiet = Lowercase<"WORLD">; // "world"
type Proper = Capitalize<"john">; // "John"
type Lower = Uncapitalize<"Smith">; // "smith"type EventNames = "click" | "focus" | "blur";
type EventHandlers = `on${Capitalize<EventNames>}`;
// "onClick" | "onFocus" | "onBlur"
type PropEventHandler<T extends string> = `on${Capitalize<T>}Changed`;
type FormEvents = PropEventHandler<"username" | "email">;
// "onUsernameChanged" | "onEmailChanged"type HttpMethod = "GET" | "POST" | "PUT" | "DELETE";
type Endpoint = "users" | "posts" | "comments";
type ApiRoute = `/${Endpoint}`;
// "/users" | "/posts" | "/comments"
type RestEndpoint = `${HttpMethod} /${Endpoint}`;
// "GET /users" | "POST /users" | ... (12 combinations)inferExtract parts from template literal types:
type ExtractRouteParams<T extends string> =
T extends `${infer _Start}:${infer Param}/${infer Rest}`
? Param | ExtractRouteParams<Rest>
: T extends `${infer _Start}:${infer Param}`
? Param
: never;
type Params = ExtractRouteParams<"/users/:userId/posts/:postId">;
// "userId" | "postId"type CamelCase<S extends string> =
S extends `${infer First}_${infer Rest}`
? `${Lowercase<First>}${Capitalize<CamelCase<Rest>>}`
: Lowercase<S>;
type Result = CamelCase<"hello_world_example">;
// "helloWorldExample"type CSSUnits = "px" | "em" | "rem" | "%";
type CSSValue<T extends number> = `${T}${CSSUnits}`;
type Width = CSSValue<100>; // "100px" | "100em" | "100rem" | "100%"
// With specific properties
type Padding = CSSValue<0 | 4 | 8 | 16>;type TableName = "users" | "posts" | "comments";
type Operation = "select" | "insert" | "update" | "delete";
type Query = `${Operation} from ${TableName}`;
// Type-safe query builder
type WhereClause<T extends string> = `where ${T}`;
type FullQuery<T extends TableName, C extends string> =
`select from ${T} ${WhereClause<C>}`;type Accessor<T, K extends keyof T> = {
[P in K as `get${Capitalize<string & P>}`]: () => T[P];
} & {
[P in K as `set${Capitalize<string & P>}`]: (value: T[P]) => void;
};
interface User {
name: string;
age: number;
}
type UserAccessors = Accessor<User, keyof User>;
// {
// getName: () => string;
// setName: (value: string) => void;
// getAge: () => number;
// setAge: (value: number) => void;
// }type EnvPrefix = "VITE_" | "NEXT_PUBLIC_";
type EnvVar<T extends string> = `${EnvPrefix}${Uppercase<T>}`;
type AppEnvVars = EnvVar<"api_url" | "api_key">;
// "VITE_API_URL" | "VITE_API_KEY" | "NEXT_PUBLIC_API_URL" | "NEXT_PUBLIC_API_KEY"
// Type-safe env access
declare const process: {
env: Record<AppEnvVars, string>;
};type Column = "id" | "name" | "email" | "created_at";
type SqlType = "INTEGER" | "TEXT" | "TIMESTAMP";
type ColumnDef = `${Column} ${SqlType}`;
type TableSchema = {
[K in Column]: ColumnDef;
};type Protocol = "http" | "https";
type Domain = string;
type Path = string;
type Url = `${Protocol}://${Domain}/${Path}`;
type ApiUrl<E extends string> = `https://api.example.com/${E}`;type Version = "v1" | "v2" | "v3";
type Resource = "users" | "posts";
type VersionedEndpoint = `/api/${Version}/${Resource}`;
// "/api/v1/users" | "/api/v1/posts" | "/api/v2/users" | ...type DomainEvent<T extends string> = `domain:${T}`;
type SystemEvent<T extends string> = `system:${T}`;
type UserEvents = DomainEvent<"user:created" | "user:updated">;
// "domain:user:created" | "domain:user:updated"infer for pattern extractionInstall with Tessl CLI
npx tessl i pantheon-ai/typescript-advanced@0.1.1references