question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Parameter decorators in setter is a valid syntax ?

See original GitHub issue

TypeScript Version: 4.0.5

Search Terms: parameter decorators, setter

Code

class A {
    set c(@log('c1') c1: string) {}
}

Expected behavior: Throw error.

Actual behavior: No errors now, and performs strange behaviours. Please check playground.

Playground Link: https://www.typescriptlang.org/play?#code/GYVwdgxgLglg9mABAGzgcwBQGcoCcBciOuMYaAlIgN4BQi9iuAplCLkqJLAohlAIa40LQgHkARgCsm0ADR0GigA644SprigBPANJMthYqTSIAPkS0BbcXGTzFywf0ssNASTAATJgA9C-MC1KWgdECAQsWyYAOlRMYnIFRABfGlSaCGR+LCxEAEFqJMQAemKUdEQoAHcYCCYigAE4jAByfhbExSwWRH4MJvRW-gBGDt7hwzxjYPTFUvKTBDrG5pbxDqLuqERxDHEJoimyGZoi+bA4Bc2eiH7ViFHKB8mSY+pU1KA

Related Issues:

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
RyanCavanaughcommented, Nov 11, 2020

Would have to ask @rbuckton

0reactions
Frezccommented, Dec 12, 2020

OK, whether it’s allowed or not. The implementation in TS is strange, it’s exactly a bug. IMHO, TS can disallow this syntax or fix this bug.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The @property Decorator in Python: Its Use Cases ...
The syntax used to define properties is very concise and readable. You can access instance attributes exactly as if they were public attributes ......
Read more >
How To Use Decorators in TypeScript - DigitalOcean
In TypeScript, you can create decorators using the special syntax ... is going to be called with the someBooleanFlag parameter set to true...
Read more >
Primer on Python Decorators
Decorators provide a simple syntax for calling higher-order functions. ... For our purposes, a function returns a value based on the given arguments....
Read more >
TypeScript decorators basics - Jannik Wempe
Each of the decorator functions receives different parameters. The accessor decorator is an exception, because it is essentially just a method ...
Read more >
Documentation - Decorators - TypeScript
The expression for the class decorator will be called as a function at runtime, with the constructor of the decorated class as its...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found