Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revision 0.34.27 #1182

Merged
merged 4 commits into from
Feb 20, 2025
Merged

Revision 0.34.27 #1182

merged 4 commits into from
Feb 20, 2025

Conversation

sinclairzx81
Copy link
Owner

This PR enables Transforms to be embedded within Module types. The updates include new inference paths for StaticDecode as well as updates to TComputed inference to rewrite the Transform signature (Ref(C)) to the reference target. This makes Transforms a form TComputed.

const Z = Type.Module({
  A: Type.String(),
  // └─────────┐
  B: Type.Ref('A'),
  // └─────────┐
  C: Type.Ref('B'),
  // └────────────────────────┐
  T: Type.Transform(Type.Ref('C'))
    .Decode((value) => parseInt(value as string)) // requires as assertion interior to module
    .Encode((value) => value.toString()),
  // └─────────┐
  X: Type.Ref('T'),
  // └─────────┐
  Y: Type.Ref('X'),
  // └─────────┐
  Z: Type.Ref('Y'),
  // └─────┐
}).Import('Z')

Expect(Z).ToStaticDecode<number>()
Expect(Z).ToStaticEncode<string>()

Using Transforms wrapped Ref types require type assertion as it's not possible to infer the reference target interior to the module.

@sinclairzx81 sinclairzx81 merged commit 5130ee5 into master Feb 20, 2025
18 checks passed
@sinclairzx81 sinclairzx81 deleted the transform branch February 20, 2025 07:24
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.

1 participant