Skip to content

Commit

Permalink
chore: allow array of JsonArray
Browse files Browse the repository at this point in the history
  • Loading branch information
HuiSF committed Aug 1, 2024
1 parent bdff20c commit cce2bdb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 15 additions & 0 deletions packages/core/__tests__/singleton/Auth/type.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,20 @@ describe('type validity', () => {

expect(a).toEqual([1, 2, 'hi', { key: 'value' }]);
});

it('can contain property that has a value as array of JsonArray', () => {
const value: JWT = {
payload: {
otherProperty: [[2, 'hi', { key: 'value' }], 1],
},
toString: () => 'mock',
};
const a = value.payload.otherProperty as (
| ({ key: string } | number | string)[]
| number
)[];

expect(a).toEqual([[2, 'hi', { key: 'value' }], 1]);
});
});
});
2 changes: 1 addition & 1 deletion packages/core/src/singleton/Auth/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ interface JwtPayloadStandardFields {
type JsonPrimitive = null | string | number | boolean;

/** JSON array type */
type JsonArray = (JsonPrimitive | JsonObject)[];
type JsonArray = (JsonPrimitive | JsonObject | JsonArray)[];

/** JSON Object type */
interface JsonObject {
Expand Down

0 comments on commit cce2bdb

Please sign in to comment.