Skip to content

Commit

Permalink
fix: don't overload toJSON
Browse files Browse the repository at this point in the history
fixes a recursive stack bug in browsers
  • Loading branch information
andrewmd5 committed Feb 10, 2024
1 parent f89e97a commit 8dbb630
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION="3.0.3-beta.2"
VERSION="3.0.3-beta.3"
MAJOR=3
MINOR=0
PATCH=3
6 changes: 3 additions & 3 deletions Core/Generators/TypeScript/TypeScriptGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ public string CompileJsonMethods(Definition definition)
{
var builder = new IndentedStringBuilder(0);
builder.AppendLine(FormatDocumentation("Serializes the current instance into a JSON-Over-Bebop string", null, 0));
builder.CodeBlock($"public toJSON(): string", indentStep, () =>
builder.CodeBlock($"public stringify(): string", indentStep, () =>
{
builder.AppendLine($"return {definition.ClassName()}.encodeToJSON(this);");
});
Expand Down Expand Up @@ -986,7 +986,7 @@ public override ValueTask<string> Compile(BebopSchema schema, GeneratorConfig co
builder.AppendLine($"invoke: service.{methodName},");
builder.AppendLine($"serialize: {method.Definition.ResponseDefintion}.encode,");
builder.AppendLine($"deserialize: {method.Definition.RequestDefinition}.decode,");
builder.AppendLine($"toJSON: {method.Definition.ResponseDefintion}.encodeToJSON,");
builder.AppendLine($"stringify: {method.Definition.ResponseDefintion}.encodeToJSON,");
builder.AppendLine($"fromJSON: {method.Definition.RequestDefinition}.fromJSON,");
builder.AppendLine($"type: MethodType.{RpcSchema.GetMethodTypeName(methodType)},");
}, close: $"}} as BebopMethod<I{method.Definition.RequestDefinition}, I{method.Definition.ResponseDefintion}>);");
Expand Down Expand Up @@ -1050,7 +1050,7 @@ public override ValueTask<string> Compile(BebopSchema schema, GeneratorConfig co
builder.AppendLine($"id: {method.Id},");
builder.AppendLine($"serialize: {method.Definition.RequestDefinition}.encode,");
builder.AppendLine($"deserialize: {method.Definition.ResponseDefintion}.decode,");
builder.AppendLine($"toJSON: {method.Definition.RequestDefinition}.encodeToJSON,");
builder.AppendLine($"stringify: {method.Definition.RequestDefinition}.encodeToJSON,");
builder.AppendLine($"fromJSON: {method.Definition.ResponseDefintion}.fromJSON,");
builder.AppendLine($"type: MethodType.{RpcSchema.GetMethodTypeName(methodType)},");
});
Expand Down

0 comments on commit 8dbb630

Please sign in to comment.