Skip to content

Commit 1e6d76e

Browse files
authored
Make canHaveModifiers/Decorators public (#50405)
1 parent aca1aa6 commit 1e6d76e

File tree

4 files changed

+44
-40
lines changed

4 files changed

+44
-40
lines changed

src/compiler/factory/utilities.ts

-40
Original file line numberDiff line numberDiff line change
@@ -877,17 +877,6 @@ namespace ts {
877877
|| kind === SyntaxKind.SetAccessor;
878878
}
879879

880-
export function canHaveDecorators(node: Node): node is HasDecorators {
881-
const kind = node.kind;
882-
return kind === SyntaxKind.Parameter
883-
|| kind === SyntaxKind.PropertyDeclaration
884-
|| kind === SyntaxKind.MethodDeclaration
885-
|| kind === SyntaxKind.GetAccessor
886-
|| kind === SyntaxKind.SetAccessor
887-
|| kind === SyntaxKind.ClassExpression
888-
|| kind === SyntaxKind.ClassDeclaration;
889-
}
890-
891880
export function canHaveIllegalDecorators(node: Node): node is HasIllegalDecorators {
892881
const kind = node.kind;
893882
return kind === SyntaxKind.PropertyAssignment
@@ -909,35 +898,6 @@ namespace ts {
909898
|| kind === SyntaxKind.ExportAssignment;
910899
}
911900

912-
export function canHaveModifiers(node: Node): node is HasModifiers {
913-
const kind = node.kind;
914-
return kind === SyntaxKind.TypeParameter
915-
|| kind === SyntaxKind.Parameter
916-
|| kind === SyntaxKind.PropertySignature
917-
|| kind === SyntaxKind.PropertyDeclaration
918-
|| kind === SyntaxKind.MethodSignature
919-
|| kind === SyntaxKind.MethodDeclaration
920-
|| kind === SyntaxKind.Constructor
921-
|| kind === SyntaxKind.GetAccessor
922-
|| kind === SyntaxKind.SetAccessor
923-
|| kind === SyntaxKind.IndexSignature
924-
|| kind === SyntaxKind.ConstructorType
925-
|| kind === SyntaxKind.FunctionExpression
926-
|| kind === SyntaxKind.ArrowFunction
927-
|| kind === SyntaxKind.ClassExpression
928-
|| kind === SyntaxKind.VariableStatement
929-
|| kind === SyntaxKind.FunctionDeclaration
930-
|| kind === SyntaxKind.ClassDeclaration
931-
|| kind === SyntaxKind.InterfaceDeclaration
932-
|| kind === SyntaxKind.TypeAliasDeclaration
933-
|| kind === SyntaxKind.EnumDeclaration
934-
|| kind === SyntaxKind.ModuleDeclaration
935-
|| kind === SyntaxKind.ImportEqualsDeclaration
936-
|| kind === SyntaxKind.ImportDeclaration
937-
|| kind === SyntaxKind.ExportAssignment
938-
|| kind === SyntaxKind.ExportDeclaration;
939-
}
940-
941901
export function canHaveIllegalModifiers(node: Node): node is HasIllegalModifiers {
942902
const kind = node.kind;
943903
return kind === SyntaxKind.ClassStaticBlockDeclaration

src/compiler/factory/utilitiesPublic.ts

+40
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,44 @@ namespace ts {
22
export function setTextRange<T extends TextRange>(range: T, location: TextRange | undefined): T {
33
return location ? setTextRangePosEnd(range, location.pos, location.end) : range;
44
}
5+
6+
export function canHaveModifiers(node: Node): node is HasModifiers {
7+
const kind = node.kind;
8+
return kind === SyntaxKind.TypeParameter
9+
|| kind === SyntaxKind.Parameter
10+
|| kind === SyntaxKind.PropertySignature
11+
|| kind === SyntaxKind.PropertyDeclaration
12+
|| kind === SyntaxKind.MethodSignature
13+
|| kind === SyntaxKind.MethodDeclaration
14+
|| kind === SyntaxKind.Constructor
15+
|| kind === SyntaxKind.GetAccessor
16+
|| kind === SyntaxKind.SetAccessor
17+
|| kind === SyntaxKind.IndexSignature
18+
|| kind === SyntaxKind.ConstructorType
19+
|| kind === SyntaxKind.FunctionExpression
20+
|| kind === SyntaxKind.ArrowFunction
21+
|| kind === SyntaxKind.ClassExpression
22+
|| kind === SyntaxKind.VariableStatement
23+
|| kind === SyntaxKind.FunctionDeclaration
24+
|| kind === SyntaxKind.ClassDeclaration
25+
|| kind === SyntaxKind.InterfaceDeclaration
26+
|| kind === SyntaxKind.TypeAliasDeclaration
27+
|| kind === SyntaxKind.EnumDeclaration
28+
|| kind === SyntaxKind.ModuleDeclaration
29+
|| kind === SyntaxKind.ImportEqualsDeclaration
30+
|| kind === SyntaxKind.ImportDeclaration
31+
|| kind === SyntaxKind.ExportAssignment
32+
|| kind === SyntaxKind.ExportDeclaration;
33+
}
34+
35+
export function canHaveDecorators(node: Node): node is HasDecorators {
36+
const kind = node.kind;
37+
return kind === SyntaxKind.Parameter
38+
|| kind === SyntaxKind.PropertyDeclaration
39+
|| kind === SyntaxKind.MethodDeclaration
40+
|| kind === SyntaxKind.GetAccessor
41+
|| kind === SyntaxKind.SetAccessor
42+
|| kind === SyntaxKind.ClassExpression
43+
|| kind === SyntaxKind.ClassDeclaration;
44+
}
545
}

tests/baselines/reference/api/tsserverlibrary.d.ts

+2
Original file line numberDiff line numberDiff line change
@@ -4834,6 +4834,8 @@ declare namespace ts {
48344834
}
48354835
declare namespace ts {
48364836
function setTextRange<T extends TextRange>(range: T, location: TextRange | undefined): T;
4837+
function canHaveModifiers(node: Node): node is HasModifiers;
4838+
function canHaveDecorators(node: Node): node is HasDecorators;
48374839
}
48384840
declare namespace ts {
48394841
/**

tests/baselines/reference/api/typescript.d.ts

+2
Original file line numberDiff line numberDiff line change
@@ -4834,6 +4834,8 @@ declare namespace ts {
48344834
}
48354835
declare namespace ts {
48364836
function setTextRange<T extends TextRange>(range: T, location: TextRange | undefined): T;
4837+
function canHaveModifiers(node: Node): node is HasModifiers;
4838+
function canHaveDecorators(node: Node): node is HasDecorators;
48374839
}
48384840
declare namespace ts {
48394841
/**

0 commit comments

Comments
 (0)