Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
acutmore opened this issue Feb 9, 2024 · 3 comments Β· Fixed by #57849 Β· May be fixed by #57396
Closed

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

acutmore opened this issue Feb 9, 2024 · 3 comments Β· Fixed by #57849 Β· May be fixed by #57396
Assignees
Labels
Fix Available A PR has been opened for this issue Needs Investigation This issue needs a team member to investigate its status.

Comments

@acutmore
Copy link
Contributor

acutmore commented Feb 9, 2024

πŸ”Ž 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.

@RyanCavanaugh
Copy link
Member

Bisects to #56087

@acutmore
Copy link
Contributor Author

acutmore commented Feb 9, 2024

Bisects to #56087

Thanks! I wrongly thought it was #56753, which merged the day after and the reproduction does involve destructuring.

@Andarist
Copy link
Contributor

Andarist commented Feb 9, 2024

I’ll try to investigate this over the weekend

@RyanCavanaugh RyanCavanaugh added the Needs Investigation This issue needs a team member to investigate its status. label Feb 12, 2024
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 5.5.0 milestone Feb 12, 2024
@typescript-bot typescript-bot added the Fix Available A PR has been opened for this issue label Feb 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fix Available A PR has been opened for this issue Needs Investigation This issue needs a team member to investigate its status.
Projects
None yet
5 participants