Skip to content

'Circular definition of import alias' error in 5.4.0-BetaΒ #57357

@acutmore

Description

@acutmore

πŸ”Ž Search Terms

circular definition binding inference

πŸ•— Version & Regression Information

⏯ Playground Link

https://www.typescriptlang.org/dev/bug-workbench/?ts=5.4.0-beta#code/PTAEAEDMEsBsFMB2BDAtvAXKAJsgLsgHR4DOAUNKgA4D2ATnqHgJ5XygDeoAIvsqAF9QkOjVSgA5IWBVRAY3gkS9CQG4yIUJVoMmrdhyEixoAETSWbU6tCaAPAFoHoAK6IHcsekSNkibKDwdKJ0oADmNIqgyADuyMxkZPAAHjqMkG5yeNA0iOHweLwEABQAlJxkoFW2YOCkDilsWQ3B9JXVdAUudHmeiCR4dC5ZRcjFhuUk+NAkMFEA2gC66gKJGYhZOb25A0MjfMW4BFij5RztVX0DnKCEd7I0VCSCoAC8OHzq1TWgnXjdeSOyBs31B1XsTlc7k8qG8vn8gVaoQiUVi8Quvy6PQqYKqd0IDyeABoMQIVolNFA4Eg0Jg9GxiORGvRGJZ2AA1ZCwFzsd6GCm1GAIFDoLAPBRKeiMijUFk3MIFUYvYziKTAIFqRLaOVsnHVTnc+AkoyiVUWfSapKpHX6Hh8N56qoARxcfmyLCwBp5K3UZGw8DksGQnWEmWyuVAck6+HgACV4C7FHgAAryRTKOh2eNOgB8xQxVGgbFg0EQdLKbxzoGzJNKWGzvuZuiujHF6foDqj8Bj2Z5A1TNAlGfz3wVhT4ZFKvspQppotAqGQpel2t0XDbktCJpMao3Gc1TcY-sgyBcsFbac308F1JFdJi9AA1kFS3ggieFCvZbpdQBlIIAG5BMIpqSNIi6lpah70uwAD6AAqDrFGyNCQKA-50EBdBTmQQA

πŸ’» Code

(reduced down from a large project as best I could)

// @filename: data.ts
import type { Data } from './processor';
// import type {} from "./type"; // <-- un-comment and error goes away

export function getData() {
    // @ts-expect-error
    return constructData({}) satisfies [];
}

function constructData(data: Data) {
    const { ...props } = data;
    // return data;             // <-- un-comment and error goes away
    return {
        ...props,
    };
}

// @filename: type.ts
export type Value = {}

// @filename: processor.ts
import { getData } from './data';

import type {
    Value,
} from './type';

export type Data = {
    quantity: Value;
};

declare function createRequestProcessor<Req>(
    pipeline: () => Req,
): Req;

export const processor = createRequestProcessor(
    getData
);

// @filename: main.ts
import { processor } from './processor';
export default processor;

// @filename: workerinterface.ts
import type Server from './main';

export type _T = (typeof Server);

πŸ™ Actual behavior

Errors about circular types

implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.

πŸ™‚ Expected behavior

Either no error, or a clearer error message. The types don't appear to be circular.

Additional information about the issue

The code that is now erroring was already using // @ts-expect-error to ignore an error. Fixing that hidden error avoids this issue.

Adding an unused import (as commented in the same) also fixes the error. So it seems that TypeScript has gotten into an odd state.

Metadata

Metadata

Assignees

Labels

Fix AvailableA PR has been opened for this issueNeeds InvestigationThis issue needs a team member to investigate its status.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions