This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
factorius, | |
requires, | |
instance, | |
transient, | |
optional, | |
externalId, | |
type, | |
tokensOf, | |
} from './factorius'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare const errorTag: unique symbol; | |
type TypesError<T> = { [errorTag]: T }; | |
interface Validatable { | |
validate(): boolean; | |
} | |
type Assert<T, TType, TTypeName extends string, TTargetName extends string = string, TSource extends string = string> = T extends TType ? T : | |
string extends TTargetName | |
? TypesError<`T should be of type {${TTypeName}}`> | |
: string extends TSource | |
? TypesError<`{${TTargetName}} should be of type {${TTypeName}}`> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { type O } from 'ts-toolbelt'; | |
type InferInterpolation<TString> = | |
TString extends `${string}{${infer I}}${infer R}` | |
? O.Merge<{ [K in I]: string | number }, InferInterpolation<R>> | |
: object; | |
type TFunctionParams< | |
TNamespace, | |
TKey extends keyof TNamespace, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* eslint-disable @typescript-eslint/no-unsafe-return */ | |
/* eslint-disable @typescript-eslint/no-explicit-any */ | |
import { type O } from 'ts-toolbelt'; | |
type MapLayer<TServices> = | |
TServices extends Record<string, (di: any) => any> | |
? { | |
[K in keyof TServices]: ReturnType<TServices[K]>; | |
} | |
: never; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { mapValues } from 'remeda'; | |
export class Token<in out T> { | |
constructor(readonly id: string) {} | |
} | |
export declare namespace Token { | |
export type Type<T extends Token<any>> = T extends Token<infer S> ? S : never; | |
} | |
export class Container<in TTokens extends Token<any> = never> { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// TODO: make eslint rule only allowing to UseHook inside client components | |
// TODO: make eslint rule not allowing conditions inside useHook | |
export function UseHook<T>(props: { | |
useHook: () => T; | |
children: (hookResult: T) => JSX.Element; | |
}) { | |
const hookResult = props.useHook(); | |
return <>{props.children(hookResult)}</>; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Token<T, Id extends string> { | |
/** @typeonly */ | |
private readonly __type: T = null!; | |
constructor(readonly id: Id) {} | |
} | |
declare namespace Token { | |
export type Type<T> = T extends Token<infer TokenType, string> ? TokenType : never; | |
export type Id<T> = T extends Token<unknown, infer TokenId> ? TokenId : never; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let currentInjector: IInjector | null = null; | |
function runInInjectionContext(injector: IInjector, fn: () => void) { | |
const prevInjector = currentInjector; | |
currentInjector = injector; | |
try { | |
fn(); | |
} finally { | |
currentInjector = prevInjector; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type NeverIfNotExtends<T, P> = T extends P ? T : never; | |
type IFactoryBindConfig = { | |
fresh: true; | |
eager?: false; | |
} | { | |
fresh: false; | |
eager?: boolean; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
[RequireComponent(typeof(PolygonCollider2D))] | |
[RequireComponent(typeof(MeshFilter))] | |
[RequireComponent(typeof(MeshRenderer))] | |
[RequireComponent(typeof(LineRenderer))] | |
public class MeshFromPolygonCollider2D : MonoBehaviour | |
{ | |
// Based onh ttp://answers.unity3d.com/questions/835675/how-to-fill-polygon-collider-with-a-solid-color.html |
NewerOlder