{"id":14994,"library":"typescript-char","title":"TypeScript Character Code Enumeration","description":"typescript-char is a lightweight, type-definition-only library providing a TypeScript enumeration for common character codes. Its primary purpose is to eliminate 'magic numbers' in code, enhancing readability and maintainability when dealing with character-based operations, such as in parsers, lexers, or character stream processing. The library currently stands at version 0.0.0, indicating a pre-release or unversioned state. As a 'header-only' library, it consists solely of a `.d.ts` file, meaning it introduces no runtime JavaScript code or overhead. Its release cadence is effectively non-existent, with no updates since 2017. Key differentiators include its zero-runtime footprint and its focus purely on providing type-safe, named constants for character codes within a TypeScript environment, allowing direct usage of `Char.OpenBrace` instead of numerical literals like `123`.","status":"abandoned","version":"0.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/mason-lang/typescript-char","tags":["javascript"],"install":[{"cmd":"npm install typescript-char","lang":"bash","label":"npm"},{"cmd":"yarn add typescript-char","lang":"bash","label":"yarn"},{"cmd":"pnpm add typescript-char","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The library exports a default enum-like object named `Char`.","wrong":"import { Char } from 'typescript-char'","symbol":"Char","correct":"import Char from 'typescript-char'"},{"note":"Being a type-only library, it's typically used with `import` statements or global type references, and has no CommonJS runtime equivalent.","wrong":"const Char = require('typescript-char')","symbol":"Char","correct":"/// <reference types=\"typescript-char\" />\n\nconst x: Char = Char.OpenBrace"}],"quickstart":{"code":"import Char from 'typescript-char';\n\n// Use a character code from the enumeration\nconst openBraceCode: Char = Char.OpenBrace;\nconsole.log(`Open Brace Code: ${openBraceCode}`); // Expected output: 123\n\n// Convert the character code back to a string character\nconsole.log(`Character from code: ${String.fromCharCode(openBraceCode)}`); // Expected output: {\n\n// Example in a simple parser context (conceptual, as it's types only)\nfunction processInput(input: string) {\n  if (input.charCodeAt(0) === Char.OpenParen) {\n    console.log('Input starts with an opening parenthesis.');\n  } else if (input.charCodeAt(0) === Char.A) {\n    console.log('Input starts with an 'A'.');\n  } else {\n    console.log('Input starts with another character.');\n  }\n}\n\nprocessInput('(');\nprocessInput('Apple');\nprocessInput('Banana');","lang":"typescript","description":"Demonstrates importing the `Char` enumeration and using its constants for character codes, including converting a code back to its string representation."},"warnings":[{"fix":"Use with caution in production environments. Consider vendoring the `.d.ts` file or pinning to a specific commit if stability is critical.","message":"The package version is 0.0.0, indicating it is pre-release and not considered stable. Future updates (if any) could introduce breaking changes without following semantic versioning practices.","severity":"breaking","affected_versions":">=0.0.0"},{"fix":"Do not attempt to instantiate `Char` at runtime or use `require()`. It is purely for type-checking and compile-time constant resolution. Use `import Char from 'typescript-char'` in TypeScript files.","message":"This is a 'header-only' library, meaning it provides only TypeScript type definitions (`.d.ts` file) and no runtime JavaScript code. Attempting to `require()` it in a CommonJS environment or expecting a runtime class will result in errors.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Evaluate alternatives if active maintenance, broader character support (e.g., full Unicode), or compatibility with very recent TypeScript features are required.","message":"The library has not been updated since 2017. This indicates it is likely abandoned and will not receive new features, bug fixes, or compatibility updates for newer TypeScript versions or Unicode characters.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Ensure `typescript-char` is listed in your `devDependencies` and `node_modules` is accessible. Verify your `tsconfig.json` includes `node_modules` in `typeRoots` or `include` paths, and `moduleResolution` is set appropriately (e.g., `NodeNext` or `Node`).","cause":"This error occurs if TypeScript cannot locate the module's declaration file, often due to incorrect `tsconfig.json` paths or if the package is not installed correctly.","error":"Error: Cannot find module 'typescript-char'"},{"fix":"This library only provides types. If you need runtime character codes, you must either define them as `const` enums (which are inlined) or use direct magic numbers in your JavaScript output, which defeats the purpose of this library for runtime values. This library is for compile-time type safety.","cause":"This error arises when you try to access `Char.OpenBrace` in JavaScript at runtime after TypeScript compilation, but `typescript-char` is a type-only library and provides no runtime values.","error":"TypeError: Cannot read properties of undefined (reading 'OpenBrace') at runtime"}],"ecosystem":"npm"}