Skip to content

28911 - change Diagnostic.code to 'string | number' #28959

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

Conversation

a-tarasyuk
Copy link
Contributor

Fixes #28911

Copy link
Contributor

@ajafff ajafff left a comment

Choose a reason for hiding this comment

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

Should the same change be made to DiagnosticWithLinePosition and DiagnosticRelatedInformation?

@a-tarasyuk
Copy link
Contributor Author

@ajaff ok, will add changes to DiagnosticWithLinePosition, DiagnosticRelatedInformation.

@DanielRosenwasser
Copy link
Member

DanielRosenwasser commented Dec 12, 2018

The unfortunate thing here is that we're going to cause a few bugs where people create a Set<number | string> and end up using .has on the wrong type. But I think this is fine.

@DanielRosenwasser
Copy link
Member

Hey @amcasey, can VS handle non-numeric diagnostic codes?

@amcasey
Copy link
Member

amcasey commented Dec 12, 2018

@DanielRosenwasser, I believe so, but I'll confirm.

Edit: Yes, it can.

@amcasey
Copy link
Member

amcasey commented Dec 12, 2018

@DanielRosenwasser I misspoke - Roslyn can accept strings but TS deserializes them as int so old versions of VS will break (probably by dropping these diagnostics).

But we can definitely have newer versions of VS opt into receiving string error codes.

@DanielRosenwasser DanielRosenwasser added the Breaking Change Would introduce errors in existing code label Dec 13, 2018
@DanielRosenwasser
Copy link
Member

DanielRosenwasser commented Dec 13, 2018

Sounds like we'd need to change our API to also support a new configuration option on to say that the client can support string error codes. Even if we decided to add this functionality, we would need to keep numeric error codes around f o r e v e r.

As terrible as it sounds, it might be better to return a new property on Diagnostic objects.

@DanielRosenwasser
Copy link
Member

@weswigham

@sheetalkamat
Copy link
Member

@DanielRosenwasser Your suggestion doesnt sound terrible. Infact i like having optional friendlyName property sounds good. That way even we could add the names to error codes (instead of numbers) and editors can decide to use them over number if present to displayed. We should keep errorCode required so that editors not handling the additional optional property can show something that user can search about.

@weswigham
Copy link
Member

Friendly human readable short names are good. Although question, if we go there: Can multiple messages share a short name (so, eg, we can group all the excess property variant messages under one "name")? I don't really see why not.

@a-tarasyuk
Copy link
Contributor Author

I think this PR has to be closed.

@minestarks
Copy link
Member

@DanielRosenwasser just to clarify on #28959 (comment) I feel like a configuration option isn't necessary if we simply add a new optional friendlyName field - errors that support friendly names would always populate the friendlyName and old editors would just ignore it.

@a-tarasyuk a-tarasyuk deleted the feature/28911-change-diagnostic-code-to-string-or-number branch June 11, 2019 05:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Breaking Change Would introduce errors in existing code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants