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
classClass{staticStaticMethod(){console.log("static is fine")}Method(){// this works in plain JS, but is considered as an error in TSthis.constructor.StaticMethod()}}newClass().Method()
π Actual behavior
TS emits an error Property 'StaticMethod' does not exist on type 'Function'. ts(2339)
π Expected behavior
no error in TS
Additional information about the issue
this also works well in JS:
classClass{staticStaticMethod(){console.log("Class static")}Method(){// this works in plain JS, but is considered as an error in TS// prints "Derived static"this.constructor.StaticMethod()}}classDerivedextendsClass{staticStaticMethod(){console.log("Derived static")}}newDerived().Method()
π Search Terms
constructor class type
π Version & Regression Information
β― Playground Link
https://www.typescriptlang.org/play/?#code/MYGwhgzhAEDC5WgbwFAEgIBcyYJbGgGVs9gBZAU0wAsB7AEwAoBKZdNYWgOwlpAoB0IWgHNGAIiw580XDABmuLhXHN0AX3SUaDFmzRoA9Ieg050AO60ATgGsYS6AAdwjgFKEANNABGAV0xZGE4eXHoKawp6aEgYrmgI6xtZeIAVQnYzCAEQrGs-YEwbAWJpcio6JjU0TU0UZQs4BAgWAW1KliA
π» Code
π Actual behavior
TS emits an error
Property 'StaticMethod' does not exist on type 'Function'. ts(2339)
π Expected behavior
no error in TS
Additional information about the issue
this also works well in JS:
https://www.typescriptlang.org/play/?#code/MYGwhgzhAEDC5WgbwFAEgIBcyYJbGgGVs9gBZAU0wAsB7AEwAoBKZdNYWgOwlpAoB0IWgHNGAIniQYWHPnHN0AX3SUaDFmzRoA9Dug1cMAO60ATgGsYuLtAAO4G9ABShADTQARgFdM0I9CcPLj0FGYU9NCQUbZhZub+tgAqhCjQ6RnpevZmNpgw4gAiYbgAbhHQsqTi7IYQAkFYZt7AmOYCxHLkVHRMimgqKiig0tDFueWRFAAemBRc9DBSiKiZVfhEJPhqvZqrmRmNfILCYkUlk5VbwAppGYMoKFwUxmMXESwCOxrMQA
The text was updated successfully, but these errors were encountered: