Skip to content

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

Open
wants to merge 2 commits into
base: exprement-override
Choose a base branch
from
Open

Override codefix in js #8

wants to merge 2 commits into from

Conversation

Kingwl
Copy link
Owner

@Kingwl Kingwl commented Nov 6, 2020

Copy link

@sandersn sandersn left a 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.

  1. One question in emitter.ts (plus it needs a merge).
  2. A refactor in fixOverrideModifier.ts
  3. A code move in textChanges.ts

case SyntaxKind.JSDocOverrideTag:
case SyntaxKind.JSDocPublicTag:
case SyntaxKind.JSDocPrivateTag:
case SyntaxKind.JSDocProtectedTag:
Copy link

Choose a reason for hiding this comment

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

  1. why do these need to be emitted?
  2. 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)) {
Copy link

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]> = {
Copy link

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 {
Copy link

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 {
Copy link

Choose a reason for hiding this comment

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

same

@sandersn
Copy link

sandersn commented Sep 7, 2021

@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.

@Kingwl
Copy link
Owner Author

Kingwl commented Sep 7, 2021

Sure. And I think @stkevintan might already have some work here.

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

Successfully merging this pull request may close these issues.

2 participants