Skip to content

Commit

Permalink
Define return type of parse() in subclasses of Expression
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliver Wipfli authored and wipfli committed Jul 18, 2021
1 parent 9fe8cf6 commit 4e72829
Show file tree
Hide file tree
Showing 14 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/style-spec/expression/definitions/at.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class At implements Expression {
this.input = input;
}

static parse(args: ReadonlyArray<unknown>, context: ParsingContext) {
static parse(args: ReadonlyArray<unknown>, context: ParsingContext): Expression | undefined | null {
if (args.length !== 3)
return context.error(`Expected 2 arguments, but found ${args.length - 1} instead.`);

Expand Down
2 changes: 1 addition & 1 deletion src/style-spec/expression/definitions/case.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Case implements Expression {
this.otherwise = otherwise;
}

static parse(args: ReadonlyArray<unknown>, context: ParsingContext) {
static parse(args: ReadonlyArray<unknown>, context: ParsingContext): Expression | undefined | null {
if (args.length < 4)
return context.error(`Expected at least 3 arguments, but found only ${args.length - 1}.`);
if (args.length % 2 !== 0)
Expand Down
2 changes: 1 addition & 1 deletion src/style-spec/expression/definitions/coalesce.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Coalesce implements Expression {
this.args = args;
}

static parse(args: ReadonlyArray<unknown>, context: ParsingContext) {
static parse(args: ReadonlyArray<unknown>, context: ParsingContext): Expression | undefined | null {
if (args.length < 2) {
return context.error("Expectected at least one argument.");
}
Expand Down
2 changes: 1 addition & 1 deletion src/style-spec/expression/definitions/in.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class In implements Expression {
this.haystack = haystack;
}

static parse(args: ReadonlyArray<unknown>, context: ParsingContext) {
static parse(args: ReadonlyArray<unknown>, context: ParsingContext): Expression | undefined | null {
if (args.length !== 3) {
return context.error(`Expected 2 arguments, but found ${args.length - 1} instead.`);
}
Expand Down
2 changes: 1 addition & 1 deletion src/style-spec/expression/definitions/index_of.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class IndexOf implements Expression {
this.fromIndex = fromIndex;
}

static parse(args: ReadonlyArray<unknown>, context: ParsingContext) {
static parse(args: ReadonlyArray<unknown>, context: ParsingContext): Expression | undefined | null {
if (args.length <= 2 || args.length >= 5) {
return context.error(`Expected 3 or 4 arguments, but found ${args.length - 1} instead.`);
}
Expand Down
2 changes: 1 addition & 1 deletion src/style-spec/expression/definitions/interpolate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class Interpolate implements Expression {
return t;
}

static parse(args: ReadonlyArray<unknown>, context: ParsingContext) {
static parse(args: ReadonlyArray<unknown>, context: ParsingContext): Expression | undefined | null {
let [operator, interpolation, input, ...rest] = args;

if (!Array.isArray(interpolation) || interpolation.length === 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/style-spec/expression/definitions/length.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Length implements Expression {
this.input = input;
}

static parse(args: ReadonlyArray<unknown>, context: ParsingContext) {
static parse(args: ReadonlyArray<unknown>, context: ParsingContext): Expression | undefined | null {
if (args.length !== 2)
return context.error(`Expected 1 argument, but found ${args.length - 1} instead.`);

Expand Down
2 changes: 1 addition & 1 deletion src/style-spec/expression/definitions/let.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Let implements Expression {
fn(this.result);
}

static parse(args: ReadonlyArray<unknown>, context: ParsingContext) {
static parse(args: ReadonlyArray<unknown>, context: ParsingContext): Expression | undefined | null {
if (args.length < 4)
return context.error(`Expected at least 3 arguments, but found ${args.length - 1} instead.`);

Expand Down
2 changes: 1 addition & 1 deletion src/style-spec/expression/definitions/literal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Literal implements Expression {
this.value = value;
}

static parse(args: ReadonlyArray<unknown>, context: ParsingContext) {
static parse(args: ReadonlyArray<unknown>, context: ParsingContext): Expression | undefined | null {
if (args.length !== 2)
return context.error(`'literal' expression requires exactly one argument, but found ${args.length - 1} instead.`);

Expand Down
2 changes: 1 addition & 1 deletion src/style-spec/expression/definitions/match.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Match implements Expression {
this.otherwise = otherwise;
}

static parse(args: ReadonlyArray<unknown>, context: ParsingContext) {
static parse(args: ReadonlyArray<unknown>, context: ParsingContext): Expression | undefined | null {
if (args.length < 5)
return context.error(`Expected at least 4 arguments, but found only ${args.length - 1}.`);
if (args.length % 2 !== 1)
Expand Down
2 changes: 1 addition & 1 deletion src/style-spec/expression/definitions/slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Slice implements Expression {

}

static parse(args: ReadonlyArray<unknown>, context: ParsingContext) {
static parse(args: ReadonlyArray<unknown>, context: ParsingContext): Expression | undefined | null {
if (args.length <= 2 || args.length >= 5) {
return context.error(`Expected 3 or 4 arguments, but found ${args.length - 1} instead.`);
}
Expand Down
2 changes: 1 addition & 1 deletion src/style-spec/expression/definitions/step.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Step implements Expression {
}
}

static parse(args: ReadonlyArray<unknown>, context: ParsingContext) {
static parse(args: ReadonlyArray<unknown>, context: ParsingContext): Expression | undefined | null {
if (args.length - 1 < 4) {
return context.error(`Expected at least 4 arguments, but found only ${args.length - 1}.`);
}
Expand Down
2 changes: 1 addition & 1 deletion src/style-spec/expression/definitions/var.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Var implements Expression {
this.boundExpression = boundExpression;
}

static parse(args: ReadonlyArray<unknown>, context: ParsingContext) {
static parse(args: ReadonlyArray<unknown>, context: ParsingContext): Expression | undefined | null {
if (args.length !== 2 || typeof args[1] !== 'string')
return context.error(`'var' expression requires exactly one string literal argument.`);

Expand Down
2 changes: 1 addition & 1 deletion src/style-spec/expression/definitions/within.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ class Within implements Expression {
this.geometries = geometries;
}

static parse(args: ReadonlyArray<unknown>, context: ParsingContext) {
static parse(args: ReadonlyArray<unknown>, context: ParsingContext): Expression | undefined | null {
if (args.length !== 2)
return context.error(`'within' expression requires exactly one argument, but found ${args.length - 1} instead.`);
if (isValue(args[1])) {
Expand Down

0 comments on commit 4e72829

Please sign in to comment.