pretiac

npm

pretiac: PREtty Typed Icinga2 Api Client

Similar projects

https://github.com/adedomin/perfdata-parser

TypeDoc

https://typedoc.org/tags/group/

Configuration attributes

/**
* @group config
*/

Runtime attributes

/**
* @group runtime
*/

Attributes that represent object relationships. The objects are linked via joins.

/**
* @group navigation
*/

Typescript

TypeScript function return type based on input parameter

https://stackoverflow.com/a/54166010

interface Circle {
type: 'circle'
radius: number
}

interface Square {
type: 'square'
length: number
}

type TypeName = 'circle' | 'square'

type ObjectTyp<T> = T extends 'circle'
? Circle
: T extends 'square'
? Square
: never

const shapes: (Circle | Square)[] = [
{ type: 'circle', radius: 1 },
{ type: 'circle', radius: 2 },
{ type: 'square', length: 10 }
]

function getItems<T extends TypeName>(type: T): ObjectTyp<T>[] {
return shapes.filter((s) => s.type == type) as ObjectTyp<T>[]
}

const circles = getItems('circle')
for (const circle of circles) {
console.log(circle.length)
}