microsoft / microsoft/TypeScript

Parameter decorators in setter is a valid syntax ?

Open
#41,354 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Domain: Decorators
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

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:

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the TypeScript playground link and the supplied setter example using a parameter decorator. Trace how the compiler parses and validates decorators on setter parameters, then confirm that the example receives the expected diagnostic rather than compiling without errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.