get-typescript-patterns
Access TypeScript patterns for React Native development, including strict mode configuration, API response typing, route parameters, and reusable hooks. Use topic parameter to target specific sections.
Instructions
Get TypeScript patterns for React Native. Call this when writing types or interfaces. Covers strict mode config, model types, API response types, route param typing, props interface naming, store types, generics for reusable hooks, as const, discriminated unions, and type guards. Use topic to get a specific section only.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| topic | No | Get a specific section only. Available: strict-config, route-params, api-types, model-types, props-naming, store-types, generics, as-const, discriminated-unions, type-guards. Omit for full content. | |
| compact | No | If true, returns rules only without code examples. Much shorter. |
Implementation Reference
- The `getTypescriptPatterns` function serves as the handler for the `get-typescript-patterns` tool, delegating the logic to `resolvePattern` with the predefined pattern definitions.
export const getTypescriptPatterns = (topic?: string, compact?: boolean): string => resolvePattern(pattern, topic, compact); - src/index.ts:215-233 (registration)Tool registration for `get-typescript-patterns` within the MCP server.
server.tool( "get-typescript-patterns", "Get TypeScript patterns for React Native. Call this when writing types or interfaces. Covers strict mode config, model types, API response types, route param typing, props interface naming, store types, generics for reusable hooks, as const, discriminated unions, and type guards. Use `topic` to get a specific section only.", { topic: z .string() .optional() .describe( "Get a specific section only. Available: strict-config, route-params, api-types, model-types, props-naming, store-types, generics, as-const, discriminated-unions, type-guards. Omit for full content." ), compact: z .boolean() .optional() .describe("If true, returns rules only without code examples. Much shorter."), }, async ({ topic, compact }) => ({ content: [{ type: "text", text: getTypescriptPatterns(topic, compact) }], }) ); - src/index.ts:218-229 (schema)Input schema definition (parameters `topic` and `compact`) for the `get-typescript-patterns` tool.
{ topic: z .string() .optional() .describe( "Get a specific section only. Available: strict-config, route-params, api-types, model-types, props-naming, store-types, generics, as-const, discriminated-unions, type-guards. Omit for full content." ), compact: z .boolean() .optional() .describe("If true, returns rules only without code examples. Much shorter."), },