Skip to content

Deprecate isParameter, rename to isParameterDeclaration #52283

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

Closed
Closed
Show file tree
Hide file tree
Changes from all 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
6 changes: 3 additions & 3 deletions src/compiler/binder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
break;
case SyntaxKind.JSDocFunctionType:
return (isJSDocConstructSignature(node) ? InternalSymbolName.New : InternalSymbolName.Call);
case SyntaxKind.Parameter:
case SyntaxKind.ParameterDeclaration:
// Parameters with names are handled at the top of this function. Parameters
// without names can only come from JSDocFunctionTypes.
Debug.assert(node.parent.kind === SyntaxKind.JSDocFunctionType, "Impossible parameter parent kind", () => `parent is: ${Debug.formatSyntaxKind(node.parent.kind)}, expected JSDocFunctionType`);
Expand Down Expand Up @@ -1206,7 +1206,7 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
case SyntaxKind.BindingElement:
bindBindingElementFlow(node as BindingElement);
break;
case SyntaxKind.Parameter:
case SyntaxKind.ParameterDeclaration:
bindParameterFlow(node as ParameterDeclaration);
break;
case SyntaxKind.ObjectLiteralExpression:
Expand Down Expand Up @@ -2940,7 +2940,7 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
break; // Binding the children will handle everything
case SyntaxKind.TypeParameter:
return bindTypeParameter(node as TypeParameterDeclaration);
case SyntaxKind.Parameter:
case SyntaxKind.ParameterDeclaration:
return bindParameter(node as ParameterDeclaration);
case SyntaxKind.VariableDeclaration:
return bindVariableDeclarationOrBindingElement(node as VariableDeclaration);
Expand Down
142 changes: 71 additions & 71 deletions src/compiler/checker.ts

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/compiler/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import {
isNamedTupleMember,
isNumericLiteral,
isOptionalTypeNode,
isParameter,
isParameterDeclaration,
isParenthesizedTypeNode,
isParseTreeNode,
isPrivateIdentifier,
Expand Down Expand Up @@ -722,7 +722,7 @@ export namespace Debug {
isNumericLiteral(this) ? `NumericLiteral ${this.text}` :
isBigIntLiteral(this) ? `BigIntLiteral ${this.text}n` :
isTypeParameterDeclaration(this) ? "TypeParameterDeclaration" :
isParameter(this) ? "ParameterDeclaration" :
isParameterDeclaration(this) ? "ParameterDeclaration" :
isConstructorDeclaration(this) ? "ConstructorDeclaration" :
isGetAccessorDeclaration(this) ? "GetAccessorDeclaration" :
isSetAccessorDeclaration(this) ? "SetAccessorDeclaration" :
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1577,7 +1577,7 @@ export function createPrinter(printerOptions: PrinterOptions = {}, handlers: Pri
// Signature elements
case SyntaxKind.TypeParameter:
return emitTypeParameter(node as TypeParameterDeclaration);
case SyntaxKind.Parameter:
case SyntaxKind.ParameterDeclaration:
return emitParameter(node as ParameterDeclaration);
case SyntaxKind.Decorator:
return emitDecorator(node as Decorator);
Expand Down Expand Up @@ -5298,7 +5298,7 @@ export function createPrinter(printerOptions: PrinterOptions = {}, handlers: Pri
forEach((node as VariableDeclarationList).declarations, generateNames);
break;
case SyntaxKind.VariableDeclaration:
case SyntaxKind.Parameter:
case SyntaxKind.ParameterDeclaration:
case SyntaxKind.BindingElement:
case SyntaxKind.ClassDeclaration:
generateNameIfNeeded((node as NamedDeclaration).name);
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/expressionToTypeNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export function createSyntacticTypeNodeBuilder(
switch (node.kind) {
case SyntaxKind.PropertySignature:
return serializeExistingTypeAnnotation(getEffectiveTypeAnnotationNode(node));
case SyntaxKind.Parameter:
case SyntaxKind.ParameterDeclaration:
return typeFromParameter(node, context);
case SyntaxKind.VariableDeclaration:
return typeFromVariable(node, context);
Expand Down
10 changes: 5 additions & 5 deletions src/compiler/factory/nodeFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ import {
isObjectLiteralExpression,
isOmittedExpression,
isOuterExpression,
isParameter,
isParameterDeclaration,
isParenthesizedExpression,
isParseTreeNode,
isPrivateIdentifier,
Expand Down Expand Up @@ -1649,7 +1649,7 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode
type?: TypeNode,
initializer?: Expression,
) {
const node = createBaseDeclaration<ParameterDeclaration>(SyntaxKind.Parameter);
const node = createBaseDeclaration<ParameterDeclaration>(SyntaxKind.ParameterDeclaration);
node.modifiers = asNodeArray(modifiers);
node.dotDotDotToken = dotDotDotToken;
node.name = asName(name);
Expand Down Expand Up @@ -7065,7 +7065,7 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode
modifierArray = modifiers;
}
return isTypeParameterDeclaration(node) ? updateTypeParameterDeclaration(node, modifierArray, node.name, node.constraint, node.default) :
isParameter(node) ? updateParameterDeclaration(node, modifierArray, node.dotDotDotToken, node.name, node.questionToken, node.type, node.initializer) :
isParameterDeclaration(node) ? updateParameterDeclaration(node, modifierArray, node.dotDotDotToken, node.name, node.questionToken, node.type, node.initializer) :
isConstructorTypeNode(node) ? updateConstructorTypeNode1(node, modifierArray, node.typeParameters, node.parameters, node.type) :
isPropertySignature(node) ? updatePropertySignature(node, modifierArray, node.name, node.questionToken, node.type) :
isPropertyDeclaration(node) ? updatePropertyDeclaration(node, modifierArray, node.name, node.questionToken ?? node.exclamationToken, node.type, node.initializer) :
Expand Down Expand Up @@ -7094,7 +7094,7 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode

function replaceDecoratorsAndModifiers<T extends HasModifiers & HasDecorators>(node: T, modifiers: readonly ModifierLike[]): T;
function replaceDecoratorsAndModifiers(node: HasModifiers & HasDecorators, modifierArray: readonly ModifierLike[]) {
return isParameter(node) ? updateParameterDeclaration(node, modifierArray, node.dotDotDotToken, node.name, node.questionToken, node.type, node.initializer) :
return isParameterDeclaration(node) ? updateParameterDeclaration(node, modifierArray, node.dotDotDotToken, node.name, node.questionToken, node.type, node.initializer) :
isPropertyDeclaration(node) ? updatePropertyDeclaration(node, modifierArray, node.name, node.questionToken ?? node.exclamationToken, node.type, node.initializer) :
isMethodDeclaration(node) ? updateMethodDeclaration(node, modifierArray, node.asteriskToken, node.name, node.questionToken, node.typeParameters, node.parameters, node.type, node.body) :
isGetAccessorDeclaration(node) ? updateGetAccessorDeclaration(node, modifierArray, node.name, node.parameters, node.type, node.body) :
Expand Down Expand Up @@ -7321,7 +7321,7 @@ function getTransformFlagsSubtreeExclusions(kind: SyntaxKind) {
return TransformFlags.ArrayLiteralOrCallOrNewExcludes;
case SyntaxKind.ModuleDeclaration:
return TransformFlags.ModuleExcludes;
case SyntaxKind.Parameter:
case SyntaxKind.ParameterDeclaration:
return TransformFlags.ParameterExcludes;
case SyntaxKind.ArrowFunction:
return TransformFlags.ArrowFunctionExcludes;
Expand Down
5 changes: 2 additions & 3 deletions src/compiler/factory/nodeTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -404,9 +404,8 @@ export function isTypeParameterDeclaration(node: Node): node is TypeParameterDec
return node.kind === SyntaxKind.TypeParameter;
}

// TODO(rbuckton): Rename to 'isParameterDeclaration'
export function isParameter(node: Node): node is ParameterDeclaration {
return node.kind === SyntaxKind.Parameter;
export function isParameterDeclaration(node: Node): node is ParameterDeclaration {
return node.kind === SyntaxKind.ParameterDeclaration;
}

export function isDecorator(node: Node): node is Decorator {
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/factory/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,7 @@ export function getTargetOfBindingOrAssignmentElement(bindingElement: BindingOrA
*/
export function getRestIndicatorOfBindingOrAssignmentElement(bindingElement: BindingOrAssignmentElement): BindingOrAssignmentElementRestIndicator | undefined {
switch (bindingElement.kind) {
case SyntaxKind.Parameter:
case SyntaxKind.ParameterDeclaration:
case SyntaxKind.BindingElement:
// `...` in `let [...a] = ...`
return bindingElement.dotDotDotToken;
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/factory/utilitiesPublic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export function setTextRange<T extends TextRange>(range: T, location: TextRange
export function canHaveModifiers(node: Node): node is HasModifiers {
const kind = node.kind;
return kind === SyntaxKind.TypeParameter
|| kind === SyntaxKind.Parameter
|| kind === SyntaxKind.ParameterDeclaration
|| kind === SyntaxKind.PropertySignature
|| kind === SyntaxKind.PropertyDeclaration
|| kind === SyntaxKind.MethodSignature
Expand Down Expand Up @@ -42,7 +42,7 @@ export function canHaveModifiers(node: Node): node is HasModifiers {

export function canHaveDecorators(node: Node): node is HasDecorators {
const kind = node.kind;
return kind === SyntaxKind.Parameter
return kind === SyntaxKind.ParameterDeclaration
|| kind === SyntaxKind.PropertyDeclaration
|| kind === SyntaxKind.MethodDeclaration
|| kind === SyntaxKind.GetAccessor
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ const forEachChildTable: ForEachChildTable = {
[SyntaxKind.SpreadAssignment]: function forEachChildInSpreadAssignment<T>(node: SpreadAssignment, cbNode: (node: Node) => T | undefined, _cbNodes?: (nodes: NodeArray<Node>) => T | undefined): T | undefined {
return visitNode(cbNode, node.expression);
},
[SyntaxKind.Parameter]: function forEachChildInParameter<T>(node: ParameterDeclaration, cbNode: (node: Node) => T | undefined, cbNodes?: (nodes: NodeArray<Node>) => T | undefined): T | undefined {
[SyntaxKind.ParameterDeclaration]: function forEachChildInParameter<T>(node: ParameterDeclaration, cbNode: (node: Node) => T | undefined, cbNodes?: (nodes: NodeArray<Node>) => T | undefined): T | undefined {
return visitNodes(cbNode, cbNodes, node.modifiers) ||
visitNode(cbNode, node.dotDotDotToken) ||
visitNode(cbNode, node.name) ||
Expand Down Expand Up @@ -3389,7 +3389,7 @@ namespace Parser {
}

function isReusableParameter(node: Node) {
if (node.kind !== SyntaxKind.Parameter) {
if (node.kind !== SyntaxKind.ParameterDeclaration) {
return false;
}

Expand Down
8 changes: 4 additions & 4 deletions src/compiler/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ import {
isModifier,
isModuleDeclaration,
isObjectLiteralExpression,
isParameter,
isParameterDeclaration,
isPlainJsFile,
isRequireCall,
isRootedDiskPath,
Expand Down Expand Up @@ -3147,7 +3147,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
// Otherwise break to visit each child

switch (parent.kind) {
case SyntaxKind.Parameter:
case SyntaxKind.ParameterDeclaration:
case SyntaxKind.PropertyDeclaration:
case SyntaxKind.MethodDeclaration:
if ((parent as ParameterDeclaration | PropertyDeclaration | MethodDeclaration).questionToken === node) {
Expand Down Expand Up @@ -3256,7 +3256,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
else if (canHaveDecorators(parent) && parent.modifiers) {
const decoratorIndex = findIndex(parent.modifiers, isDecorator);
if (decoratorIndex >= 0) {
if (isParameter(parent) && !options.experimentalDecorators) {
if (isParameterDeclaration(parent) && !options.experimentalDecorators) {
// report illegall decorator on parameter
diagnostics.push(createDiagnosticForNode(parent.modifiers[decoratorIndex], Diagnostics.Decorators_are_not_valid_here));
}
Expand Down Expand Up @@ -3321,7 +3321,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
return "skip";
}
break;
case SyntaxKind.Parameter:
case SyntaxKind.ParameterDeclaration:
// Check modifiers of parameter declaration
if (nodes === (parent as ParameterDeclaration).modifiers && some(nodes, isModifier)) {
diagnostics.push(createDiagnosticForNodeArray(nodes, Diagnostics.Parameter_modifiers_can_only_be_used_in_TypeScript_files));
Expand Down
6 changes: 3 additions & 3 deletions src/compiler/transformers/classFields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ import {
isObjectLiteralElementLike,
isObjectLiteralExpression,
isOmittedExpression,
isParameter,
isParameterDeclaration,
isParameterPropertyDeclaration,
isParenthesizedExpression,
isPrefixUnaryExpression,
Expand Down Expand Up @@ -478,7 +478,7 @@ export function transformClassFields(context: TransformationContext): (x: Source
return visitVariableStatement(node as VariableStatement);
case SyntaxKind.VariableDeclaration:
return visitVariableDeclaration(node as VariableDeclaration);
case SyntaxKind.Parameter:
case SyntaxKind.ParameterDeclaration:
return visitParameterDeclaration(node as ParameterDeclaration);
case SyntaxKind.BindingElement:
return visitBindingElement(node as BindingElement);
Expand Down Expand Up @@ -2460,7 +2460,7 @@ export function transformClassFields(context: TransformationContext): (x: Source
setCommentRange(statement, property);

const propertyOriginalNode = getOriginalNode(property);
if (isParameter(propertyOriginalNode)) {
if (isParameterDeclaration(propertyOriginalNode)) {
// replicate comment and source map behavior from the ts transform for parameter properties.
setSourceMapRange(statement, propertyOriginalNode);
removeAllComments(statement);
Expand Down
6 changes: 3 additions & 3 deletions src/compiler/transformers/declarations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ export function transformDeclarations(context: TransformationContext): Transform
// Literal const declarations will have an initializer ensured rather than a type
return;
}
const shouldAddImplicitUndefined = node.kind === SyntaxKind.Parameter && resolver.requiresAddingImplicitUndefined(node, enclosingDeclaration);
const shouldAddImplicitUndefined = node.kind === SyntaxKind.ParameterDeclaration && resolver.requiresAddingImplicitUndefined(node, enclosingDeclaration);
if (type && !shouldAddImplicitUndefined) {
return visitNode(type, visitDeclarationSubtree, isTypeNode);
}
Expand All @@ -691,7 +691,7 @@ export function transformDeclarations(context: TransformationContext): Transform
}
let typeNode;
switch (node.kind) {
case SyntaxKind.Parameter:
case SyntaxKind.ParameterDeclaration:
case SyntaxKind.PropertySignature:
case SyntaxKind.PropertyDeclaration:
case SyntaxKind.BindingElement:
Expand Down Expand Up @@ -1914,7 +1914,7 @@ function canHaveLiteralInitializer(node: Node): node is CanHaveLiteralInitialize
case SyntaxKind.PropertyDeclaration:
case SyntaxKind.PropertySignature:
return !hasEffectiveModifier(node, ModifierFlags.Private);
case SyntaxKind.Parameter:
case SyntaxKind.ParameterDeclaration:
case SyntaxKind.VariableDeclaration:
return true;
}
Expand Down
Loading