mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-11 15:37:27 +00:00
Fix for invalid null returns (#4318)
* Eclipse ignore * TypeScript support * Prefixing enums * Test results * Merged JS and TS generators * Fixed AppVeyor build problems * Fixed more AppVeyor build problems * Fixed more AppVeyor build problems * Changed TS flag to options struct * Storing options by value * Removed unneeded const * Re-export support for unions * Uint support * Casting bools to numbers for mutation * TS shell tests * Reverted generates js test file to original version * Backing up js tests and properly generating test data * Not importing flatbuffers for TS test generation * Not overwriting generated js for tests * AppVeyor test fixes * Generating the most strict TS code possible * Not returning null when creating vectors * Not returning null from struct contructors
This commit is contained in:
committed by
Wouter van Oortmerssen
parent
55dec4d2f8
commit
3d2cf554d7
@@ -955,7 +955,7 @@ void GenStruct(const Parser &parser, StructDef &struct_def,
|
||||
|
||||
if (lang_.language == IDLOptions::kTs) {
|
||||
code += "static create" + struct_def.name + "(builder:flatbuffers.Builder";
|
||||
code += arguments + "):flatbuffers.Offset|null {\n";
|
||||
code += arguments + "):flatbuffers.Offset {\n";
|
||||
} else {
|
||||
code += object_name + ".create" + struct_def.name + " = function(builder";
|
||||
code += arguments + ") {\n";
|
||||
@@ -1049,8 +1049,7 @@ void GenStruct(const Parser &parser, StructDef &struct_def,
|
||||
type += " | Uint8Array";
|
||||
}
|
||||
code += "Vector(builder:flatbuffers.Builder, data:" + type +
|
||||
"):flatbuffers.Offset|null {\n";
|
||||
code += "if(!data){\n return null;\n}\n";
|
||||
"):flatbuffers.Offset {\n";
|
||||
} else {
|
||||
code += object_name + ".create" + MakeCamel(field.name);
|
||||
code += "Vector = function(builder, data) {\n";
|
||||
|
||||
Reference in New Issue
Block a user