Skip to content

Type.Evaluate doesn't respect Type.Base during Type.Intersect #1470

@orimay

Description

@orimay

When I try to intersect a type extended from base and then evaluate it, it turns into never

import { Type, type StaticDecode } from 'typebox';

class TId extends Type.Base<string> {}

const schemaNonEvaluated = Type.Intersect([
  new TId(),
  new TId(),
]);
type TNonEvaluated = StaticDecode<typeof schemaNonEvaluated>;

/**
 *  const schemaNonEvaluated: Type.TIntersect<[TId, TId]>;
 *  type TNonEvaluated = string;
 */

const schemaEvaluated = Type.Evaluate(schemaNonEvaluated);
type TEvaluated = StaticDecode<typeof schemaEvaluated>;

/**
 *  const schemaEvaluated: Type.TNever;
 *  type TEvaluated = never;
 *  
 *  instead of
 *  
 *  const schemaEvaluated: TId;
 *  type TEvaluated = string;
 */

Showcase: https://play.vuejs.org/#eNqNlMty2jAUhl9Fo00IQ+1Fu6IOnaZlQRe003gXZaHYB+PEljTSMU6G4d1zJAMxt0w2HnSu3y9+e81/GhOtGuBjnrjMlgaZA2wMq6QqbgRHJ/hEqLI22iJbs/TVwIghPdkdSiyz35DpHNiGLayu2ZXPPOqXq+9CCZVV0jmWznIGLwgqp9+Ujm6lg8ShLVUxYetNqNTK0eZsCbWcazVdyaqRCDm76VpmCsE6yHBwLxRjClo/dnA9Oj49XNPmgJcezenjJr5CL84snATweDikwUPGLnGNO6x0z5XcE8HIYzz4Eb73LEUnO1TEx8JPVO8Cg1OAd5mf0/gZgSfq5rACe6Cmv0z1st2zpFkgc6YX/eilFbP84ujDW0rizpnkQzog1KaiOjolce/AR7xz6ZdamujJaUWeXnt/iG2CrDxmIeJjW6f6mOBLROPGcdy2bdQo81xEma7jbcmPWudNBYL7VrLrhlahI1mLsjhaRF2mrMD+NViS7IOFsqp0+yfE0DYQrBt6lpA9n4k/uS3cPwsO7IoA9jmUtgDs0tO7Ob1eveQO94Pkf3C6ajxjV3bbqJywe3WBdhbujf6K1E39G+x2ojxouI1QLzh9QX59IP0d92v0bX+LmzeR+4iI

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions