-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
--noImplicitOverride #39669
--noImplicitOverride #39669
Conversation
@typescript-bot run dt. |
Hey @Kingwl, I've packed this into an installable tgz. You can install it for testing by referencing it in your
and then running There is also a playground for this build. |
Emmmm.... Need review and feedback |
@typescript-bot pack this. |
Hey @Kingwl, I've packed this into an installable tgz. You can install it for testing by referencing it in your
and then running There is also a playground for this build. |
@typescript-bot pack this. |
@DanielRosenwasser Here they are:Comparison Report - master..39669
System
Hosts
Scenarios
Developer Information: |
The benchmark looks good, at least with the option off. |
@DanielRosenwasser Here they are:Comparison Report - master..39669
System
Hosts
Scenarios
Developer Information: |
Is this expected? For code class Q {
y() {}
}
class T extends Q {
override y() {}
} The nightly playground emits the following JS code "use strict";
class Q {
y() { }
}
class T extends Q {
override y() { }
} which IMO is invalid. Is |
@Jack-Works Nope. Fixed in #43536. |
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. |
@danfma can you give an example? |
Would we consider to add quickfix for parameter property or allow override in parameter property as @danfma said.😂 |
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! 😬 |
@Kingwl I think we’re going to allow |
Okay. Looking forward for the good news :XP |
I've problems with static fields and override: #43916 |
What about methods that implement interface (as opposed to base class) members? |
No plan yet. |
Is there a way to apply this to my entire project except to classes that inherit from a particular class (like |
Same question/need as @guilhermesimoes - getting errors on without a way to exclude these (either by name, e.g. 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: ERROR in src/SomeComponent/index.tsx:22:3
TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'Component<IProps, IState, any>'.
20 | IState
21 | > {
> 22 | state: IState = {}
| ^^^^^
23 |
24 | render() {
ERROR in src/SomeComponent/index.tsx:24:3
TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'Component<IProps, IState, any>'.
22 | state: IState = {}
23 |
> 24 | render() {
| ^^^^^^
25 | return ( |
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.
used without
noImplicitOverride
flag: ok but less checkIf a class member has override modifier and the container class does not extend any class: error
if a class member has override modifier and the name of the method is not existed in the base class: error
if a class member do not has override modifier and the name of the method is exited in the base class: error
properties are the same as the method.
node in ambient context: not check.
must before accessibility modifier
cannot be used with the
declare
static
modifier.cannot be used with a constructor.
Something needs to consider:
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.abstract method or abstract class:
eg:
eg: