Message from JavaScript discussions

November 2020

— But uhh, *how* dynamic?

— 

/**
*
* param {number} id
* returns {Promise<Record<'Error' | 'Warning' | 'Notificiation' | 'Message' | 'Unknown', number>>}
*/
async countTypesByDevice(id) {
const types = await bookshelf.model('EventType').fetchAll()
const typeNames = R.map(R.prop('Type'), types.toJSON())
const typeCounts = await Promise.all(R.map(async type => ({
type,
count: await this.where({ type, id }).count()
}), typeNames))
// ts-ignore
return R.reduce((acc, cur) => R.assoc(cur.type, cur.count, acc), {}, typeCounts)
}

— If you can find all instances where you construct an event, you can make them static

— Oof

— Just TS it man

— We are still converting.

— Or.. I am converting.

— I only wonder.. while we are converting, can older branches still properly merge? When the file name is changed.. I think it is best then to pause everything else to convert

Message permanent page

— Wait, is Record<A, B> an alias for { [k: A]: B }?

— I think so.

— Utility types are love 👌

— I tried, but if I reinitialize it in my custom.js, it breaks the slider, and from my file I don't know how to make that function run before the standard initialization.

Message permanent page