SKY-T106 · Quality, structure and performance
Unsafe exported API type
any switches TypeScript's checks off for a value. SKY-T106 reports any, an any-valued index signature and Record<string, any> in the types of what a module exports: function parameters and return types, interface and class members, type aliases and exported variables.
- Languages
- TypeScript
- Quality gate
- counted toward the gate limits (full and diff scans)
- Finding type
- review
Why it matters
An exported type is a promise to every caller. With payload: any, each caller can read any property without a check, so a typo or a changed webhook format compiles fine and fails only in production, in code far from the module that let it through.
What Skylos flags
export interface WebhookEvent { id: string; type: string; payload: any;} export function handleWebhook(event: WebhookEvent): void { console.log(event.id, event.type);}What Skylos leaves alone
export interface WebhookEvent { id: string; type: string; payload: unknown;} function logRaw(value: any): void { console.log(JSON.stringify(value));} export function handleWebhook(event: WebhookEvent): void { logRaw(event.payload);}Why Skylos leaves it alone
The exported interface uses unknown, which forces every caller to check the payload before using it. The remaining any belongs to a helper that is not exported, so it is not part of the module's API.
More languages
TypeScript
Flagged
import type { WebhookEvent } from "./types"; export function handleWebhook(event: WebhookEvent, meta: Record<string, any>) { console.log(event.id, meta.source);}Not flagged
import type { WebhookEvent } from "./types"; type Meta = { source: string; receivedAt: number }; export function handleWebhook(event: WebhookEvent, meta: Meta) { console.log(event.id, meta.source);}Why Skylos leaves it alone
The metadata has its own precise type, so the exported signature says exactly what callers must pass.
How Skylos decides
- Runs with
--qualityon.ts,.tsx,.mtsand.ctsfiles, declaration files (.d.ts) included. Generated files and files that do not parse are skipped. - Collects what the module exports: exported functions, classes, interfaces, type aliases and variables, including
export { name }lists andexport default. Private class members are left out. - Reads the type annotations of that public surface: parameters, return types, properties, index signatures and alias bodies.
- Reports a type that is exactly
any(also as the value of an index signature) andRecord<string, any>whenRecordis the built-in one.anynested inside another type, such asany[]orPromise<any>, is not reported. - Reports MEDIUM on the line of the offending type, once per type.
How to fix it
Give the value a precise type. When its shape is not known in advance, use unknown, which makes each caller check it before use.
Added: export type WebhookPayload =Added: | { kind: "order.paid"; orderId: string; amount: number }Added: | { kind: "order.refunded"; orderId: string; reason: string };Added: export interface WebhookEvent { id: string; type: string;Removed: payload: any;Added: payload: WebhookPayload;} export function handleWebhook(event: WebhookEvent): void { console.log(event.id, event.type);}When it can be wrong
- A deliberately generic API, such as a logger that accepts anything, is reported;
unknownusually works there too. - It misses
anynested inside another type (any[],Promise<any>,Map<string, any>) andanyin code that is not exported.
Seeing a case that isn't listed here? Report the wrong result so the rule can be fixed. Don't paste company code: describe the shape of it.
How to silence it
On the reported line:
TypeScript payload: any; // skylos: ignore[SKY-T106] shape varies per provider[tool.skylos] ignore = ["SKY-T106"]inpyproject.tomlturns the rule off for the project. A baseline accepts existing findings, but it records the absolute file path and the line, so an entry stops matching when the checkout moves or the line shifts.