-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Type does not follow workspace since 4.3.2 #44488
Comments
Condensed as far as I felt needed, this is a 4.2 -> 4.3 regression type StringFunc = (a: string) => void;
declare function startHttpServer(x: { uses: Record<string, NumberFunc | StringFunc>; }): void;
export interface BoolFunc {
(req: boolean): void;
}
export interface NumberFunc extends BoolFunc {
(req: number): void;
}
startHttpServer({
uses: {
'foo.Txt': (req) => {
}
}
}) |
Amazing @RyanCavanaugh ! |
Shrunk it down even further, seems to be specific to the contextual typing when there's a union of functions in that position type StringFunc = (a: string) => void;
declare function startHttpServer(x: { uses: Record<string, NumberFunc | StringFunc>; }): void;
export interface BoolFunc {
(req: boolean): void;
}
export interface NumberFunc extends BoolFunc {
(req: number): void;
}
startHttpServer({
uses: {
'foo.Txt': (req) => {
}
}
}) |
@orta that's not a regression, though - longstanding behavior |
This seems off. It feels like previously working before is a bug though, on 4.2 it the contextual arg is a string but it 'ideally' should be The 4.3 changes might have just brought it inline with the rest of the type system? |
Hi, My opinion is probably not highly relevant because I lack a lot of information here, and I'm not sure wether it's a bug or a correction. But the fact the this behavior changes between 2 minors is maybe an issue in itself. Best Regards, |
Both Major and Minors are effectively major versions for TypeScript, see for the general reasoning #14116 (comment) which is why you see long release notes for every major/minor combo. I chatted with one of the engineers who I figured might have made the changes for this and they said this change is intentional, ignoring the other functions in the type system because they had an overload was a bug fixed in #42620 |
Make sense for the majors thanks. For the rest I'm not sure I agree with the fix then. In the repro provided by you, the More than that, I can not help the typing, if I put Anyway, in the end if it's to align the typing system, I have no say in this. |
Bug Report
Hello team,
Not sure if it's a limitation or a bug, but when using types across workspaces, some of them are not following along.
I can not explain why, but I have a small repro
🔎 Search Terms
types, express, workspaces, references,
🕗 Version & Regression Information
⏯ Playground Link
git clone https://github.com/bodinsamuel/ts-workspace-typing-issue.git cd ts-workspace-typing-issue yarn yarn tsc -b
🙁 Actual behavior
Express

req
andres
are typed as any🙂 Expected behavior
Correct express typing
The text was updated successfully, but these errors were encountered: