Description
π Search Terms
circular definition binding inference
π Version & Regression Information
- This changed between versions 5.3.3 and 5.4.0-beta (5.4.0-dev.20240110 and 5.4.0-dev.20240111)
- This changed in PR Use symbols of type aliases when emitting declarationsΒ #56087
β― Playground Link
π» 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.