-
Notifications
You must be signed in to change notification settings - Fork 1
Override codefix in js #8
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
base: exprement-override
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basic structure looks good.
- One question in emitter.ts (plus it needs a merge).
- A refactor in fixOverrideModifier.ts
- A code move in textChanges.ts
case SyntaxKind.JSDocOverrideTag: | ||
case SyntaxKind.JSDocPublicTag: | ||
case SyntaxKind.JSDocPrivateTag: | ||
case SyntaxKind.JSDocProtectedTag: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- why do these need to be emitted?
- these are now in emitter.ts as no-ops, and will need to be removed when this PR is merged from main.
@@ -61,7 +62,7 @@ namespace ts.codefix { | |||
codeFixAll(context, errorCodes, (changes, diag) => { | |||
const { code, start, file } = diag; | |||
const info = errorCodeFixIdMap[code]; | |||
if (!info || info[1] !== context.fixId || isSourceFileJS(file)) { | |||
if (!info || info[1] !== context.fixId || !info[3] && isSourceFileJS(file)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not your fault, but errorCodeFixIdMap
should really have object keys, not tuple ones. info[3]
is way worse than info.allowInJS
.
@@ -20,23 +20,24 @@ namespace ts.codefix { | |||
Diagnostics.This_parameter_property_must_be_rewritten_as_a_property_declaration_with_an_override_modifier_because_it_overrides_a_member_in_base_class_0.code | |||
]; | |||
|
|||
const errorCodeFixIdMap: Record<number, [DiagnosticMessage, string | undefined, DiagnosticMessage | undefined]> = { | |||
const errorCodeFixIdMap: Record<number, [message: DiagnosticMessage, fixId: string, fixAllMessage: DiagnosticMessage, allowInjs: boolean]> = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please convert this into an object type that has the same property names you just added to the tuple.
this.insertJsdocCommentBefore(sourceFile, jsDocNode, tag); | ||
} | ||
|
||
public getJsDocNodeForArrowFunction(signature: ArrowFunction): HasJSDoc { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this doesn't need to be a method, especially a public one.
return <HasJSDoc>signature.parent.parent; | ||
} | ||
|
||
public tryMergeJsdocTags(oldTag: JSDocTag, newTag: JSDocTag): JSDocTag | undefined { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
@Kingwl it's been quite a while since you submitted this. Do you have time to work on it? If not, one of the TS team (probably me :) can take over. |
Sure. And I think @stkevintan might already have some work here. |
Fixes microsoft#39669