Skip to content

fix(cddl2ts): infer template literal types from regexp strings#48

Merged
christian-bromann merged 4 commits intomainfrom
cb/custom-channel-regexp-8ddb
Apr 13, 2026
Merged

fix(cddl2ts): infer template literal types from regexp strings#48
christian-bromann merged 4 commits intomainfrom
cb/custom-channel-regexp-8ddb

Conversation

@christian-bromann
Copy link
Copy Markdown
Member

@christian-bromann christian-bromann commented Apr 13, 2026

Summary

  • normalize cddl operator handling so native text types with .regexp are preserved without misclassifying reference operators
  • generalize cddl2ts regexp inference so string regexes containing one or more literal .+ wildcards become template literal types (for example custom:.+, foo_.+, some_.+_name, and multi-slot variants)
  • keep non-template-friendly regexes as plain string/str fallbacks
  • mirror the same generalized behavior in cddl2py with Python-friendly Annotated[...] metadata, plus StringConstraints in Pydantic mode
  • add focused parser, utils, and generator coverage for the generalized regexp case

Testing

  • pnpm run compile
  • pnpm run test:typechecks
  • pnpm exec vitest --config vitest.config.ts --run --coverage.enabled=false packages/cddl/tests/parser.test.ts packages/cddl/tests/utils.test.ts packages/cddl2ts/tests/transform_edge_cases.test.ts packages/cddl2py/tests/transform_edge_cases.test.ts

@webdriverio webdriverio deleted a comment from cursor bot Apr 13, 2026
@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla bot commented Apr 13, 2026

CLA Signed

The committers listed above are authorized under a signed CLA.

@christian-bromann christian-bromann force-pushed the cb/custom-channel-regexp-8ddb branch from ea13105 to 094128f Compare April 13, 2026 20:30
@christian-bromann christian-bromann merged commit e1ff91f into main Apr 13, 2026
7 checks passed
@christian-bromann christian-bromann deleted the cb/custom-channel-regexp-8ddb branch April 13, 2026 20:31
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