gristlabs / ts-interface-builder

Compile TypeScript interfaces into a description that allows runtime validation
Apache License 2.0
132 stars 28 forks source link

--ignore-not-supported, GenericRecords to object, resolve namespaces #28

Open Crusader4Christ opened 4 years ago

Crusader4Christ commented 4 years ago

Do not throw exception on non supported features. GenericRecords transforms to object Namespaces content are parsed

zenflow commented 4 years ago

@Crusader4Christ It seems the new test ("should compile namespace to runtime code") is also responsible for testing --ignore-not-supported. I think that --ignore-not-supported should have it's own test, like all the other flags. Also there's no updates regarding the new "GenericRecords to object feature". I think (if I can guess what it is) it can just be an addition to the sample.ts & sample-ti.ts fixtures.

So looking at the test you added, I can see how the "resolve namespaces" feature has been implemented. I guess this lets us use ts-interface-builder/checker with types that are in namespaces, in basic scenarios, but what about:

  1. Types that depend on namespaced types. e.g. type IMyFoo: MyNamespace.IFoo | null.. will that work? (not sure)
  2. Types that have the same name as a namespaced type. Can I compile & use a type suite with IThing, MyNamespace.IThing & MyOtherNamespace.IThing? (with this implementation, no)

Just trying to look at this holistically, in terms of support for namespaces in general. Maybe this is a good stepping stone & these issues can be left for later, since I guess it would be a bit of work between this lib & ts-interface-checker.