microsoft / microsoft/TypeScript
Adding a compilerOption to disable error on property override accessor in 4.0.beta
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
Search Terms
property override accessor
Suggestion
Previously in 3.9, property can override an accessor with no emit errors. And in 4.0 beta, a break change was introduced by #33509.
It's reasonable to report an error on property override accessor in most case, but I'm using experimentalDecorators to inject a property accessor in prototype.
Currently I cannot find a solution for this use case, so I'm suggesting to add a new compilerOption to disable this check(strictOnly?) for compatibility.
Use Cases
class Animal {
private _age: number
get age(){ return this._age }
set age(value){ this._age = value }
}
class Dog extends Animal {
@defaultValue(100) age: number; // Unexpected error here
}
function defaultValue(value) {
return (obj, name) => {
Object.defineProperty(obj, name, {
get() { return value }
})
}
}
Checklist
My suggestion meets these guidelines:
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
- This feature would agree with the rest of TypeScript's Design Goals.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading this issue together with the referenced breaking change in #33509 and reviewing how compiler options and property/accessor override diagnostics are handled. The issue names no files or tests; done would require an agreed compatibility option that suppresses this diagnostic without changing emitted JavaScript, with coverage for the decorator example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 28/100