import { Dictionary , DictionaryValues , DeepPartial , DeepReadonly , Opaque , DeepRequired , AsyncOrSync , } from "../lib/types" ; const stringDict = { a : "A" , b : "B" , } ; const dictOfNumbers = { 420 : "four twenty" , 1337 : "HAX" , } ; export type DummyOptions = "open" | "closed" | "unknown" ; const dictFromUnionType = { closed : 1 , open : 2 , unknown : 3 , } ; type stringDictValues = DictionaryValues < typeof stringDict > ; type ComplexObject = { simple : number ; nested : { a : string ; array : [ { bar : number ; } ] ; } ; } ; type ComplexObjectPartial = DeepPartial < ComplexObject > ; const samplePartial = { nested : { array : [ ] , } , } ; type ComplexObjectAgain = DeepRequired < ComplexObjectPartial > ; const sampleRequired = { simple : 5 , nested : { a : "test" , array : [ { bar : 1 } ] , } , } ; type ComplexObjectReadonly = DeepReadonly < ComplexObject > ; type SimplifiedComplexObject = Omit < ComplexObject , "nested" > ; type PositiveNumber = Opaque < number , "PositiveNumber" > ; function makePositiveNumber ( n ) { if ( n <= 0 ) { throw new Error ( `Value ${ n } is not positive !` ) ; } return n as any as PositiveNumber ; } type NegativeNumber = Opaque < number , "NegativeNumber" > ; function makeNegativeNumber ( n ) { if ( n >= 0 ) { throw new Error ( `Value ${ n } is not negative !` ) ; } return n as any as NegativeNumber ; } let a = makePositiveNumber ( 5 ) ; let b = makeNegativeNumber ( - 10 ) ; interface CiProvider { getSHA ( ) : AsyncOrSync < string > ; } class Circle implements CiProvider { getSHA ( ) { return "abc" ; } } class Travis implements CiProvider { async getSHA ( ) { return "def" ; } }