sf-symbols-typescript is a utility library providing TypeScript type definitions for Apple's SF Symbols. It enables developers to use SF Symbol names as string literal types, enhancing type safety in applications that consume these icons, particularly useful in environments like React Native. The current stable version is 2.2.0. The library primarily updates its types in sync with new releases of SF Symbols from Apple, incorporating new icons and symbol versions. Its key differentiators include having zero runtime dependencies and zero runtime code, making it a pure type-level utility. It also offers advanced features for restricting the available symbols globally via declaration merging or individually by importing specific version types, which is crucial for maintaining compatibility with target iOS/macOS versions.
npm install sf-symbols-typescriptVerified import paths — ran on the pinned version, not inferred.
Demonstrates basic usage of `SFSymbol` for type safety, global restriction via declaration merging, and importing version-specific symbol types.
Migrate any custom version restriction logic to use the `declare module 'sf-symbols-typescript' { interface Overrides { SFSymbolsVersion: 'X.Y' } }` pattern, or import specific version types like `SFSymbolsX_Y`.Always use `import type { SFSymbol } from 'sf-symbols-typescript'` for type-only imports to ensure it's stripped correctly during compilation.Move global `declare module 'sf-symbols-typescript' { ... }` blocks to a dedicated `.d.ts` file in your project's root or `src` directory, ensuring it's picked up by the TypeScript compiler.Remember that `SFSymbol` is a TypeScript type only. It has no runtime representation. It should only be used in type annotations or declarations, such as `const icon: SFSymbol = '...'`.
Ensure you are using declaration merging correctly: `declare module 'sf-symbols-typescript' { interface Overrides { SFSymbolsVersion: 'X.Y' } }` in a global `.d.ts` file. Do not try to import or extend `Overrides` as a regular interface.Double-check the symbol name for typos. If you've restricted the `SFSymbol` type to an older version (e.g., '5.0'), ensure the symbol you're using is available in that version. Consult the SF Symbols app or the Version Support Table in the package's README to verify symbol availability for your chosen version.
No dependency data recorded yet.