Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

refactor(typescript-estree): simplify applyModifiersToResult#3084

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
armano2 merged 1 commit intomasterfromrefactor/apply-modifers
Feb 21, 2021
Merged
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletionspackages/typescript-estree/src/convert.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -580,13 +580,13 @@ export class Converter {
if (!modifiers || !modifiers.length) {
return;
}
const remainingModifiers: TSESTree.Modifier[] = [];
/**
* Some modifiers are explicitly handled by applying them as
* boolean values on the result node. As well as adding them
* to the result, we remove them from the array, so that they
* are not handled twice.
*/
const handledModifierIndices: { [key: number]: boolean } = {};
for (let i = 0; i < modifiers.length; i++) {
const modifier = modifiers[i];
switch (modifier.kind) {
Expand All@@ -596,31 +596,26 @@ export class Converter {
*/
case SyntaxKind.ExportKeyword:
case SyntaxKind.DefaultKeyword:
handledModifierIndices[i] = true;
break;
case SyntaxKind.ConstKeyword:
(result as any).const = true;
handledModifierIndices[i] = true;
break;
case SyntaxKind.DeclareKeyword:
result.declare = true;
handledModifierIndices[i] = true;
break;
default:
remainingModifiers.push(this.convertChild(modifier));
break;
}
}
/**
* If there are still valid modifiers available which have
* not been explicitly handled above, we just convert and
* add the modifiers array to the result node.
*/
const remainingModifiers = modifiers.filter(
(_, i) => !handledModifierIndices[i],
);
if (!remainingModifiers || !remainingModifiers.length) {
return;
if (remainingModifiers.length) {
result.modifiers = remainingModifiers;
}
result.modifiers = remainingModifiers.map(el => this.convertChild(el));
}

/**
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp