import { Decoder , fields , fieldsAuto , number , string } from "../" ; test ( "type annotations" , ( ) => { type Person = { name : string ; age : number ; } ; function greet ( person ) { return `Hello, ${ person . name }!` ; } const testPerson = { name : "John" , age : 30 , aye : 0 , extra : "" } ; const personDecoder1 = fields ( ( field ) => ( { name : field ( "name" , string ) , aye : field ( "age" , number ) , } ) ) ; const personDecoder1Auto = fieldsAuto ( { name : string , aye : number , } ) ; greet ( personDecoder1 ( testPerson ) ) ; greet ( personDecoder1Auto ( testPerson ) ) ; const personDecoder2 = fields ( ( field ) : Person => ( { name : field ( "name" , string ) , aye : field ( "age" , number ) , } ) ) ; const personDecoder2Auto = fieldsAuto < Person > ( { name : string , aye : number , } ) ; greet ( personDecoder2 ( testPerson ) ) ; greet ( personDecoder2Auto ( testPerson ) ) ; const personDecoder5 = fields ( ( field ) => ( { name : field ( "name" , string ) , age : field ( "age" , number ) , extra : field ( "extra" , string ) , } ) ) ; const personDecoder5Auto = fieldsAuto ( { name : string , age : number , extra : string , } ) ; greet ( personDecoder5 ( testPerson ) ) ; greet ( personDecoder5Auto ( testPerson ) ) ; const personDecoder6 = fields ( ( field ) => ( { name : field ( "name" , string ) , age : field ( "age" , number ) , extra : field ( "extra" , string ) , } ) ) ; const personDecoder6Auto = fieldsAuto ( { name : string , age : number , extra : string , } ) ; greet ( personDecoder6 ( testPerson ) ) ; greet ( personDecoder6Auto ( testPerson ) ) ; const personDecoder7 = fields ( ( field ) : Person => ( { name : field ( "name" , string ) , age : field ( "age" , number ) , extra : field ( "extra" , string ) , } ) ) ; const personDecoder7Auto = fieldsAuto < Person > ( { name : string , age : number , extra : string , } ) ; greet ( personDecoder7 ( testPerson ) ) ; greet ( personDecoder7Auto ( testPerson ) ) ; const personDecoder8 = fields ( ( field ) : Person => ( { name : field ( "name" , string ) , age : field ( "age" , number ) , } ) ) ; const personDecoder8Auto = fieldsAuto < Person > ( { name : string , age : number , } ) ; greet ( personDecoder8 ( testPerson ) ) ; greet ( personDecoder8Auto ( testPerson ) ) ; expect ( personDecoder8 ( testPerson ) ) . toMatchInlineSnapshot ( `
    Object {
      "age": 30,
      "name": "John",
    }
  ` ) ; expect ( personDecoder8Auto ( testPerson ) ) . toMatchInlineSnapshot ( `
    Object {
      "age": 30,
      "name": "John",
    }
  ` ) ; } ) ;