Integer string passes floating decimal string
Bug Report
📝 Summary
`${number & tags.Type<"int32">}` passes decimal string (such as "0.1")
- Typia Version: v6.5.4
-
Expected behavior: Only pass integer string (such as
"1") -
Actual behavior: Also pass decimal string (such as
"0.1")
⏯ Playground Link
https://typia.io/playground/?script=JYWwDg9gTgLgBDAnmYBDANHA3g1BzAZzgF84AzKCEOAIiRVRoG4AoF+gUzmADsYBlGFDgBeOAAMAJFh4BXEACMOwgGS5CAOgAqyDgB4avGAGYATDQB8xcWwDGEHgXgA3VABs4ohMjQaoqHgATKj0jQSgLAAoASiY4AHp42gAGGkwaAEYaOA1clntHeFsACw5bAGsMr3pfYAJQvnComlTYhKShWQ58hyc4ErLy02qfVA06hoEhZuSNLLbEhCguuD0xACFZPDgAQh27Xog3Dg03CDxIrBZPVzd0a-7Sioz7zwGK0xZiNpYgA
💻 Code occuring the bug
import typia, { tags } from "typia";
type intStr = `${number & tags.Type<"int32">}`
const val = typia.random<intStr>(); // "0", "1" ...
const check1 = typia.is<intStr>("0"); // true
const check2 = typia.is<intStr>("0.1"); // true <= Bug !!
Unfortunately, template literal string type cannot utilize type tags.
It's because TypeScript compiler API cannot recognize the intersection tag type in the template literal type.
That's unfortunate. Since typia.random<intStr>() was outputting correctly, I thought it could be obtained. Is there a way to treat strings without other characters (for example, `${boolean}`, `${number & tags.Type<"int32">}`) as a special case?
@samchon I found that ts compiler can handle the intersection tag type in the template literal since v5.1! TS5.1
The interesting thing is that anoter library ts-runtime-checks has the same issue
@miyaji255 Good point, will you challenge this issue?
Sorry, it's hard for me to do.
If it becomes possible, it is okay to challenge.
I'm not affordable to develop this feature.