36
export const CONST_TRUE = true;
37
export const CONST_FALSE = false;
38
39
-export function initFbt() {
39
+export function initFbt(): void {
40
const viewerContext: IntlViewerContext = {
41
GENDER: IntlVariations.GENDER_UNKNOWN,
42
locale: "en_US",
52
53
export function mutate(arg: any): void {
54
// don't mutate primitive
55
- if (typeof arg === null || typeof arg !== "object") {
55
+ if (arg == null || typeof arg !== "object") {
56
return;
57
}
58
80
81
export function setProperty(arg: any, property: any): void {
82
// don't mutate primitive
83
- if (typeof arg === null || typeof arg !== "object") {
83
+ if (arg == null || typeof arg !== "object") {
84
return arg;
85
}
86
123
/**
124
* Functions that do not mutate their parameters
125
*/
126
-export function shallowCopy(obj: Object): object {
126
+export function shallowCopy(obj: object): object {
127
return Object.assign({}, obj);
128
}
129
139
return value + 1;
140
}
141
142
-// Alias console.log, as it is defined as a global and may have
143
-// different compiler handling than unknown functions
144
-export function print(...args: Array<unknown>) {
142
+/*
143
+ * Alias console.log, as it is defined as a global and may have
144
+ * different compiler handling than unknown functions
145
+ */
146
+export function print(...args: Array<unknown>): void {
147
console.log(...args);
148
}
149
155
throw new Error(message);
156
}
157
156
-export function throwInput(x: Object): never {
158
+export function throwInput(x: object): never {
159
throw x;
160
}
161
169
console.log(value);
170
}
171
170
-export function useHook(): Object {
172
+export function useHook(): object {
173
return makeObject_Primitives();
174
}
175
176
const noAliasObject = Object.freeze({});
175
-export function useNoAlias(...args: Array<any>): object {
177
+export function useNoAlias(..._args: Array<any>): object {
178
return noAliasObject;
179
}
180
185
export function invoke<T extends Array<any>, ReturnType>(
186
fn: (...input: T) => ReturnType,
187
...params: T
186
-) {
188
+): ReturnType {
189
return fn(...params);
190
}
191
193
shouldInvoke: boolean,
194
fn: (...input: T) => ReturnType,
195
...params: T
194
-) {
196
+): ReturnType | null {
197
if (shouldInvoke) {
198
return fn(...params);
199
} else {
207
export function Text(props: {
208
value: string;
209
children?: Array<React.ReactNode>;
208
-}) {
210
+}): React.ReactElement {
211
return React.createElement("div", null, props.value, props.children);
212
}
213
212
-export function StaticText1(props: { children?: Array<React.ReactNode> }) {
214
+export function StaticText1(props: {
215
+ children?: Array<React.ReactNode>;
216
+}): React.ReactElement {
217
return React.createElement("div", null, "StaticText1", props.children);
218
}
219
216
-export function StaticText2(props: { children?: Array<React.ReactNode> }) {
220
+export function StaticText2(props: {
221
+ children?: Array<React.ReactNode>;
222
+}): React.ReactElement {
223
return React.createElement("div", null, "StaticText2", props.children);
224
}
225
226
export function RenderPropAsChild(props: {
227
items: Array<() => React.ReactNode>;
222
-}) {
228
+}): React.ReactElement {
229
return React.createElement(
230
"div",
231
null,
248
}: {
249
inputs: Array<any>;
250
output: any;
245
-}) {
251
+}): React.ReactElement {
252
"use no forget";
253
const [previousInputs, setPreviousInputs] = React.useState(inputs);
254
const [previousOutput, setPreviousOutput] = React.useState(output);
279
}
280
281
// helper functions
276
-export function toJSON(value: any, invokeFns: boolean = false) {
282
+export function toJSON(value: any, invokeFns: boolean = false): string {
283
const seen = new Map();
284
285
return JSON.stringify(value, (_key: string, val: any) => {
325
},
326
};
327
322
-export function useFragment(...args: Array<any>): Object {
328
+export function useFragment(..._args: Array<any>): object {
329
return {
330
a: [1, 2, 3],
331
b: { c: { d: 4 } },