hide-unsafe-assertions

Hide internal type assertions from public TypeScript APIs.

Updated Jul 17, 2017
One-click install
npx skills add https://github.com/luyi985/lyi-bash --skill hide-unsafe-assertions
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: hide-unsafe-assertions
Source: https://github.com/luyi985/lyi-bash/tree/main/ai/skills/hide-unsafe-assertions
Command: npx skills add https://github.com/luyi985/lyi-bash --skill hide-unsafe-assertions

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Use when type assertions are necessary. Use when function implementations need any. Use when hiding unsafe code.

Core Features & Use Cases

  • Hide internal type assertions inside well-typed functions to preserve a clean public API.
  • Narrow the scope of unsafe code to the implementation, not the interface.
  • Validate unsafe points locally to prevent runtime errors while keeping types stable.

Quick Start

Apply hidden assertions inside well-typed functions to preserve clean public APIs.

Frequently Asked Questions about hide-unsafe-assertions

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I hide unsafe type assertions from a public TypeScript API?

To hide unsafe type assertions from a public TypeScript API, wrap the internal type assertions inside well-typed functions. This narrows the scope of unsafe code to the implementation, preserving a clean public interface without leaking assertions.

Why does my TypeScript function signature expose internal type assertions?

Your TypeScript function signature exposes internal type assertions when implementation details like any or type casts leak into the public contract. You must internalize these checks within the function body to keep the external type signatures clean.

What is the best way to handle necessary type assertions without breaking type safety in TypeScript?

The best way to handle necessary type assertions without breaking type safety is to validate unsafe points locally within the implementation. Hiding internal assertions prevents runtime errors while keeping public TypeScript types stable and clean.

Can I use internal type assertions while maintaining a clean external TypeScript contract?

Yes, you can use internal type assertions while maintaining a clean external TypeScript contract. By applying hidden assertions inside well-typed functions, you ensure the unsafe implementation details do not leak into the public API.

When do I need to hide type assertions in TypeScript codebases?

You need to hide type assertions in TypeScript codebases when function implementations require any or unsafe casts, but the public API must remain strictly typed. This isolates the unsafe code to prevent runtime errors while preserving type stability.

What are the limitations of hiding unsafe code in TypeScript implementations?

The limitation of hiding unsafe code in TypeScript implementations is that it requires local validation at unsafe points to prevent runtime errors. While the public type signature remains clean, the internal logic still relies on assertions that the compiler cannot verify.