Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

--noImplicitOverride#39669

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
DanielRosenwasser merged 76 commits intomicrosoft:masterfromKingwl:exprement-override
Mar 26, 2021

Conversation

@Kingwl
Copy link
Contributor

@KingwlKingwl commentedJul 20, 2020
edited
Loading

Related#38905 ,#9034
Fixes#2000

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

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

  1. used withoutnoImplicitOverride 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 arethe same as the method.

  6. node in ambient context:not check.

  7. must before accessibility modifier

  8. cannot be used with thedeclarestatic 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? AsSuggestion 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)}}

alexrock, ifiokjr, rowbotman, InExtremaRes, Dionis-mgn, soncodi, cherryblossom000, J-Fields, dested, intellild, and 54 more reacted with thumbs up emojiachimmihca, likern, c9r, Trass3r, krozner, kirillgroshkov, Basssiiie, celian-rib, mass10, kaznovac, and 4 more reacted with heart emojimass10, kaznovac, jonlepage, Enteleform, and LittleIronMan reacted with rocket emojiJack-Works, mass10, kirillgroshkov, and celian-rib reacted with eyes emoji
@Kingwl
Copy link
ContributorAuthor

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

@typescript-bot
Copy link
Collaborator

typescript-bot commentedJul 20, 2020
edited by orta
Loading

The TypeScript team has xxyy

Heya@Kingwl, I've started to run the tarball bundle task on this PR at37ada55. You can monitor the buildhere.

@typescript-bot
Copy link
Collaborator

typescript-bot commentedJul 20, 2020
edited
Loading

Heya@Kingwl, I've started to run the parallelized Definitely Typed test suite on this PR at37ada55. You can monitor the buildhere.

@typescript-bot
Copy link
Collaborator

typescript-bot commentedJul 20, 2020
edited
Loading

Hey@Kingwl, I've packed this intoan installable tgz. You can install it for testing by referencing it in yourpackage.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 runningnpm install.


There is also a playgroundfor this build.

@typescript-bottypescript-bot added the For Uncommitted BugPR for untriaged, rejected, closed or missing bug labelJul 21, 2020
@KingwlKingwl marked this pull request as ready for reviewAugust 19, 2020 03:04
@Kingwl
Copy link
ContributorAuthor

Emmmm.... Need review and feedback

@Kingwl
Copy link
ContributorAuthor

@typescript-bot pack this.

@typescript-bot
Copy link
Collaborator

typescript-bot commentedAug 19, 2020
edited
Loading

Heya@Kingwl, I've started to run the tarball bundle task on this PR at2fd560a. You can monitor the buildhere.

@typescript-bot
Copy link
Collaborator

typescript-bot commentedAug 19, 2020
edited
Loading

Hey@Kingwl, I've packed this intoan installable tgz. You can install it for testing by referencing it in yourpackage.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 runningnpm install.


There is also a playgroundfor this build.

@Kingwl
Copy link
ContributorAuthor

@typescript-bot pack this.

@DanielRosenwasser
Copy link
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.

Kingwl, whzx5byb, alex-okrushko, Basssiiie, a11delavar, felixhirt, and v1rtl reacted with hooray emojiKingwl, a11delavar, and v1rtl reacted with heart emojiKingwl, alexrock, a11delavar, and v1rtl reacted with rocket emojiKingwl, a11delavar, and v1rtl reacted with eyes emoji

@typescript-bot
Copy link
Collaborator

@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
ContributorAuthor

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

@DanielRosenwasserDanielRosenwasser merged commit2f0c8b2 intomicrosoft:masterMar 26, 2021
@typescript-bot
Copy link
Collaborator

@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
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. Isoverride y() {} a valid JS class member?

@Kingwl
Copy link
ContributorAuthor

Kingwl commentedApr 7, 2021
edited
Loading

@Jack-Works Nope. Fixed in#43536.

@danfma
Copy link

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
Member

@danfma can you give an example?

danfma reacted with rocket emoji

@danfma
Copy link

Yes.

On the left side, it's the original code. So, I tried to put the override in the constructor likeprotected 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

andrewbranch, Kingwl, InExtremaRes, and whzx5byb reacted with thumbs up emoji

@Kingwl
Copy link
ContributorAuthor

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

@danfma
Copy link

danfma commentedApr 24, 2021
edited
Loading

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
Member

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

danfma reacted with thumbs up emoji

@Kingwl
Copy link
ContributorAuthor

Okay. Looking forward for the good news :XP

@jogibear9988
Copy link

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

@SLaks
Copy link

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

hearnden, karol-depka, AlansCodeLog, and gdplouis reacted with thumbs up emoji

@Kingwl
Copy link
ContributorAuthor

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

No plan yet.

@guilhermesimoes
Copy link

Is there a way to apply this to my entire projectexcept to classes that inherit from a particular class (likeReact.Component, for example)?

@ekilah
Copy link

ekilah commentedJun 29, 2023
edited
Loading

Same question/need as@guilhermesimoes - getting errors onstate andrender inside aReact.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-Reactclasses 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:3TS4114:Thismembermusthavean'override'modifierbecauseitoverridesamemberinthebaseclass'Component<IProps, IState, any>'.20|IState21|>{>22|state:IState={}|^^^^^23|24|render(){ERRORinsrc/SomeComponent/index.tsx:24:3TS4114:Thismembermusthavean'override'modifierbecauseitoverridesamemberinthebaseclass'Component<IProps, IState, any>'.22|state:IState={}23|>24|render(){|^^^^^^25|return(
guilhermesimoes reacted with thumbs up emoji

@microsoftmicrosoft locked asresolvedand limited conversation to collaboratorsOct 21, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.

Reviewers

@andrewbranchandrewbranchandrewbranch approved these changes

@DanielRosenwasserDanielRosenwasserDanielRosenwasser approved these changes

@sandersnsandersnAwaiting requested review from sandersn

@RyanCavanaughRyanCavanaughAwaiting requested review from RyanCavanaugh

+1 more reviewer

@mprobstmprobstmprobst left review comments

Reviewers whose approvals may not affect merge requirements

Labels

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

Projects

Archived in project

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Support override keyword on class methods

19 participants

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

[8]ページ先頭

©2009-2025 Movatter.jp