Registry / type-stubs / typescript-char

typescript-char

JSON →
library0.0.0jsnpmunverified

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`.

npm install typescript-char
INSTALL
IMPORT
SIG · TYPESCRIPT-CHAR
T
typescript-char
type-stubsjavascriptv0.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Char
import Char from 'typescript-char'
import { Char } from 'typescript-char'
The library exports a default enum-like object named `Char`.
Char
/// <reference types="typescript-char" /> const x: Char = Char.OpenBrace
const Char = require('typescript-char')
Being a type-only library, it's typically used with `import` statements or global type references, and has no CommonJS runtime equivalent.

Demonstrates importing the `Char` enumeration and using its constants for character codes, including converting a code back to its string representation.

import Char from 'typescript-char'; // Use a character code from the enumeration const openBraceCode: Char = Char.OpenBrace; console.log(`Open Brace Code: ${openBraceCode}`); // Expected output: 123 // Convert the character code back to a string character console.log(`Character from code: ${String.fromCharCode(openBraceCode)}`); // Expected output: { // Example in a simple parser context (conceptual, as it's types only) function processInput(input: string) { if (input.charCodeAt(0) === Char.OpenParen) { console.log('Input starts with an opening parenthesis.'); } else if (input.charCodeAt(0) === Char.A) { console.log('Input starts with an 'A'.'); } else { console.log('Input starts with another character.'); } } processInput('('); processInput('Apple'); processInput('Banana');
Debug
Known issues
breakingThe 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.
fix
Use with caution in production environments. Consider vendoring the `.d.ts` file or pinning to a specific commit if stability is critical.
affects: >=0.0.0
gotchaThis 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.
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.
affects: >=0.0.0
gotchaThe 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.
fix
Evaluate alternatives if active maintenance, broader character support (e.g., full Unicode), or compatibility with very recent TypeScript features are required.
affects: >=0.0.0
Errors
Common errors & fixes
Error: Cannot find module 'typescript-char'
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.
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`).
TypeError: Cannot read properties of undefined (reading 'OpenBrace') at runtime
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.
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.
Upgrade
Version history
0.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
34 hits · last 30 days
node
30
OpenAI (training)
1
Resources
typescript-char — npm install typescript-char · libregistry