Skip to content

Commit

Permalink
Merge pull request #43 from samchon/v2.0
Browse files Browse the repository at this point in the history
Fix #41 and Report #42
  • Loading branch information
samchon authored May 13, 2022
2 parents a8221c0 + 62d35b4 commit 58a8f59
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const stringify = fast({
nullable: false,
},
gender: {
anyOf: [
oneOf: [
{ type: "string" },
{ type: "number" }
],
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "typescript-json",
"version": "2.0.9",
"version": "2.0.10",
"description": "Faster JSON stringify with only one line",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down Expand Up @@ -39,7 +39,7 @@
"typescript": "^4.6.4"
},
"dependencies": {
"fast-json-stringify": "^3.1.0",
"fast-json-stringify": "^3.2.0",
"nested-error-stacks": "^2.1.1",
"tstl": "^2.5.6",
"uuid": "^8.3.2"
Expand Down
2 changes: 1 addition & 1 deletion src/factories/SchemaFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export namespace SchemaFactory
return unions[0];
else
return {
anyOf: unions
oneOf: unions
};
}

Expand Down
2 changes: 1 addition & 1 deletion test/features/test_stringify_atomic_union.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export function test_stringify_atomic_union(): void
const expected: string = JSON.stringify(value)

if (json !== expected)
throw new Error("Bug on TSON.createStringifier(): failed to understand the atomic union type.");;
throw new Error("Bug on TSON.createStringifier(): failed to understand the atomic union type.");
};

test(true);
Expand Down
20 changes: 20 additions & 0 deletions test/issues/fast-json-stringify-top-level-one-of.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import TSON from "../../src";

export function fast_json_stringify_top_level_one_of(): void
{
const top = TSON.createStringifier<number|string>();
const capsuled = TSON.createStringifier<IMember>();

console.log("TOP LEVEL UNION")
console.log(top.toString());
console.log("-----------------------------------");
console.log("THE CAPSULED UNION");
console.log(capsuled.toString());
}

interface IMember
{
id: string;
name: string;
sex: number | string;
}
2 changes: 1 addition & 1 deletion test/manual.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ runner.register({
compiler: "ttypescript"
});

const program = require("./features/test_stringify_array_generic_alias.ts");
const program = require("./issues/fast-json-stringify-top-level-one-of.ts");
for (const value of Object.values(program))
if (typeof value === "function")
value();

0 comments on commit 58a8f59

Please sign in to comment.