Skip to content

refactor: clean up public API surface #24#32

Merged
edloidas merged 1 commit intomasterfrom
issue-24
Mar 29, 2026
Merged

refactor: clean up public API surface #24#32
edloidas merged 1 commit intomasterfrom
issue-24

Conversation

@edloidas
Copy link
Copy Markdown
Owner

Added RollParserError base class with typed error codes and isRollParserError() type guard.
Refactored LexerError, ParseError, EvaluatorError to extend RollParserError.
Narrowed public API by removing internal exports (Lexer, Parser, lex, TokenType, Token).
Created roll-parser/testing subpath export for createMockRng and MockRNGExhaustedError.
Added bounds validation to MockRNG.nextInt.
Replaced hardcoded VERSION with package.json import.
Migrated bun-types to @types/bun.
Aligned line width to 100 chars across biome and rules.

Closes #24

Drafted with AI assistance

Added `RollParserError` base class with typed `RollParserErrorCode` union and `isRollParserError()` type guard derived from a single `as const` array source of truth.
Refactored `LexerError`, `ParseError`, and `EvaluatorError` to extend `RollParserError` with error codes and structured context (`nodeType` for evaluator errors).
Narrowed `src/index.ts` exports by removing `Lexer`, `Parser`, `lex`, `TokenType`, `Token`, and mock RNG re-exports while keeping AST types required by `parse()` return type.
Created `roll-parser/testing` subpath export with `createMockRng` and `MockRNGExhaustedError`, including dedicated ESM/CJS build scripts.
Added bounds validation to `MockRNG.nextInt` that throws `RangeError` for out-of-range values.
Replaced hardcoded `VERSION` constant with `package.json` import, migrated `bun-types` to `@types/bun`, and aligned line width to 100 chars.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@edloidas edloidas self-assigned this Mar 29, 2026
@edloidas edloidas merged commit fec50b1 into master Mar 29, 2026
10 checks passed
@edloidas edloidas deleted the issue-24 branch March 29, 2026 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor: clean up public API surface

1 participant