Make convertFunctionToEs6Class a codefix#22241
Conversation
522be8d to
f53adf8
Compare
| "category": "Suggestion", | ||
| "code": 80001 | ||
| }, | ||
| "Function may be converted to a class.": { |
There was a problem hiding this comment.
@DanielRosenwasser any thoughts about the error message
There was a problem hiding this comment.
I think this message can be enhanced, @DanielRosenwasser might have better suggestions.
There was a problem hiding this comment.
We should refine this over time, but
This constructor function may be converted to a class declaration.
or
Constructor function may be better represented as a class declaration.
| switch (node.kind) { | ||
| case SyntaxKind.FunctionDeclaration: | ||
| case SyntaxKind.FunctionExpression: | ||
| if (isInJavaScriptFile(node)) { |
There was a problem hiding this comment.
since this is the only one we have right now, i would move this to the top of the check function. we can refactor it later as we add more checks.
| ['1', '2', '3', '4', '5', '6', '7', '8'].forEach(m => verify.applicableRefactorAvailableAtMarker(m)); | ||
| verify.fileAfterApplyingRefactorAtMarker('7', | ||
| verify.codeFix({ | ||
| description: "Convert function to an ES2015 class", |
There was a problem hiding this comment.
Can this refer to the resource, rather than including a string literal? That would make it easier to change the resource's value.
There was a problem hiding this comment.
Unfortunately, diagnostics are automatically named the same as their message. (See scripts/processDIagnosticMessages.ts.) So if we change the message we end up needing to rename a bunch of things anyway...
Part of #19392
Discovered #22240