Skip to content

--noImplicitOverride - #39669

Merged
DanielRosenwasser merged 76 commits into
microsoft:masterfrom
Kingwl:exprement-override
Mar 26, 2021
Merged

--noImplicitOverride#39669
DanielRosenwasser merged 76 commits into
microsoft:masterfrom
Kingwl:exprement-override

Conversation

@Kingwl

@KingwlKingwl commented Jul 20, 2020

Copy link
Copy Markdown
Contributor

Related #38905 , #9034
Fixes#2000

This pr added the override keyword to mark the class method is overrides a method in the base class.
And a flag called noImplicitOverride and don't break something.

Basically, If the flag turns on, We add the below check.

  1. used without noImplicitOverride flag: ok but less check

  2. If a class member has override modifier and the container class does not extend any class: error

  3. if a class member has override modifier and the name of the method is not existed in the base class: error

  4. if a class member do not has override modifier and the name of the method is exited in the base class: error

  5. properties are the same as the method.

  6. node in ambient context: not check.

  7. must before accessibility modifier

  8. cannot be used with the declarestatic modifier.

  9. cannot be used with a constructor.

Something needs to consider:

  1. class declaration in Ambient context. Should we issue errors in the d.ts files? As Suggestion Backlog Slog, 6/8/2016 #9034 said. Looks needn't.

  2. abstract method or abstract class:

eg:

