with one click
typescript-strict-patterns
TypeScript strict mode, type safety, readonly patterns, type guards for frontend tooling used in CI/CD
Menu
TypeScript strict mode, type safety, readonly patterns, type guards for frontend tooling used in CI/CD
Identity and access management: RBAC, least privilege, MFA, quarterly reviews per ISO 27001 A.5.15, A.8.2, A.8.3
Business continuity and disaster recovery: 30-day retention, quarterly restore tests, RTO/RPO targets per ISO 27001 A.17
Political psychology, cognitive biases, group dynamics, leadership analysis, decision-making patterns for Swedish political intelligence
Risk-based data and asset classification framework: PUBLIC, INTERNAL, CONFIDENTIAL, RESTRICTED aligned with ISO 27001 A.5.12 and CIA triad
Unified compliance verification across ISO 27001, NIST CSF, CIS Controls, NIS2, EU CRA, GDPR, SOC 2, PCI DSS, and HIPAA for cybersecurity consulting
Cryptographic controls implementation: TLS 1.3, AES-256-GCM, bcrypt, RSA-4096, key management per NIST FIPS 140-2 and ISO 27001 A.8.24
| name | typescript-strict-patterns |
| description | TypeScript strict mode, type safety, readonly patterns, type guards for frontend tooling used in CI/CD |
| license | Apache-2.0 |
Ensure type-safe TypeScript development for CI/CD tooling, MCP servers, and build scripts used in the CIA platform. This skill covers strict compiler options, type guard patterns, and defensive coding practices for TypeScript components within a primarily Java/Maven project.
Do NOT use for:
{
"compilerOptions": {
"strict": true,
"noUncheckedIndexedAccess": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"exactOptionalPropertyTypes": true,
"forceConsistentCasingInFileNames": true,
"isolatedModules": true,
"esModuleInterop": true,
"moduleResolution": "node16",
"module": "node16",
"target": "ES2022",
"declaration": true,
"declarationMap": true,
"sourceMap": true,
"outDir": "./dist"
}
}
| Flag | Purpose |
|---|---|
strictNullChecks | Prevents null/undefined assignment errors |
strictFunctionTypes | Enforces contravariant function parameter types |
strictPropertyInitialization | Requires class properties to be initialized |
noImplicitAny | Disallows implicit any types |
noImplicitThis | Errors on this with implicit any type |
interface Politician {
readonly type: "politician";
readonly personId: string;
readonly firstName: string;
readonly lastName: string;
readonly party: SwedishParty;
}
interface Committee {
readonly type: "committee";
readonly committeeId: string;
readonly name: string;
readonly members: readonly string[];
}
type PoliticalEntity = Politician | Committee;
// Type guard
function isPolitician(entity: PoliticalEntity): entity is Politician {
return entity.type === "politician";
}
// Immutable data structures for political records
interface VotingRecord {
readonly personId: string;
readonly votes: ReadonlyArray<Vote>;
readonly summary: Readonly<VotingSummary>;
}
// Readonly mapped type for API responses
type Immutable<T> = {
readonly [K in keyof T]: T[K] extends object ? Immutable<T[K]> : T[K];
};
type ImmutableApiResponse = Immutable<RiksdagApiResponse>;
function isValidParty(value: unknown): value is SwedishParty {
const validParties = ["S", "M", "SD", "C", "V", "KD", "L", "MP"] as const;
return typeof value === "string" && validParties.includes(value as SwedishParty);
}
function assertNonNull<T>(value: T | null | undefined, name: string): asserts value is T {
if (value === null || value === undefined) {
throw new Error(`Expected non-null value for ${name}`);
}
}
type PersonId = string & { readonly __brand: "PersonId" };
type CommitteeId = string & { readonly __brand: "CommitteeId" };
function createPersonId(raw: string): PersonId {
if (!/^[0-9a-f-]{36}$/.test(raw)) {
throw new Error(`Invalid person ID format: ${raw}`);
}
return raw as PersonId;
}
// Result type for safe error handling
type Result<T, E = Error> =
| { readonly success: true; readonly value: T }
| { readonly success: false; readonly error: E };
async function fetchPoliticianData(id: PersonId): Promise<Result<Politician>> {
try {
const response = await fetch(`https://data.riksdagen.se/person/${id}`);
if (!response.ok) {
return { success: false, error: new Error(`HTTP ${response.status}`) };
}
const data: unknown = await response.json();
const validated = validatePoliticianData(data);
return { success: true, value: validated };
} catch (error) {
return { success: false, error: error instanceof Error ? error : new Error(String(error)) };
}
}
{
"scripts": {
"build": "tsc --project tsconfig.json",
"typecheck": "tsc --noEmit",
"lint": "eslint src/ --ext .ts",
"test": "vitest run"
}
}
- name: TypeScript Type Check
run: npx tsc --noEmit --strict
unknown over any for untyped data from APIsas) without validationnpm audit before adding packages