Skip to content

Improve decorator on overload error message#6129

Merged
DanielRosenwasser merged 1 commit intomicrosoft:masterfrom
pimterry:decorator-overload-msg
Dec 21, 2015
Merged

Improve decorator on overload error message#6129
DanielRosenwasser merged 1 commit intomicrosoft:masterfrom
pimterry:decorator-overload-msg

Conversation

@pimterry
Copy link
Copy Markdown
Contributor

This fixes #6064, by improving the error message in the case when a decorator is rejected for being on a method overload, not an implementation.

I'm happy this works, but I'm not super happy with the detection of whether it's a method overload (currently: it's a method declaration without a body, which can't be decorated). I'm not familiar with the structure of the TypeScript codebase yet though, and I can't find any existing methods that define exactly how to check whether a node is an overload declaration.

I've opened this PR regardless for now, to check I'm on the right track, and because it is working and mergeable if you're happy with the approach.

Any suggestions on tidying that check up, or if that's required at all? If there's nothing already existing for this then should I be refactoring this check out somewhere? (and if so where?)

Comment thread src/compiler/checker.ts
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ts. is not necessary

@vladima
Copy link
Copy Markdown
Contributor

vladima commented Dec 17, 2015

implementation-wise looks ok, modulo one comment. Also can you add one more test to capture the correct case: method with overload and decorator is placed on implementation?

Pinging @DanielRosenwasser to see if he has any comments on phrasing of the error message?

@sandersn
Copy link
Copy Markdown
Member

The message's grammar looks fine to me but might still violate some error message guidelines that I haven't learned yet.

@DanielRosenwasser
Copy link
Copy Markdown
Member

Considering I was the one who originally suggested this message, I'm biased 😄

@pimterry let's add the inverse test and we should be good to pull this in.

@DanielRosenwasser DanielRosenwasser added this to the TypeScript 1.8 milestone Dec 18, 2015
@DanielRosenwasser DanielRosenwasser added the Spec Issues related to the TypeScript language specification label Dec 18, 2015
@DanielRosenwasser DanielRosenwasser removed the Spec Issues related to the TypeScript language specification label Dec 18, 2015
@DanielRosenwasser DanielRosenwasser removed this from the TypeScript 1.8 milestone Dec 18, 2015
@DanielRosenwasser
Copy link
Copy Markdown
Member

Actually, I'll just add the inverse test. Thanks for the PR!

DanielRosenwasser added a commit that referenced this pull request Dec 21, 2015
Improve decorator on overload error message
@DanielRosenwasser DanielRosenwasser merged commit ee50adb into microsoft:master Dec 21, 2015
@pimterry pimterry deleted the decorator-overload-msg branch July 26, 2017 16:22
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Supply a better error message for a decorator on a method overload

6 participants