Skip to content

Commit 8426565

Browse files
authored
Rename isParameterDeclaration to isPartOfParameterDeclaration (#58251)
1 parent e04a27c commit 8426565

File tree

4 files changed

+14
-18
lines changed

4 files changed

+14
-18
lines changed

src/compiler/binder.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,9 @@ import {
200200
isOptionalChain,
201201
isOptionalChainRoot,
202202
isOutermostOptionalChain,
203-
isParameterDeclaration,
204203
isParameterPropertyDeclaration,
205204
isParenthesizedExpression,
205+
isPartOfParameterDeclaration,
206206
isPartOfTypeQuery,
207207
isPrefixUnaryExpression,
208208
isPrivateIdentifier,
@@ -3647,7 +3647,7 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
36473647
else if (isBlockOrCatchScoped(node)) {
36483648
bindBlockScopedDeclaration(node, SymbolFlags.BlockScopedVariable, SymbolFlags.BlockScopedVariableExcludes);
36493649
}
3650-
else if (isParameterDeclaration(node)) {
3650+
else if (isPartOfParameterDeclaration(node)) {
36513651
// It is safe to walk up parent chain to find whether the node is a destructuring parameter declaration
36523652
// because its parent chain has already been set up, since parents are set before descending into children.
36533653
//

src/compiler/checker.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -674,10 +674,10 @@ import {
674674
isOptionalTypeNode,
675675
isOutermostOptionalChain,
676676
isParameter,
677-
isParameterDeclaration,
678677
isParameterPropertyDeclaration,
679678
isParenthesizedExpression,
680679
isParenthesizedTypeNode,
680+
isPartOfParameterDeclaration,
681681
isPartOfTypeNode,
682682
isPartOfTypeQuery,
683683
isPlainJsFile,
@@ -8233,7 +8233,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
82338233
sym.flags & SymbolFlags.FunctionScopedVariable
82348234
&& sym.valueDeclaration
82358235
) {
8236-
if (isParameterDeclaration(sym.valueDeclaration)) {
8236+
if (isPartOfParameterDeclaration(sym.valueDeclaration)) {
82378237
return { introducesError, node: attachSymbolToLeftmostIdentifier(node) as T };
82388238
}
82398239
}
@@ -8994,7 +8994,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
89948994
}
89958995

89968996
function includePrivateSymbol(symbol: Symbol) {
8997-
if (some(symbol.declarations, isParameterDeclaration)) return;
8997+
if (some(symbol.declarations, isPartOfParameterDeclaration)) return;
89988998
Debug.assertIsDefined(deferredPrivatesStack[deferredPrivatesStack.length - 1]);
89998999
getUnusedName(unescapeLeadingUnderscores(symbol.escapedName), symbol); // Call to cache unique name for symbol
90009000
// Blanket moving (import) aliases into the root private context should work, since imports are not valid within namespaces
@@ -10686,7 +10686,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
1068610686
}
1068710687
const pattern = declaration.parent;
1068810688
// Relax null check on ambient destructuring parameters, since the parameters have no implementation and are just documentation
10689-
if (strictNullChecks && declaration.flags & NodeFlags.Ambient && isParameterDeclaration(declaration)) {
10689+
if (strictNullChecks && declaration.flags & NodeFlags.Ambient && isPartOfParameterDeclaration(declaration)) {
1069010690
parentType = getNonNullableType(parentType);
1069110691
}
1069210692
// Filter `undefined` from the type we check against if the parent has an initializer and that initializer is not possibly `undefined`
@@ -42464,7 +42464,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
4246442464
for (const node of potentialUnusedRenamedBindingElementsInTypes) {
4246542465
if (!getSymbolOfDeclaration(node)?.isReferenced) {
4246642466
const wrappingDeclaration = walkUpBindingElementsAndPatterns(node);
42467-
Debug.assert(isParameterDeclaration(wrappingDeclaration), "Only parameter declaration should be checked here");
42467+
Debug.assert(isPartOfParameterDeclaration(wrappingDeclaration), "Only parameter declaration should be checked here");
4246842468
const diagnostic = createDiagnosticForNode(node.name, Diagnostics._0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation, declarationNameToString(node.name), declarationNameToString(node.propertyName));
4246942469
if (!wrappingDeclaration.type) {
4247042470
// entire parameter does not have type annotation, suggest adding an annotation
@@ -42746,7 +42746,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
4274642746
// }
4274742747

4274842748
// skip block-scoped variables and parameters
42749-
if ((getCombinedNodeFlagsCached(node) & NodeFlags.BlockScoped) !== 0 || isParameterDeclaration(node)) {
42749+
if ((getCombinedNodeFlagsCached(node) & NodeFlags.BlockScoped) !== 0 || isPartOfParameterDeclaration(node)) {
4275042750
return;
4275142751
}
4275242752

@@ -42818,7 +42818,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
4281842818
if (
4281942819
node.propertyName &&
4282042820
isIdentifier(node.name) &&
42821-
isParameterDeclaration(node) &&
42821+
isPartOfParameterDeclaration(node) &&
4282242822
nodeIsMissing((getContainingFunction(node) as FunctionLikeDeclaration).body)
4282342823
) {
4282442824
// type F = ({a: string}) => void;
@@ -42864,7 +42864,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
4286442864
forEach(node.name.elements, checkSourceElement);
4286542865
}
4286642866
// For a parameter declaration with an initializer, error and exit if the containing function doesn't have a body
42867-
if (node.initializer && isParameterDeclaration(node) && nodeIsMissing((getContainingFunction(node) as FunctionLikeDeclaration).body)) {
42867+
if (node.initializer && isPartOfParameterDeclaration(node) && nodeIsMissing((getContainingFunction(node) as FunctionLikeDeclaration).body)) {
4286842868
error(node, Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation);
4286942869
return;
4287042870
}

src/compiler/utilities.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5340,10 +5340,6 @@ export function isPushOrUnshiftIdentifier(node: Identifier) {
53405340
return node.escapedText === "push" || node.escapedText === "unshift";
53415341
}
53425342

5343-
// TODO(jakebailey): this function should not be named this. While it does technically
5344-
// return true if the argument is a ParameterDeclaration, it also returns true for nodes
5345-
// that are children of ParameterDeclarations inside binding elements.
5346-
// Probably, this should be called `rootDeclarationIsParameter`.
53475343
/**
53485344
* This function returns true if the this node's root declaration is a parameter.
53495345
* For example, passing a `ParameterDeclaration` will return true, as will passing a
@@ -5353,7 +5349,7 @@ export function isPushOrUnshiftIdentifier(node: Identifier) {
53535349
*
53545350
* @internal
53555351
*/
5356-
export function isParameterDeclaration(node: Declaration): boolean {
5352+
export function isPartOfParameterDeclaration(node: Declaration): boolean {
53575353
const root = getRootDeclaration(node);
53585354
return root.kind === SyntaxKind.Parameter;
53595355
}
@@ -11239,7 +11235,7 @@ export function createNameResolver({
1123911235
lastLocation === (location as BindingElement).name && isBindingPattern(lastLocation)
1124011236
)
1124111237
) {
11242-
if (isParameterDeclaration(location as BindingElement) && !associatedDeclarationForContainingInitializerOrBindingName) {
11238+
if (isPartOfParameterDeclaration(location as BindingElement) && !associatedDeclarationForContainingInitializerOrBindingName) {
1124311239
associatedDeclarationForContainingInitializerOrBindingName = location as BindingElement;
1124411240
}
1124511241
}

src/services/inlayHints.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ import {
7070
isObjectLiteralExpression,
7171
isOptionalTypeNode,
7272
isParameter,
73-
isParameterDeclaration,
7473
isParenthesizedTypeNode,
74+
isPartOfParameterDeclaration,
7575
isPrefixUnaryExpression,
7676
isPropertyAccessExpression,
7777
isPropertyDeclaration,
@@ -899,7 +899,7 @@ export function provideInlayHints(context: InlayHintsContext): InlayHint[] {
899899
}
900900

901901
function isHintableDeclaration(node: VariableDeclaration | ParameterDeclaration) {
902-
if ((isParameterDeclaration(node) || isVariableDeclaration(node) && isVarConst(node)) && node.initializer) {
902+
if ((isPartOfParameterDeclaration(node) || isVariableDeclaration(node) && isVarConst(node)) && node.initializer) {
903903
const initializer = skipParentheses(node.initializer);
904904
return !(isHintableLiteral(initializer) || isNewExpression(initializer) || isObjectLiteralExpression(initializer) || isAssertionExpression(initializer));
905905
}

0 commit comments

Comments
 (0)