Skip to content

Add setTypeId#254

Merged
waynemwashuma merged 1 commit into
wimaengine:devfrom
waynemwashuma:Add-setTypId
Sep 17, 2025
Merged

Add setTypeId#254
waynemwashuma merged 1 commit into
wimaengine:devfrom
waynemwashuma:Add-setTypId

Conversation

@waynemwashuma
Copy link
Copy Markdown
Collaborator

@waynemwashuma waynemwashuma commented Sep 15, 2025

Objective

Introduces a dedicated function with proper safety documentation to cast arbitrary strings into TypeIds.This can be used to create ids for enums, unions and any type that only exists at compile time not at runtime.

Solution

The solution adds a new setTypeId() function that centralizes unsafe typeid casting to a single, well-documented function

Showcase

The new function should be used sparingly for special cases:

import { setTypeId } from 'wima'

// Only use for special cases where types don't exist at runtime
const enumTypeId = setTypeId("MyEnum") // Use for enums, union types, etc.

// For regular classes, continue using the safe methods:
class MyClass {}
const safeTypeId = typeid(MyClass) // Preferred method for regular types

Migration Guide

No breaking changes were introduced.

Checklist

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly (via function documentation).
  • I have added tests to cover my changes.

@waynemwashuma waynemwashuma self-assigned this Sep 15, 2025
@waynemwashuma waynemwashuma marked this pull request as ready for review September 17, 2025 02:49
@waynemwashuma waynemwashuma merged commit f76ea98 into wimaengine:dev Sep 17, 2025
5 checks passed
@waynemwashuma waynemwashuma deleted the Add-setTypId branch September 17, 2025 02:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:reflect type:enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant