Skip to content

Different behaviors between actual compiler and baselines of class member override. #43533

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

Closed
g-plane opened this issue Apr 5, 2021 · 4 comments Β· Fixed by #43544
Closed

Different behaviors between actual compiler and baselines of class member override. #43533

g-plane opened this issue Apr 5, 2021 · 4 comments Β· Fixed by #43544
Assignees
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue Good First Issue Well scoped, documented and has the green light Help Wanted You can do this

Comments

@g-plane
Copy link
Contributor

g-plane commented Apr 5, 2021

Bug Report

πŸ”Ž Search Terms

class override

πŸ•— Version & Regression Information

  • This changed between versions 4.2.0 and nightly

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

class B {
    p1: number = 1;
    p2: number = 2;
    p3: number = 3;
    p4: number = 4;
    oop: number;
    pp: number;
    op: number;
}

class D extends B{
    declare p1: number

    override declare p2: number;

    readonly override p3: number;

    override readonly p4: number;

    override static sp: number;

    override override oop: number;

    public override pp: number;
    override public op: number;

    override constructor () {
        super();
    }
}

πŸ™ Actual behavior

I've tried the same code in playground with nightly version and with npm install typescript@next, and there's only one compilation error occurred: 'override' modifier already seen. . Other errors, such as 'public' modifier must precede 'override' modifier., 'static' modifier cannot be used with 'override' modifier. and etc. can't be reproduced as baselines in https://github.com/microsoft/TypeScript/blob/master/tests/baselines/reference/override5.errors.txt , so I'm not sure which one is correct.

Context: we're implementing parsing override syntax in swc: swc-project/swc#1541 .

πŸ™‚ Expected behavior

Not sure. Stated as above.

@andrewbranch
Copy link
Member

It looks like all those errors depend on --noImplicitOverride being enabled. I don’t know why that would be the caseβ€”it seems like all the grammar checking should happen regardless of the flag. Also, was it intentional that the order of modifiers between override and readonly isn’t enforced? /cc @DanielRosenwasser @Kingwl

@DanielRosenwasser DanielRosenwasser added the Bug A bug in TypeScript label Apr 5, 2021
@DanielRosenwasser DanielRosenwasser added Good First Issue Well scoped, documented and has the green light Help Wanted You can do this labels Apr 5, 2021
@DanielRosenwasser DanielRosenwasser added this to the TypeScript 4.3.1 milestone Apr 5, 2021
@DanielRosenwasser
Copy link
Member

I think override should precede readonly.

@Kingwl
Copy link
Contributor

Kingwl commented Apr 6, 2021

My bad. Thanks!

@g-plane
Copy link
Contributor Author

g-plane commented Apr 6, 2021

There's another pull request which may be related to this: #43545 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue Good First Issue Well scoped, documented and has the green light Help Wanted You can do this
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants