Skip to content

Maximum call stack size exceeded in isJSLiteralType #42445

Closed
@rbuckton

Description

@rbuckton

This was discovered in the docker tests run for office-ui-fabric:

image

The function in question is here:
https://github.com/microsoft/TypeScript/blob/424b805d6166c5095be97d8328ebaf1968ec1028/src/compiler/checker.ts#L14088-L14105

        function isJSLiteralType(type: Type): boolean {
            if (noImplicitAny) {
                return false; // Flag is meaningless under `noImplicitAny` mode
            }
            if (getObjectFlags(type) & ObjectFlags.JSLiteral) {
                return true;
            }
            if (type.flags & TypeFlags.Union) {
                return every((type as UnionType).types, isJSLiteralType);
            }
            if (type.flags & TypeFlags.Intersection) {
                return some((type as IntersectionType).types, isJSLiteralType);
            }
            if (type.flags & TypeFlags.Instantiable) {
                return isJSLiteralType(getResolvedBaseConstraint(type));
            }
            return false;
        }

The getResolvedBaseConstraint function can return type in some cases, creating a circularity.

I will be adding a fix as part of #42431.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions