Skip to content

Commit d101b90

Browse files
authored
Merge pull request #590 from eemeli/update-deps
Update dependencies & fix minor TS issue
2 parents 5406b34 + ebd98dc commit d101b90

File tree

6 files changed

+3282
-3162
lines changed

6 files changed

+3282
-3162
lines changed

fluent-langneg/src/negotiate_languages.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {filterMatches} from "./matches.js";
1+
import { filterMatches } from "./matches.js";
22

33
export interface NegotiateLanguagesOptions {
44
strategy?: "filtering" | "matching" | "lookup";
@@ -51,22 +51,19 @@ export interface NegotiateLanguagesOptions {
5151
export function negotiateLanguages(
5252
requestedLocales: Readonly<Array<string>>,
5353
availableLocales: Readonly<Array<string>>,
54-
{
55-
strategy = "filtering",
56-
defaultLocale,
57-
}: NegotiateLanguagesOptions = {}
54+
{ strategy = "filtering", defaultLocale }: NegotiateLanguagesOptions = {}
5855
): Array<string> {
59-
6056
const supportedLocales = filterMatches(
61-
Array.from(Object(requestedLocales)).map(String),
62-
Array.from(Object(availableLocales)).map(String),
57+
Array.from(requestedLocales ?? []).map(String),
58+
Array.from(availableLocales ?? []).map(String),
6359
strategy
6460
);
6561

6662
if (strategy === "lookup") {
6763
if (defaultLocale === undefined) {
6864
throw new Error(
69-
"defaultLocale cannot be undefined for strategy `lookup`");
65+
"defaultLocale cannot be undefined for strategy `lookup`"
66+
);
7067
}
7168
if (supportedLocales.length === 0) {
7269
supportedLocales.push(defaultLocale);

fluent-syntax/src/ast.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export abstract class BaseNode {
4747
return true;
4848
}
4949

50-
clone(): BaseNode {
50+
clone(): this {
5151
function visit(value: unknown): unknown {
5252
if (value instanceof BaseNode) {
5353
return value.clone();
@@ -57,7 +57,8 @@ export abstract class BaseNode {
5757
}
5858
return value;
5959
}
60-
const clone = Object.create(this.constructor.prototype) as BaseNode;
60+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
61+
const clone = Object.create(this.constructor.prototype) as this;
6162
for (const prop of Object.keys(this)) {
6263
clone[prop] = visit(this[prop]);
6364
}

fluent-syntax/src/visitor.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export abstract class Transformer extends Visitor {
106106
} else if (Array.isArray(prop)) {
107107
let newVals: Array<AST.BaseNode> = [];
108108
for (let element of prop) {
109-
let newVal = this.visit(element);
109+
let newVal = this.visit(element as AST.BaseNode);
110110
if (newVal !== undefined) {
111111
newVals.push(newVal);
112112
}
@@ -127,10 +127,12 @@ export abstract class Transformer extends Visitor {
127127
visitNumberLiteral?(node: AST.NumberLiteral): AST.BaseNode | undefined;
128128
visitMessageReference?(node: AST.MessageReference): AST.BaseNode | undefined;
129129
visitTermReference?(node: AST.TermReference): AST.BaseNode | undefined;
130-
visitVariableReference?(node: AST.VariableReference):
131-
AST.BaseNode | undefined;
132-
visitFunctionReference?(node: AST.FunctionReference):
133-
AST.BaseNode | undefined;
130+
visitVariableReference?(
131+
node: AST.VariableReference
132+
): AST.BaseNode | undefined;
133+
visitFunctionReference?(
134+
node: AST.FunctionReference
135+
): AST.BaseNode | undefined;
134136
visitSelectExpression?(node: AST.SelectExpression): AST.BaseNode | undefined;
135137
visitCallArguments?(node: AST.CallArguments): AST.BaseNode | undefined;
136138
visitAttribute?(node: AST.Attribute): AST.BaseNode | undefined;

0 commit comments

Comments
 (0)