Skip to content
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

Crash when redeclaring a property from interface. #32524

Closed
GabrielCastro opened this issue Jul 23, 2019 · 3 comments
Closed

Crash when redeclaring a property from interface. #32524

GabrielCastro opened this issue Jul 23, 2019 · 3 comments
Assignees
Labels
Bug A bug in TypeScript Rescheduled This issue was previously scheduled to an earlier milestone

Comments

@GabrielCastro
Copy link

TypeScript Version: 3.5.1

Search Terms:
Debug Failure. Unhandled declaration kind! GetAccessor for
Debug Failure. Unhandled declaration kind! 159 for
Code

// A *self-contained* demonstration of the problem follows...
// Test this by running `tsc` on the command-line, rather than through another build tool such as Gulp, Webpack, etc.

export interface IHasAName {
  readonly name: string;
}

export class HasAName implements IHasAName {

  public readonly get name(): string {
    return 'foo';
  }

  constructor(
    public readonly name: string,
  ) {
  }

}

Expected behavior:

Should result in a duplicate-identifier error

Actual behavior:

tsc exits witout writing file and prints error to console

Debug Failure. Unhandled declaration kind! GetAccessor for { name: name; flags: Property|GetAccessor; declarations: GetAccessor,Parameter }

Playground Link:

https://www.typescriptlang.org/play/#code/KYDwDg9gTgLgBASwHY2FAZgQwMbDgSQAlMBnAQQDlMBbPAbwCg44phMATCJAGwE84kNYAC44JGFGQBzANwMAvgwahIsONm6kScYuSq1E1MN2C0U2oqUpC4jJnDABXAEbcE2Fm049+U4PEFaAAoASlFxSSQpW3tmVhhHKCQ4AHJ0CAgUuWZFe2wuCMdsGGgg2IcXNw9WDi4+ASFwiWkAGnsQmJylRSA

Related Issues:

#31225
#27352

@RyanCavanaugh RyanCavanaugh added the Bug A bug in TypeScript label Jul 23, 2019
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 3.6.1 milestone Jul 23, 2019
@RyanCavanaugh
Copy link
Member

Thanks for the simple repro!

@tbhartman
Copy link

I was not aware of the use of access keywords in the constructor arguments. It appears the error only occurs if the getter is defined in the class before the regular parameter.

Fails:

interface IHasAName {
    readonly name:string
}
class HasAName implements IHasAName {
    get name() {
        return 'foo';
    }
    name:string
}

OK (gives Duplicate identifier error):

interface IHasAName {
    readonly name:string
}
class HasAName implements IHasAName {
    name:string
    get name() {
        return 'foo';
    }
}

@orta orta added the Rescheduled This issue was previously scheduled to an earlier milestone label May 12, 2020
@orta orta modified the milestones: TypeScript 3.9.1, TypeScript 4.0 May 12, 2020
@orta
Copy link
Contributor

orta commented Jun 25, 2020

Looks like this has been fixed since then, looks fine in 3.9 playground.

Thanks, closing

@orta orta closed this as completed Jun 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Rescheduled This issue was previously scheduled to an earlier milestone
Projects
None yet
Development

No branches or pull requests

5 participants