This file contains 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 alias resolves to `True` if and only if `U` is the same as `V`, otherwise it resolves to `False`. | |
* @typeparam U - An arbitrary type | |
* @typeparam V - An arbitrary type | |
* @typeparam True - Production when `U` is the same as `V` | |
* @typeparam False - Production when `U` is not the same as `V` | |
*/ | |
export type Exact<U, V, True = true, False = false> = | |
{ <_>(): _ extends U ? 1 : 0 } extends { <_>(): _ extends V ? 1 : 0 } | |
? True |
This file contains 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
def PI: 3.14159265359; | |
def Radians(deg): deg * (PI / 180); | |
def Degrees(rad): rad * (180 / PI); | |
def a: 6378.137; #equitorial radius in km | |
def b: 6356.752; #polar radius in km | |
def radius_of_earth(lat1): | |
(((pow(((a*a)*(lat1 | cos));2))+(pow(((b*b)*(lat1 | sin));2)))/(pow((a*(lat1 | cos));2)+pow((b*(lat1 | sin));2))) | sqrt; | |
def Distance1(lat1;long1;lat2;long2): |
This file contains 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
/****************************************************************************** | |
* Implementation of `Nonempty` validator which checks that the provided type | |
* has at least one defined property, excluding `{}`. | |
******************************************************************************/ | |
type Nonempty<T extends { [key: string]: any }> = { [P in keyof T]: T }[keyof T]; | |
declare function wantsNonempty<T extends { [key: string]: any }>(x: Nonempty<T>): true; | |
wantsNonempty({ x: 1 }); | |
wantsNonempty({}); // error expected |
This file contains 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 StringSerialized<T extends object, Prefix extends string = ""> = T extends Array<any> ? { | |
[P in keyof T & `${bigint}`]: `-${P}` extends `${bigint}` | |
? | `${Prefix}${P}` | |
| StringSerialized<T[P] & object, `${Prefix}${P}.`> | |
: never | |
}[keyof T & `${bigint}`] : { | |
[P in keyof T & string]: | |
| `${Prefix}${P}` | |
| StringSerialized<T[P] & object, `${Prefix}${P}.`> | |
}[keyof T & string]; |
This file contains 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 UnionToIntersection< | |
T, | |
U = T extends unknown ? { _: { [_ in T & PropertyKey]: never } } : {}, | |
V = keyof U[keyof U], | |
// We need to remove the primitive we branded T with when we made it a | |
// property key. However, if the union T contains a branded type already, | |
// we must avoid stripping those brands off. | |
X = true extends (T extends PropertyKey ? true : never) ? never : PropertyKey | |
> = T extends never ? never : V extends X & infer W ? W : V; |
This file contains 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 Tuple<L extends number, T extends any[] = []> = | |
T["length"] extends L ? T : Tuple<L, [...T, void]>; | |
type Keys = [ | |
"Z", "Y", "X", "W", "V", "U", "T", "S", "R", | |
"Q", "P", "O", "N", "M", "L", "K", "J", "I", | |
"H", "G", "F", "E", "D", "C", "B", "A" | |
]; | |
type Evil = { |
This file contains 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
{ | |
"pnpm": { | |
"patchedDependencies": { | |
"typescript@5.0.4": "patches/typescript@5.0.4.patch" | |
} | |
} | |
} |
This file contains 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
&(?: | |
\w+;| | |
(?:AE|ae|sz)lig| | |
[Aa]ring| | |
[AaEeIiOoUu](?:grave|circ)| | |
[AaEeIiOoUuy]?(?:acute|uml)|Yacute| | |
[AaNnOo]tilde| | |
[AEeIiOoUu]irc| | |
[Cc]?cedil| | |
[lr]aquo| |
This file contains 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
const inputText = ` | |
yain.tain=1 | |
yain.tether=2 | |
foo=1 | |
foo.bar=2 | |
foo=2 | |
foo.baz=3 | |
bla.bla.bla=jlskdfjlskd.sdlfksldkfj=sldkjlskdf | |
` |
This file contains 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
const tsconfig = { | |
include: ["lib/**/*.ts", "lib/packages/**/*.ts", "lib/index.ts"], | |
exclude: ["src"], | |
files: ["lib/index.ts"], | |
typeAcquisition: { | |
enable: true, | |
disableFilenameBasedTypeAcquisition: true, | |
}, | |
compilerOptions: { | |
allowUnreachableCode: true, |