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

Static member added by class decorator is not emitted in types #57558

Closed
yoursunny opened this issue Feb 27, 2024 · 1 comment
Closed

Static member added by class decorator is not emitted in types #57558

yoursunny opened this issue Feb 27, 2024 · 1 comment

Comments

@yoursunny
Copy link

πŸ”Ž Search Terms

class decorator, static member

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about decorators

⏯ Playground Link

https://www.typescriptlang.org/play?ts=5.5.0-dev.20240226#code/GYVwdgxgLglg9mABAQwCaoPrADwBUB8AFFMgE4DmAplAFyJiUDuhAlALz64A0i0AHnWRgAnizqEGzdpxaIAZIgDeiYONkd6IALYAjSqUQBfJQChEiUtRCkkAeR0ArStAB0yAM7uY5MMTJUoHmVVRFYOAEYjFhNDExMAATRMYBMIABsPd0QAZVNY1IR3ODTKFzS4ckJsl2BWFgBuEyA

πŸ’» Code

function add_f<T>(target: new()=>T, ctx: any): (new()=>T) & { f: () => number } {
  return Object.assign(target, { f: ()=>1 })
}

@add_f
class S {
}

console.log(S.f());

πŸ™ Actual behavior

.d.ts emits:

declare class S {
}

Errors include:

Property 'f' does not exist on type 'typeof S'.

Runtime behavior is correct: it prints 1.

πŸ™‚ Expected behavior

.d.ts emits:

declare class S {
  static f(): number;
}

No error.

Additional information about the issue

No response

@fatcerberus
Copy link

Looks like #4881

@yoursunny yoursunny closed this as not planned Won't fix, can't repro, duplicate, stale Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants