$('.click-reports-link').click(function() {
console.log(this);
});
if(b.items[i].member_id < 0) {
...
}
const [a, b, c, d, f, g= ''] = value.match(/\d+/g)!;
const [a, b, c, d, f, g= ''] = value.match(/\d+/g) || [];
[1, 2, 3].map((x, index) => ({x, y: index * 10 }));
// [ { x: 1, y: 0 }, { x: 2, y: 10 }, { x: 3, y: 20 } ]
// Эта функция определена где-то в другом месте (для примера вместо AsyncStorage)
declare function someMagic(key: string): string | null;
type StoreTypes = {
theme: 'light' | 'dark' | null;
auth: 'true' | 'false' | null;
}
// Собственно декларация функции
function getKey<K extends keyof StoreTypes>(key: K): StoreTypes[K] {
return someMagic(key) as StoreTypes[K];
}
// type t = "light" | "dark" | null
const t = getKey('theme');
// type a = "true" | "false" | null
const a = getKey('auth');
// ошибка "test" не является ключом в StoreTypes
const x = getKey('test');
request({
agent: tunnelingAgent,
url: "https://2ip.ru/",
headers: { ... }
}, callback);