abstractclassAB{abstractfoo(v: string): void;abstractbar(v: string): void}abstractclassAD1extendsAB{}abstractclassAD2extendsAB{abstractfoo(v: ''): void// need override?}abstractclassAD3extendsAB{overridefoo(v: ''): void{}// need override?abstractbar(): void;// need override?}classD4extendsAB{overridefoo(v: ''): void{}overridebar(v: ''): void{}}
  1. property in constructor parameters:

eg:

classB{publicbaz: number=1;constructor(publicfoo: string,publicbar: number){}}classDextendsB{overridepublicbar: number=1// override required ?constructor(publicfoo: string,publicbaz: number){super(foo,42)}}

@Kingwl

Copy link
Copy Markdown
ContributorAuthor

@typescript-bot run dt.
@typescript-bot pack this.

@typescript-bot

typescript-bot commented Jul 20, 2020

Copy link
Copy Markdown
Contributor

The TypeScript team has xxyy

Heya @Kingwl, I've started to run the tarball bundle task on this PR at 37ada55. You can monitor the build here.

@typescript-bot

typescript-bot commented Jul 20, 2020

Copy link
Copy Markdown
Contributor

Heya @Kingwl, I've started to run the parallelized Definitely Typed test suite on this PR at 37ada55. You can monitor the build here.

@typescript-bot

typescript-bot commented Jul 20, 2020

Copy link
Copy Markdown
Contributor

Hey @Kingwl, I've packed this into an installable tgz. You can install it for testing by referencing it in your package.json like so:

{
"devDependencies": {
"typescript": "https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/80234/artifacts?artifactName=tgz&fileId=24EB196251C0700ECE50C8E4EF36FFE41ECC147DC5822099E673D2E05A67AFE302&fileName=/typescript-4.0.0-insiders.20200720.tgz"
}
}

and then running npm install.


There is also a playground for this build.

@typescript-bottypescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Jul 21, 2020
@Kingwl
Kingwl marked this pull request as ready for review August 19, 2020 03:04
@Kingwl

Copy link
Copy Markdown
ContributorAuthor

Emmmm.... Need review and feedback

@Kingwl

Copy link
Copy Markdown
ContributorAuthor

@typescript-bot pack this.

@typescript-bot

typescript-bot commented Aug 19, 2020

Copy link
Copy Markdown
Contributor

Heya @Kingwl, I've started to run the tarball bundle task on this PR at 2fd560a. You can monitor the build here.

@typescript-bot

typescript-bot commented Aug 19, 2020

Copy link
Copy Markdown
Contributor

Hey @Kingwl, I've packed this into an installable tgz. You can install it for testing by referencing it in your package.json like so:

{
"devDependencies": {
"typescript": "https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/82712/artifacts?artifactName=tgz&fileId=F20A5C267D30CCAF558DD8B90945444BF1ECAF2C9D1D3EF7D1AECB09BA31230402&fileName=/typescript-4.1.0-insiders.20200819.tgz"
}
}

and then running npm install.


There is also a playground for this build.

@Kingwl

Copy link
Copy Markdown
ContributorAuthor

@typescript-bot pack this.

@DanielRosenwasser

Copy link
Copy Markdown
Member

Yeah, I doubt we'll see anything significant, and I will likely merge if it's not too crazy seeing as we can optimize later.

@typescript-bot

Copy link
Copy Markdown
Contributor

@DanielRosenwasser
The results of the perf run you requested are in!

Here they are:

Comparison Report - master..39669

Metricmaster39669DeltaBestWorst
Angular - node (v14.15.1, x64)
Memory used321,274k (± 0.01%)321,290k (± 0.01%)+16k (+ 0.01%)321,215k321,438k
Parse Time1.93s (± 0.43%)1.93s (± 0.61%)-0.00s (- 0.21%)1.91s1.96s
Bind Time0.86s (± 0.57%)0.85s (± 0.80%)-0.01s (- 1.04%)0.84s0.87s
Check Time5.01s (± 0.46%)5.01s (± 0.37%)+0.01s (+ 0.14%)4.96s5.05s
Emit Time6.33s (± 0.48%)6.35s (± 0.63%)+0.03s (+ 0.43%)6.26s6.44s
Total Time14.13s (± 0.28%)14.15s (± 0.33%)+0.02s (+ 0.12%)14.07s14.29s
Compiler-Unions - node (v14.15.1, x64)
Memory used189,310k (± 0.01%)189,355k (± 0.01%)+45k (+ 0.02%)189,314k189,397k
Parse Time0.80s (± 0.69%)0.80s (± 0.87%)-0.00s (- 0.12%)0.79s0.82s
Bind Time0.56s (± 0.40%)0.56s (± 0.67%)-0.01s (- 1.07%)0.55s0.56s
Check Time7.07s (± 0.59%)7.03s (± 0.62%)-0.04s (- 0.62%)6.95s7.14s
Emit Time2.54s (± 0.52%)2.54s (± 0.89%)+0.00s (+ 0.08%)2.50s2.60s
Total Time10.97s (± 0.36%)10.93s (± 0.54%)-0.05s (- 0.44%)10.82s11.08s
Monaco - node (v14.15.1, x64)
Memory used323,900k (± 0.01%)323,966k (± 0.01%)+66k (+ 0.02%)323,941k324,008k
Parse Time1.56s (± 0.43%)1.56s (± 0.82%)-0.00s (- 0.00%)1.53s1.58s
Bind Time0.75s (± 0.80%)0.75s (± 0.92%)-0.00s (- 0.13%)0.73s0.76s
Check Time5.03s (± 0.54%)5.02s (± 0.52%)-0.01s (- 0.26%)4.98s5.10s
Emit Time3.18s (± 0.92%)3.17s (± 0.58%)-0.00s (- 0.16%)3.13s3.22s
Total Time10.52s (± 0.45%)10.50s (± 0.36%)-0.02s (- 0.16%)10.42s10.59s
TFS - node (v14.15.1, x64)
Memory used287,541k (± 0.01%)287,629k (± 0.01%)+88k (+ 0.03%)287,549k287,673k
Parse Time1.26s (± 1.13%)1.25s (± 1.41%)-0.00s (- 0.16%)1.22s1.28s
Bind Time0.72s (± 0.62%)0.72s (± 0.69%)-0.00s (- 0.28%)0.71s0.73s
Check Time4.65s (± 0.59%)4.66s (± 0.31%)+0.01s (+ 0.19%)4.63s4.69s
Emit Time3.26s (± 0.71%)3.26s (± 0.81%)-0.00s (- 0.03%)3.20s3.32s
Total Time9.88s (± 0.42%)9.89s (± 0.28%)+0.00s (+ 0.05%)9.83s9.94s
material-ui - node (v14.15.1, x64)
Memory used441,841k (± 0.06%)441,985k (± 0.00%)+144k (+ 0.03%)441,949k442,005k
Parse Time2.07s (± 0.62%)2.09s (± 0.36%)+0.02s (+ 0.82%)2.07s2.10s
Bind Time0.69s (± 0.69%)0.69s (± 0.43%)-0.00s (- 0.14%)0.69s0.70s
Check Time13.02s (± 0.60%)12.91s (± 0.27%)-0.11s (- 0.85%)12.84s13.00s
Emit Time0.00s (± 0.00%)0.00s (± 0.00%)0.00s ( NaN%)0.00s0.00s
Total Time15.79s (± 0.53%)15.69s (± 0.24%)-0.09s (- 0.60%)15.60s15.78s
System
Machine Namets-ci-ubuntu
Platformlinux 4.4.0-198-generic
Architecturex64
Available Memory16 GB
Available Memory4 GB
CPUs4 × Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
Hosts
  • node (v14.15.1, x64)
Scenarios
  • Angular - node (v14.15.1, x64)
  • Compiler-Unions - node (v14.15.1, x64)
  • Monaco - node (v14.15.1, x64)
  • TFS - node (v14.15.1, x64)
  • material-ui - node (v14.15.1, x64)
BenchmarkNameIterations
Current3966910
Baselinemaster10

Developer Information:

Download Benchmark

@Kingwl

Copy link
Copy Markdown
ContributorAuthor

The benchmark looks good, at least with the option off.

@DanielRosenwasser
DanielRosenwasser merged commit 2f0c8b2 into microsoft:masterMar 26, 2021
@typescript-bot

Copy link
Copy Markdown
Contributor

@DanielRosenwasser
The results of the perf run you requested are in!

Here they are:

Comparison Report - master..39669

Metricmaster39669DeltaBestWorst
Angular - node (v10.16.3, x64)
Memory used344,876k (± 0.02%)344,936k (± 0.02%)+60k (+ 0.02%)344,745k345,113k
Parse Time1.95s (± 0.55%)1.93s (± 0.63%)-0.02s (- 1.03%)1.90s1.96s
Bind Time0.84s (± 0.84%)0.83s (± 0.69%)-0.01s (- 1.07%)0.82s0.85s
Check Time5.09s (± 0.35%)5.08s (± 0.39%)-0.01s (- 0.16%)5.04s5.12s
Emit Time5.94s (± 0.72%)5.91s (± 0.60%)-0.03s (- 0.45%)5.85s6.00s
Total Time13.81s (± 0.45%)13.75s (± 0.31%)-0.06s (- 0.46%)13.67s13.86s
Compiler-Unions - node (v10.16.3, x64)
Memory used203,133k (± 0.12%)203,224k (± 0.03%)+91k (+ 0.04%)203,055k203,325k
Parse Time0.79s (± 0.87%)0.78s (± 0.67%)-0.00s (- 0.51%)0.77s0.79s
Bind Time0.53s (± 1.25%)0.52s (± 1.28%)-0.01s (- 1.89%)0.51s0.53s
Check Time7.55s (± 0.67%)7.46s (± 0.97%)-0.09s (- 1.23%)7.32s7.66s
Emit Time2.61s (± 1.08%)2.58s (± 0.99%)-0.04s (- 1.42%)2.52s2.62s
Total Time11.48s (± 0.59%)11.34s (± 0.77%)-0.14s (- 1.25%)11.21s11.59s
Monaco - node (v10.16.3, x64)
Memory used342,681k (± 0.04%)342,621k (± 0.02%)-60k (- 0.02%)342,485k342,747k
Parse Time1.56s (± 0.89%)1.55s (± 0.50%)-0.01s (- 0.64%)1.53s1.56s
Bind Time0.74s (± 0.78%)0.73s (± 1.21%)-0.01s (- 1.21%)0.72s0.76s
Check Time5.24s (± 0.48%)5.22s (± 0.51%)-0.01s (- 0.27%)5.16s5.28s
Emit Time3.13s (± 0.31%)3.12s (± 0.48%)-0.01s (- 0.38%)3.07s3.14s
Total Time10.67s (± 0.35%)10.63s (± 0.41%)-0.04s (- 0.39%)10.52s10.73s
TFS - node (v10.16.3, x64)
Memory used304,243k (± 0.03%)304,259k (± 0.03%)+16k (+ 0.01%)304,028k304,405k
Parse Time1.21s (± 0.62%)1.20s (± 0.74%)-0.01s (- 0.82%)1.19s1.23s
Bind Time0.70s (± 0.68%)0.70s (± 0.92%)-0.00s (- 0.14%)0.68s0.71s
Check Time4.72s (± 0.59%)4.71s (± 0.46%)-0.00s (- 0.02%)4.67s4.78s
Emit Time3.27s (± 0.93%)3.26s (± 1.12%)-0.01s (- 0.28%)3.17s3.32s
Total Time9.90s (± 0.49%)9.88s (± 0.52%)-0.02s (- 0.23%)9.77s10.01s
material-ui - node (v10.16.3, x64)
Memory used465,477k (± 0.01%)465,438k (± 0.02%)-39k (- 0.01%)465,260k465,623k
Parse Time2.02s (± 0.55%)2.01s (± 0.82%)-0.01s (- 0.35%)1.98s2.04s
Bind Time0.66s (± 1.33%)0.66s (± 0.75%)-0.01s (- 1.06%)0.65s0.67s
Check Time14.32s (± 0.67%)14.22s (± 0.42%)-0.09s (- 0.64%)14.13s14.43s
Emit Time0.00s (± 0.00%)0.00s (± 0.00%)0.00s ( NaN%)0.00s0.00s
Total Time17.00s (± 0.59%)16.89s (± 0.38%)-0.11s (- 0.62%)16.80s17.11s
Angular - node (v12.1.0, x64)
Memory used322,601k (± 0.02%)322,661k (± 0.03%)+61k (+ 0.02%)322,488k322,914k
Parse Time1.93s (± 0.48%)1.92s (± 0.82%)-0.01s (- 0.36%)1.89s1.96s
Bind Time0.81s (± 1.02%)0.82s (± 1.17%)+0.00s (+ 0.12%)0.80s0.84s
Check Time5.01s (± 0.40%)5.01s (± 0.51%)-0.00s (- 0.02%)4.97s5.07s
Emit Time6.04s (± 0.70%)5.99s (± 0.67%)-0.05s (- 0.78%)5.93s6.10s
Total Time13.79s (± 0.41%)13.74s (± 0.43%)-0.05s (- 0.36%)13.62s13.89s
Compiler-Unions - node (v12.1.0, x64)
Memory used190,228k (± 0.23%)190,215k (± 0.13%)-13k (- 0.01%)189,506k190,784k
Parse Time0.78s (± 0.88%)0.77s (± 0.86%)-0.00s (- 0.26%)0.76s0.79s
Bind Time0.53s (± 0.63%)0.53s (± 0.76%)-0.00s (- 0.19%)0.52s0.54s
Check Time7.04s (± 0.75%)6.96s (± 0.45%)-0.07s (- 1.04%)6.88s7.05s
Emit Time2.56s (± 1.02%)2.56s (± 1.09%)+0.00s (+ 0.08%)2.50s2.61s
Total Time10.90s (± 0.61%)10.83s (± 0.32%)-0.07s (- 0.66%)10.76s10.90s
Monaco - node (v12.1.0, x64)
Memory used325,000k (± 0.02%)325,039k (± 0.02%)+39k (+ 0.01%)324,848k325,174k
Parse Time1.54s (± 0.61%)1.53s (± 0.87%)-0.01s (- 0.84%)1.51s1.57s
Bind Time0.72s (± 0.80%)0.72s (± 0.41%)-0.01s (- 0.69%)0.71s0.72s
Check Time5.09s (± 0.70%)5.08s (± 0.67%)-0.01s (- 0.14%)5.03s5.14s
Emit Time3.14s (± 0.78%)3.11s (± 0.74%)-0.03s (- 0.86%)3.07s3.17s
Total Time10.49s (± 0.60%)10.44s (± 0.53%)-0.05s (- 0.48%)10.34s10.58s
TFS - node (v12.1.0, x64)
Memory used288,703k (± 0.02%)288,748k (± 0.02%)+46k (+ 0.02%)288,655k288,904k
Parse Time1.21s (± 0.43%)1.20s (± 1.00%)-0.01s (- 0.41%)1.17s1.23s
Bind Time0.70s (± 1.28%)0.69s (± 0.75%)-0.01s (- 1.01%)0.68s0.70s
Check Time4.65s (± 0.50%)4.63s (± 0.38%)-0.02s (- 0.39%)4.59s4.67s
Emit Time3.18s (± 0.66%)3.17s (± 0.98%)-0.00s (- 0.13%)3.11s3.25s
Total Time9.72s (± 0.41%)9.69s (± 0.49%)-0.03s (- 0.33%)9.59s9.81s
material-ui - node (v12.1.0, x64)
Memory used443,647k (± 0.01%)443,544k (± 0.05%)-103k (- 0.02%)442,584k443,743k
Parse Time2.04s (± 0.54%)2.03s (± 0.45%)-0.01s (- 0.44%)2.01s2.05s
Bind Time0.65s (± 1.05%)0.64s (± 0.73%)-0.01s (- 0.93%)0.63s0.65s
Check Time12.88s (± 0.56%)12.90s (± 0.72%)+0.02s (+ 0.12%)12.76s13.11s
Emit Time0.00s (± 0.00%)0.00s (± 0.00%)0.00s ( NaN%)0.00s0.00s
Total Time15.57s (± 0.51%)15.57s (± 0.65%)+0.00s (+ 0.02%)15.42s15.81s
Angular - node (v14.15.1, x64)
Memory used321,274k (± 0.01%)321,302k (± 0.01%)+28k (+ 0.01%)321,198k321,351k
Parse Time1.93s (± 0.43%)1.92s (± 0.46%)-0.01s (- 0.62%)1.91s1.95s
Bind Time0.86s (± 0.57%)0.86s (± 0.61%)-0.01s (- 0.58%)0.84s0.87s
Check Time5.01s (± 0.46%)5.00s (± 0.49%)-0.01s (- 0.10%)4.95s5.05s
Emit Time6.33s (± 0.48%)6.31s (± 0.52%)-0.02s (- 0.32%)6.21s6.35s
Total Time14.13s (± 0.28%)14.09s (± 0.37%)-0.04s (- 0.30%)13.99s14.20s
Compiler-Unions - node (v14.15.1, x64)
Memory used189,310k (± 0.01%)189,366k (± 0.01%)+57k (+ 0.03%)189,333k189,412k
Parse Time0.80s (± 0.69%)0.79s (± 0.63%)-0.01s (- 0.87%)0.79s0.81s
Bind Time0.56s (± 0.40%)0.55s (± 0.67%)-0.01s (- 1.07%)0.55s0.56s
Check Time7.07s (± 0.59%)7.06s (± 0.48%)-0.01s (- 0.11%)7.01s7.16s
Emit Time2.54s (± 0.52%)2.54s (± 0.41%)+0.00s (+ 0.00%)2.51s2.56s
Total Time10.97s (± 0.36%)10.95s (± 0.35%)-0.02s (- 0.19%)10.88s11.05s
Monaco - node (v14.15.1, x64)
Memory used323,900k (± 0.01%)323,953k (± 0.01%)+53k (+ 0.02%)323,905k324,010k
Parse Time1.56s (± 0.43%)1.56s (± 0.70%)-0.00s (- 0.13%)1.54s1.59s
Bind Time0.75s (± 0.80%)0.74s (± 0.66%)-0.00s (- 0.27%)0.74s0.76s
Check Time5.03s (± 0.54%)5.03s (± 0.44%)+0.00s (+ 0.02%)4.98s5.09s
Emit Time3.18s (± 0.92%)3.16s (± 0.39%)-0.02s (- 0.69%)3.13s3.19s
Total Time10.52s (± 0.45%)10.49s (± 0.26%)-0.03s (- 0.28%)10.43s10.56s
TFS - node (v14.15.1, x64)
Memory used287,541k (± 0.01%)287,632k (± 0.01%)+92k (+ 0.03%)287,559k287,674k
Parse Time1.26s (± 1.13%)1.24s (± 0.91%)-0.01s (- 1.19%)1.22s1.26s
Bind Time0.72s (± 0.62%)0.72s (± 1.49%)+0.00s (+ 0.14%)0.71s0.76s
Check Time4.65s (± 0.59%)4.64s (± 0.51%)-0.00s (- 0.04%)4.59s4.69s
Emit Time3.26s (± 0.71%)3.26s (± 0.70%)-0.01s (- 0.21%)3.19s3.30s
Total Time9.88s (± 0.42%)9.86s (± 0.39%)-0.02s (- 0.23%)9.76s9.92s
material-ui - node (v14.15.1, x64)
Memory used441,841k (± 0.06%)441,994k (± 0.00%)+154k (+ 0.03%)441,971k442,021k
Parse Time2.07s (± 0.62%)2.09s (± 0.52%)+0.02s (+ 1.06%)2.07s2.11s
Bind Time0.69s (± 0.69%)0.69s (± 0.43%)-0.00s (- 0.14%)0.69s0.70s
Check Time13.02s (± 0.60%)12.98s (± 0.47%)-0.04s (- 0.31%)12.90s13.12s
Emit Time0.00s (± 0.00%)0.00s (± 0.00%)0.00s ( NaN%)0.00s0.00s
Total Time15.79s (± 0.53%)15.76s (± 0.42%)-0.02s (- 0.13%)15.66s15.91s
System
Machine Namets-ci-ubuntu
Platformlinux 4.4.0-198-generic
Architecturex64
Available Memory16 GB
Available Memory4 GB
CPUs4 × Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
Hosts
  • node (v10.16.3, x64)
  • node (v12.1.0, x64)
  • node (v14.15.1, x64)
Scenarios
  • Angular - node (v10.16.3, x64)
  • Angular - node (v12.1.0, x64)
  • Angular - node (v14.15.1, x64)
  • Compiler-Unions - node (v10.16.3, x64)
  • Compiler-Unions - node (v12.1.0, x64)
  • Compiler-Unions - node (v14.15.1, x64)
  • Monaco - node (v10.16.3, x64)
  • Monaco - node (v12.1.0, x64)
  • Monaco - node (v14.15.1, x64)
  • TFS - node (v10.16.3, x64)
  • TFS - node (v12.1.0, x64)
  • TFS - node (v14.15.1, x64)
  • material-ui - node (v10.16.3, x64)
  • material-ui - node (v12.1.0, x64)
  • material-ui - node (v14.15.1, x64)
BenchmarkNameIterations
Current3966910
Baselinemaster10

Developer Information:

Download Benchmark

@Jack-Works

Copy link
Copy Markdown
Contributor

https://www.typescriptlang.org/play?ts=4.3.0-dev.20210406#code/MYGwhgzhAECK0G8CwAoa7oE8AUBKRAvqkSqJDACrQCmAHgC7UB2AJjPMmhgPYBu1AJwEBLFtSx5CxVEA

Is this expected? For code

classQ{y(){}}classTextendsQ{overridey(){}}

The nightly playground emits the following JS code

"use strict";classQ{y(){}}classTextendsQ{overridey(){}}

which IMO is invalid. Is override y() {} a valid JS class member?

@Kingwl

Kingwl commented Apr 7, 2021

Copy link
Copy Markdown
ContributorAuthor

@Jack-Works Nope. Fixed in #43536.

@danfma

Copy link
Copy Markdown

The compiler is complaining about the missing override keyword for constructor declared properties but it doesn't allow using the modifier on the constructor too.

@andrewbranch

Copy link
Copy Markdown
Member

@danfma can you give an example?

@danfma

Copy link
Copy Markdown

Yes.

On the left side, it's the original code. So, I tried to put the override in the constructor like protected override readonly context... the compiler will complain.

We had to use like in the right side to force the compiler to accept the code.

image

@Kingwl

Copy link
Copy Markdown
ContributorAuthor

Would we consider to add quickfix for parameter property or allow override in parameter property as @danfma said.😂

@danfma

danfma commented Apr 24, 2021

Copy link
Copy Markdown

By the way, this language feature fits me very well because I'm using an AST transformer to apply some Mobx decorators, and one of these modifiers is the “override” decorator! So, I can read the modifier and translate the code to what Mobx needs!

Thus, thank you! 😬

@andrewbranch

Copy link
Copy Markdown
Member

@Kingwl I think we’re going to allow override in the parameter property, but I’m going to run it by the design meeting on Wednesday.

@Kingwl

Copy link
Copy Markdown
ContributorAuthor

Okay. Looking forward for the good news :XP

@jogibear9988

Copy link
Copy Markdown

I've problems with static fields and override: #43916

@SLaks

SLaks commented Jun 8, 2021

Copy link
Copy Markdown

What about methods that implement interface (as opposed to base class) members?

@Kingwl

Copy link
Copy Markdown
ContributorAuthor

What about methods that implement interface (as opposed to base class) members?

No plan yet.

@guilhermesimoes

Copy link
Copy Markdown

Is there a way to apply this to my entire project except to classes that inherit from a particular class (like React.Component, for example)?

@ekilah

ekilah commented Jun 29, 2023

Copy link
Copy Markdown

Same question/need as @guilhermesimoes - getting errors on state and render inside a React.Component is not helpful, but this flag would be very helpful outside of React (class) components.

without a way to exclude these (either by name, e.g. state, render, componentDidMount, etc.), or specifically for known React class properties (exceptReact or something), or even maybe include/exclude by directory or file extension (e.g. *.ts but not *.tsx), i can't use --noImplicitOverride in my project, but I have lots of non-React classes I'd love to have this protection apply to.

I realize that the TS team is not likely to want to have React-specific things in its codebase, but I just wanted to bring more attention to a common pain point with this feature for a subset of your users :)


Example errors for reference:

ERRORinsrc/SomeComponent/index.tsx:22:3
TS4114: Thismembermusthavean'override'modifierbecauseitoverridesamemberinthebaseclass'Component<IProps, IState, any>'.20|IState21|>{>22|state: IState={}|^^^^^23|24|render(){ERRORinsrc/SomeComponent/index.tsx:24:3
TS4114: Thismembermusthavean'override'modifierbecauseitoverridesamemberinthebaseclass'Component<IProps, IState, any>'.22|state: IState={}23|>24|render(){|^^^^^^25|return(

@microsoftmicrosoft locked as resolved and limited conversation to collaborators Oct 21, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

For Uncommitted BugPR for untriaged, rejected, closed or missing bug

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Support override keyword on class methods

20 participants

@Kingwl@typescript-bot@ifiokjr@DanielRosenwasser@millsp@andrewbranch@sk-@RyanCavanaugh@orta@karol-depka@pcj@evmar@Jack-Works@danfma@jogibear9988@SLaks@guilhermesimoes@ekilah@mprobst@sandersn