Skip to content
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

fix: accept variadic arguments after optional arguments #307

Merged
merged 2 commits into from
Nov 9, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
14 changes: 10 additions & 4 deletions packages/jsii-calc/lib/compliance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -994,6 +994,12 @@ export interface NullShouldBeTreatedAsUndefinedData {
arrayWithThreeElementsAndUndefinedAsSecondArgument: any[];
}

export class DontComplainAboutVariadicAfterOptional {
public optionalAndVariadic(optional?: string, ...things: string[]) {
return `${optional} and ${things.join(',')}`;
}
}

/**
* jsii#298: show default values in sphinx documentation, and respect newlines.
**/
Expand All @@ -1012,7 +1018,7 @@ export interface LoadBalancedFargateServiceProps {
* @default 256
*/
cpu?: string;

/**
* The amount (in MiB) of memory used by the task.
*
Expand All @@ -1034,21 +1040,21 @@ export interface LoadBalancedFargateServiceProps {
* @default 512
*/
memoryMiB?: string;

/**
* The container port of the application load balancer attached to your Fargate service. Corresponds to container port mapping.
*
* @default 80
*/
containerPort?: number;

/**
* Determines whether the Application Load Balancer will be internet-facing
*
* @default true
*/
publicLoadBalancer?: boolean;

/**
* Determines whether your Fargate Service will be assigned a public IP address.
*
Expand Down
2 changes: 1 addition & 1 deletion packages/jsii/lib/assembler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,7 @@ export class Assembler implements Emitter {

let optional = false;
for (const p of parameters) {
if (optional && !p.type.optional) {
if (optional && !p.type.optional && !p.variadic) {
this._diagnostic(node, ts.DiagnosticCategory.Error,
`Parameter ${p.name} must be optional since it comes after an optional parameter`);
}
Expand Down