Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork192
Fix template literal validation tag inheritance in type checking#1656
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:master
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
…ersection handlerCo-authored-by: samchon <13158709+samchon@users.noreply.github.com>
socket-securitybot commentedAug 21, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Review the following changes in direct dependencies. Learn more aboutSocket for GitHub. |
…g to check_templateCo-authored-by: samchon <13158709+samchon@users.noreply.github.com>
Co-authored-by: samchon <13158709+samchon@users.noreply.github.com>
commit: |
Mlocik97 left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
4 .map and .filter loops instead of one reduce? I think we can optimize this.
| .map((row)=>row.filter((tag)=>!!tag.validate)) | ||
| .filter((row)=>!!row.length) | ||
| .map((row)=> | ||
| row.map((tag)=>({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
@copilot let's replace this with one single reduce loop.
Uh oh!
There was an error while loading.Please reload this page.
Template literal types were not inheriting validation tags when intersected with tags like
MaxLengthandPattern. This caused validation to pass incorrectly when it should fail.Problem
Consider this type intersection:
The issue affected all validation functions:
validate,assert,is, and schema generation.Root Cause
The intersection handler correctly processed validation tags and attached them to template literal metadata. However, the code generator for templates (
check_template) was only generating pattern matching code and ignoring thetpl.tagsfield, unlikecheck_stringwhich processes both type checking and validation tags.Solution
Modified
src/programmers/internal/check_template.tsto:check_template_type_tagsfunction similar tocheck_string_type_tagsvalidatescripts and transpile them to runtime checksUpdated call sites in
CheckerProgrammer.tsandcheck_dynamic_key.tsto pass the requiredcontextparameter.After Fix
The fix ensures template literals validate against:
prefix*postfixpattern)MaxLength<10>)Pattern<'^[a-zA-Z0-9_]+$'>)Fixes#1635.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn moreCopilot coding agent tips in the docs.