xddq / ts2typebox

Creating TypeBox code from Typescript types
MIT License
43 stars 3 forks source link

WIP - add ability to parse indexed access types #2

Closed xddq closed 1 year ago

xddq commented 1 year ago

How to test

// Arbitrary example types

export type Address = {
  street: string;
  test: {
    a: string;
  };
};

export type Address2 = {
  street2: Address["test"]["a"];
};
import { Type, Static } from '@sinclair/typebox'

export type Address = Static<typeof Address>
export const Address = Type.Object({
  street: Type.String(),
  test: Type.Object({
    a: Type.String()
  })
})

export type Address2 = Static<typeof Address2>
export const Address2 = Type.Object({
  street2: Type.String()
})
// Arbitrary example types

export type Address = {
  street: string;
  test: {
    a: string;
  };
};

export type Address2 = {
  street2: Address["test"];
};
import { Type, Static } from '@sinclair/typebox'

export type Address = Static<typeof Address>
export const Address = Type.Object({
  street: Type.String(),
  test: Type.Object({
    a: Type.String()
  })
})

export type Address2 = Static<typeof Address2>
export const Address2 = Type.Object({
  street2: Type.Object({
    a: Type.String()
  })
})