Skip to content

Commit

Permalink
chore(core): fix JsonObject type doesn't allow array of JsonObject as…
Browse files Browse the repository at this point in the history
… field
  • Loading branch information
HuiSF committed Aug 1, 2024
1 parent 7df6057 commit d2d939d
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
@@ -0,0 +1,15 @@
import { JWT } from '../../../src/singleton/Auth/types';

describe('type validity', () => {
describe('JWT type', () => {
it('can contain property that has a value as array of JsonObject', () => {
const value: JWT = {
payload: { otherProperty: 'value' },
toString: () => 'mock',
};
const a = value.payload.otherProperty as { key: string }[];

expect(a).toEqual('value');
});
});
});
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[];
type JsonArray = JsonPrimitive[] | JsonObject[];

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

0 comments on commit d2d939d

Please sign in to comment.