Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated TypeScript imports non-existent files when unions are used in imported file(s) #6485

Closed
CS-Labs opened this issue Feb 22, 2021 · 5 comments

Comments

@CS-Labs
Copy link

CS-Labs commented Feb 22, 2021

This is a follow-on to issue #4637 which still appears to exist in residual forms.

The issue described in issue 4637 still occurs when unions are being used in one of the files being imported. (Using the latest version of flatc 1.12.0).

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;

Run the command:

flatc -o out/ts --ts --gen-all --no-fb-import ./main.fbs

And the output will be:

// automatically generated by the FlatBuffers compiler, do not modify

import * as NS2526511929974982885 from "./nested_generated";
export namespace schemas { 
export import NestedB = NS2526511929974982885.schemas.NestedB; }
export namespace schemas { 
export import NestedA = NS2526511929974982885.schemas.NestedA; }
/**
 * @enum {number}
 */
export namespace schemas{
export enum NestedUnion{
  NONE= 0,
  NestedA= 1,
  NestedB= 2
}};
.....
....
....

What is expected? The flatbuffer definitions should be self contained within a single generated file.

Let me know if I need to provide any additional information.

Thanks

@aardappel
Copy link
Collaborator

@krojew

@krojew
Copy link
Contributor

krojew commented Feb 25, 2021

The issue doesn't seem to exist in the new TS support. Can you check current master?

@CS-Labs
Copy link
Author

CS-Labs commented Feb 25, 2021

Hey,

It appears like valid TypeScript is being generated on the master version (c0be1cb).

For reference, I regenerated things with:

flatc -c -o out main.fbs --ts --gen-all

Is the next official release of this library going to be 2.0? If so is there an estimated timeframe for this release?

Thanks

@krojew
Copy link
Contributor

krojew commented Feb 25, 2021

You can follow the tracking issue here: #6353

@CS-Labs
Copy link
Author

CS-Labs commented Feb 25, 2021

Thanks!

@CS-Labs CS-Labs closed this as completed Feb 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants