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

IParserErrorMessageProvider properties must be implemented as **own** properties #1129

Closed
AccessViolator opened this issue Feb 24, 2020 · 4 comments
Labels

Comments

@AccessViolator
Copy link

In short: in TypeScript IParserErrorMessageProvider implementation requires use of 'fat arrow' syntax, while implementation of ILexerErrorMessageProvider doesn't.
This syntax works only for ILexerErrorMessageProvider:

export class MyLexerErrorMessageProvider implements ILexerErrorMessageProvider {
  buildUnableToPopLexerModeMessage(token: IToken): string {
    return 'blah';
  }
...
}

IParserErrorMessageProvider requires fat arrow syntax to work:

export class MyParserErrorMessageProvider implements IParserErrorMessageProvider {
  buildNotAllInputParsedMessage = (options: { firstRedundant: IToken; ruleName: string }): string => {
    return 'blah';
  }
}
@bd82
Copy link
Member

bd82 commented Feb 24, 2020

Hi @AccessViolator

Fat Arrow syntax is not required for either.

It is true the APIs use different styles (multiple parameters vs single config object param) TBH
I do not recall why exactly is that 😄, but I'm uncertain it is a big issue...

@bd82 bd82 closed this as completed Feb 24, 2020
@AccessViolator
Copy link
Author

Well, it's not required to compile, but is required to work. Without fat arrow parser returns original messages. You should try it :)
I suppose it has smth to do with the implementation of utils.defaults()

@bd82 bd82 reopened this Feb 25, 2020
@bd82
Copy link
Member

bd82 commented Feb 25, 2020

Interesting point, I suppose there is an assumption that these properties exist directly on the object passed and because you implement this interface using a class rather than a plain object literal then the utils.defaults overrides those.

I will take a deeper look (hopefully on the weekend).

@bd82 bd82 added the Bug 🪲 label Feb 25, 2020
@bd82 bd82 changed the title Inconsistent implementation of IParserErrorMessageProvider and ILexerErrorMessageProvider IParserErrorMessageProvider properties must be implemented as **own** properties Apr 17, 2020
@bd82 bd82 closed this as completed in 8470faf Apr 17, 2020
@bd82
Copy link
Member

bd82 commented Apr 17, 2020

Hi @AccessViolator I finally got around to this 😄

The fix should be in 7.0.0 which will hopefully be released this weekend.
I removed the use of defaults completely, I don't think it fits well when the interface includes methods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants