typia icon indicating copy to clipboard operation
typia copied to clipboard

Reuse `is` functions for code size

Open miyaji255 opened this issue 1 year ago • 1 comments

Feature Request

Reuse already created is given as an argument to reduce the code size of is for large interfaces.

Idea

Typia works without this, so I think it acceptable to have strict conditions.

  • If it's not the type you're looking for, ignore it.
  • Ignore variable symbols even if they do not appear. ex:) typia.is<User>(), validators.user
  • Ignore any cases beginning with _, $.

Example

import typia from "typia";

interface User {
  name: string;
  homepage: string;
  age: number;
}

interface Comment {
  author: User;
  content: string
}

interface Article {
  author: User;
  content: string;
  comments: Comment[]
}

const isUser = typia.createIs<User>();
const isComment = typia.createIs<Comment>(isUser);
const isArticle = typia.createIs<Article>(isUser, isComment);

miyaji255 avatar Dec 02 '24 13:12 miyaji255

I have no idea about this way. Would you challenge about this issue?

samchon avatar Dec 02 '24 18:12 samchon

Close due to no challenge.

samchon avatar Aug 08 '25 15:08 samchon