thrift-typescript icon indicating copy to clipboard operation
thrift-typescript copied to clipboard

Strict unions cause potential name conflicts

Open hayes opened this issue 6 years ago • 1 comments

Strict unions create a lot of new exported type names. This can cause name conflicts when they are imported into the index file.

The specific case I am running into is that one of my schemas has both an Attribute and AttributeType where Attribute is a union, and has a create an AttributeType union type, which conflicts with the thrift AttributeType.

I don't think this can be solved in a non-breaking way, but for v4, it would be nice if types were generated in a way that is less likely to have name collisions. My proposal for this would be to have the index use namespace imports instead eg import * as Foo from ./Foo. and then do export { Foo } . Then when using a namespace you would could import * as Namespace from './path/to/namespace and then Do Namespace.Foo.Args or Namespace.Foo.Strict

hayes avatar Aug 01 '19 19:08 hayes

Similar problem, struct X and struct XArgs and struct XResult is conflicts and broken

another problem is a field named arguments, also a diagnosis here

Kingwl avatar Oct 21 '19 09:10 Kingwl