Skip to content

Commit 82b15d6

Browse files
committed
feat(compare): support ignore jsdoc for methods
1 parent 52eeff2 commit 82b15d6

3 files changed

Lines changed: 14 additions & 8 deletions

File tree

scripts/compare/compare-methods.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { MethodSignature, Node, ParameterDeclaration, SyntaxKind } from 'ts-morph';
2-
import { updatePropertyModifiers } from './shared';
2+
import { CustomJsDocTags, getJsDocTagValues, updatePropertyModifiers } from './shared';
33
import { compareTypes } from './type-comparator';
44

55
/**
@@ -8,6 +8,12 @@ import { compareTypes } from './type-comparator';
88
* @param sourceMethod The method to use as the source of truth
99
*/
1010
export function compareAndCorrectMethodTypes(targetMethod: MethodSignature, sourceMethod: MethodSignature): void {
11+
const ignore = getJsDocTagValues(targetMethod, CustomJsDocTags.ignore);
12+
13+
if (ignore.length > 0) {
14+
return;
15+
}
16+
1117
updatePropertyModifiers(targetMethod, sourceMethod);
1218

1319
// If it has the @native jsDoc don't compare

scripts/compare/compare-properties.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
import { EnumDeclaration, EnumMember, PropertySignature, TypeNode } from 'ts-morph';
22
import { handleInterfaceTypeReferences } from './handle-interfaces';
3-
import { currentTargetSourceFile, getJsDocTagValues, isImportedType, updatePropertyModifiers } from './shared';
3+
import { currentTargetSourceFile, CustomJsDocTags, getJsDocTagValues, isImportedType, updatePropertyModifiers } from './shared';
44
import * as TypeComparator from './type-comparator';
55

6-
const CustomJsDocTags = {
7-
originalName: 'compareOriginalName',
8-
currentValue: 'currentValue',
9-
ignore: 'ignore',
10-
};
11-
126
/**
137
* Compares and corrects property types
148
* @param targetProp The property to be edited

scripts/compare/shared.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
import { Identifier, ImportSpecifier, InterfaceDeclaration, JSDocableNode, MethodSignature, Node, PropertySignature, QuestionTokenableNode, ReadonlyableNode, SourceFile, Type, TypeLiteralNode, TypeNode } from 'ts-morph';
22
import { Logger } from '../logger';
33

4+
export const CustomJsDocTags = {
5+
originalName: 'compareOriginalName',
6+
currentValue: 'currentValue',
7+
ignore: 'ignore',
8+
};
9+
410
/**
511
* Interface to represent a task in the processing queue
612
*/

0 commit comments

Comments
 (0)