Details
-
New Feature
-
Status: Open
-
Major
-
Resolution: Unresolved
-
0.9.2
-
None
-
None
Description
Not sure if it's a bug, or I am missing something, or compiler does not allow to create const structs referring to other structs. E.g.:
struct Book { 1: i32 id } struct Author { 1: Book book } const Book bookEx1 = { // example instance of Book 'id': 1 } const Author AuthorEx1 = { // example instance of Author //'book': { 'id': 1 } // This is a copy from above, but works well 'book': BookEx1 // this doesn't work, see below }
When compiling, it gives the following error:
$ thrift -v -gen js:ts model.thrift Scanning model.thrift for includes Parsing model.thrift for types [FAILURE:model.thrift:17] type error: const "AuthorEx1.book" was declared as struct/xception
Problem: I want to refer to other defined const structs by already defined structs from before (e.g. bookEx1) instead of flattening the values. Am I missing something, or is this unsupported, or just a bug?
Use case: for every model, I am creating mock `const` values which the services can re-use in their tests.
I asked this on stackoverflow too: http://stackoverflow.com/questions/32424858/writing-thrift-schemas-non-flattened-struct-constants-makes-me-repetitive