Skip to content

Instantly share code, notes, and snippets.

View error.log
TS2344: Type 'T[U]' does not satisfy the constraint '(...args: any) => any'.
Type 'T[OnlyFunctionPropertyNames<T>]' is not assignable to type '(...args: any) => any'.
Type 'T[T[keyof T] extends (...args: any) => any ? keyof T : never]' is not assignable to type '(...args: any) => any'.
Type 'T[keyof T]' is not assignable to type '(...args: any) => any'.
Type 'T[string] | T[number] | T[symbol]' is not assignable to type '(...args: any) => any'.
Type 'T[string]' is not assignable to type '(...args: any) => any'.
16 | T extends Composer<never>,
17 | U extends OnlyFunctionPropertyNames<T> = OnlyFunctionPropertyNames<T>,
> 18 | > = Filter<Parameters<T[U]>, Middleware<never>>
@drmikecrowe
drmikecrowe / README.md
Last active Aug 15, 2022
My journaling template
View README.md

I created the journals object that links a tag to a nested folder for all my journals. There are multiple issues this solves:

  • Journaling across multiple clients in different folders
  • Clicking on a link to a new journal entry that doesn't exist (see breadcrumb nested folder)
  • Client tagging

In the previous/next links, my link format is:

<< [[<% tag %>-<% tp.date.now("YYYY-MM-DD", -1) %>]] | [[<% tag %>-<% tp.date.now("YYYY-MM-DD", 1) %>]] >>
@drmikecrowe
drmikecrowe / launches.json
Last active Mar 4, 2022
My common launch.json config
View launches.json
[
{
"type": "node",
"request": "attach",
"port": 9229,
"sourceMaps": true,
"name": "Attach 9229",
"cwd": "${workspaceRoot}",
"address": "localhost",
"localRoot": "${workspaceFolder}",
View machine.js
const machine = Machine({
id: "formModal",
initial: "closed",
states: {
closed: {
on: {
OPEN: "opened"
}
},
View machine.js
const PMachineOptions = {
guards: {
IS_FETCH_NEEDED: function (ctx) {
return !ctx.podcast.loaded;
},
IS_FETCHED_ALREADY: function (ctx) {
return ctx.podcast.loaded;
},
IS_SUBSCRIBE_NEEDED: function (ctx) {
return !ctx.currentDevice.isSubscribed(ctx.podcast);
View machine.js
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
View machine.js
const states = {
IDLE: 'IDLE',
SEARCHING: 'SEARCHING',
};
const searchNotEmptyTarget = {
target: states.SEARCHING,
cond: (_ctx, evt) => evt.search !== '', // && evt.search.length > 3,
actions: assign({ search: (_ctx, evt) => evt.search }),
};
@drmikecrowe
drmikecrowe / index.d.ts
Created May 31, 2020
cache-manager index.d.ts types
View index.d.ts
declare module 'cache-manager/caching' {
/**
* Generic caching interface that wraps any caching library with a compatible interface.
* @param args.store - The store must at least have `set` and a `get` functions.
* @param [args.isCacheableValue] - A callback function which is called
* with every value returned from cache or from a wrapped function. This lets you specify
* which values should and should not be cached. If the function returns true, it will be
* stored in cache. By default it caches everything except undefined.
*/
function caching(args: {
@drmikecrowe
drmikecrowe / index.d.ts
Created May 30, 2020
index.d.ts for cache-manager
View index.d.ts
/**
* Instead of manually managing the cache like this:
* function getCachedUserManually(id, cb) {
* memoryCache.get(id, function(err, result) {
* if (err) { return cb(err); }
*
* if (result) {
* return cb(null, result);
* }
*
View machine.js
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions