You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The foo.ts file will compile successfully without errors, but the generated foo.d.ts file will be incorrect because it contains a syntax error (Foo.__#1@#bar, ts(1005)).
As a result, any TypeScript subproject that depends on this compiled code will fail at compile time due to the invalid syntax in the foo.d.ts file.
🙂 Expected behavior
Enforce an explicit return type for the public static bar() method, as the presence of it currently allows bypassing this issue.
Otherwise, adjust how TypeScript infers the return types of JavaScript's private static methods.
Additional information about the issue
No response
The text was updated successfully, but these errors were encountered:
🔎 Search Terms
"javascript private static methods return type inference", "private static method inference error in declaration file"
🕗 Version & Regression Information
⏯ Playground Link
https://www.typescriptlang.org/play/?ts=5.9.0-dev.20250406#code/MYGwhgzhAEBiD29oG8BQrqehALmHAlsNAMQBGYATgBQCUK0AvultAA4CuZIR2ehxCjXppWrSgFMcHSgDs4iAHTkqAbgxZmqRkA
💻 Code
foo.ts
:foo.d.ts
:🙁 Actual behavior
The
foo.ts
file will compile successfully without errors, but the generatedfoo.d.ts
file will be incorrect because it contains a syntax error (Foo.__#1@#bar
,ts(1005)
).As a result, any TypeScript subproject that depends on this compiled code will fail at compile time due to the invalid syntax in the
foo.d.ts
file.🙂 Expected behavior
Enforce an explicit return type for the
public static bar()
method, as the presence of it currently allows bypassing this issue.Otherwise, adjust how TypeScript infers the return types of JavaScript's private static methods.
Additional information about the issue
No response
The text was updated successfully, but these errors were encountered: