Skip to content

Conversation

@ForwardFeed
Copy link
Contributor

Added IsTypeExtendedInList to fix IsRecursionType
Added recursion check to IsJSONSerializableStrict to ensure the impossibility to add cyclic objects.

The more I learn the more I realize that a whole test series needs to be done to be really safe.
But doing tests makes me want to stare at the ceiling contemplating all seconds that passes and which will never be recovered, so I'm not that much a volunteer.
even if suggestion #6 could be used for handling the testing of that lib.

Added IsTypeExtendedInList to fix IsRecusion
@komed3
Copy link
Owner

komed3 commented Jan 30, 2026

Correct! Tests are important, but I think we can pretty much assume the types in devtypes are good to go - considering all the small and even big improvements we've made over the last few days.

My suggestion: Let's release v2 now, then we'll have a fixed code base we can work with. And if a type comes out to be buggy, we can patch it out fast.

@komed3 komed3 merged commit ea0db18 into komed3:master Jan 30, 2026
@komed3
Copy link
Owner

komed3 commented Jan 30, 2026

A minor fix was needed because

type D = IsJSONSerializableStrict< ( string | undefined )[] >;

was incorrectly returned as true.

Wrapping [ IsJSONSerializableStrict< U > ] extends [ true ] solves the problem ;)

export type IsJSONSerializableStrict< T > =
    [ T ] extends [ ( ...args: any[] ) => any ] ? false
        : [ T ] extends [ bigint | symbol | undefined ] ? false
        : [ T ] extends [ string | number | boolean | null ] ? true
        : [ T ] extends [ readonly ( infer U )[] ]
            ? [ IsJSONSerializableStrict< U > ] extends [ true ] ? true : false
            : [ T ] extends [ object ]
                ? IsTypeRecursive< T > extends true
                    ? false
                    : false extends {
                        [ K in keyof T ]: IsJSONSerializableStrict< T[ K ] >
                    }[ keyof T ] ? false : true
                : false;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants