google / flatbuffers

FlatBuffers: Memory Efficient Serialization Library

Home Page:https://flatbuffers.dev/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[TS] Top level exports file is not generated when -o path is absolute (flatc 2.0.5, OS: RHEL7)

CS-Labs opened this issue · comments

Flatbuffer version: 2.0.5
OS: RHEL7

Example:

With the following flatbuffer files:
main.fbs

include "example.fbs";

namespace schemas;

table Main {
  example:Example;
}

root_type Main;

example.fbs

include "nested.fbs";

namespace schemas;

table Example {
  nested:NestedWrapper;
  foo:int;
}

root_type Example;

nested.fbs

namespace schemas;

table NestedA {
  a:bool;
  b:byte;
}
table NestedB {
  c:bool;
  d:byte;
}
union NestedUnion {
    NestedA,
    NestedB,
}
table NestedWrapper {
    message: NestedUnion;
}

root_type NestedWrapper;
> flatc --version
flatc version 2.0.5
> mkdir test1
> mkdir test2
> ls
example.fbs  main.fbs  nested.fbs  test1  test2
> pwd
/home/cseely/Desktop/example
> flatc --ts --gen-all -o test1 main.fbs 
> flatc --ts --gen-all -o /home/cseely/Desktop/example/test2 main.fbs 
> ls test1
main.ts  schemas
> ls test2
schemas
> cat test1/main.ts 
export { Example } from './schemas/example';
export { NestedA } from './schemas/nested-a';
export { NestedB } from './schemas/nested-b';
export { NestedUnion, unionToNestedUnion, unionListToNestedUnion } from './schemas/nested-union';
export { NestedWrapper } from './schemas/nested-wrapper';

What is expected? The top level TS file that reexports everything in the namespace should be generated regardless of whether the path provided to -o is relative or absolute.

Thanks!

Thanks for the report. I just hit this as well. Will prioritize this.

Here is my example error for debugging:

foo.fbs:

include "include/bar.fbs";
include "baz.fbs";

namespace derekbailey;

table Foo {
  a:int;
  b:Bar;
  c:Baz;
}

root_type Foo;

baz.fbs:

namespace derekbailey;

table Baz {
  id: int64;
}

include/bar.fbs:

namespace derekbailey;

table Bar {
  name: string;
}

And the command: flatc --ts -I include foo.fbs include/bar.fbs baz.fbs

It produces the following structure:

bar.ts  -- empty
baz.ts  -- empty
foo.ts  -- just two include lines to Bar and Baz
include/
    baz.ts -- seems ok
    foo.ts  -- seems ok

There are no definitions outputted for bar.ts as far as I could tell.