import { expectError , expectType } from "tsd" ; expectType < unknown > ( eval ( "foo" ) ) ; expectType < { } > ( Object ( ) ) ; expectType < { foo : number ; } > ( Object ( { foo : 123 } ) ) ; expectType < { } > ( Object ( 123 ) ) ; expectType < unknown > ( Object . getPrototypeOf ( [ ] ) ) ; expectType < { } > ( Object . create ( null ) ) ; expectType < { foo : number ; bar : string ; } > ( Object . create ( null , { foo : { value : 123 , } , bar : { get ( ) { return "hi" ; } , } , } ) ) ; expectType < { foo : number ; } > ( Object . defineProperty ( { } , "foo" , { value : 123 , } ) ) ; expectType < { foo : number ; } | { bar : number ; } > ( Object . defineProperty ( { } , "foo" as "foo" | "bar" , { value : 123 , } ) ) ; expectType < { foo : number ; bar : string ; baz : boolean ; } > ( Object . defineProperties ( { foo : 123 } , { bar : { value : "hi" , } , baz : { get ( ) { return true ; } , } , } ) ) ; { const add = ( a , b ) : number => a + b ; expectType < ( a : number , b : number ) => number > ( add . bind ( null ) ) ; expectType < ( b : number ) => number > ( add . bind ( null , 123 ) ) ; expectType < ( ) => number > ( add . bind ( null , 123 , 456 ) ) ; expectError ( add . bind ( null , 123 , 456 , 789 ) ) ; const add2 = function ( this , a ) : number { return this . num + a ; } ; expectError ( add2 . bind ( null ) ) ; expectError ( add2 . bind ( null , 123 ) ) ; expectType < ( a : number ) => number > ( add2 . bind ( { num : 0 } ) ) ; expectType < ( ) => number > ( add2 . bind ( { num : 100 } , 123 ) ) ; expectError ( add2 . bind ( { num : 100 } , 123 , 456 ) ) ; } ( function ( ) { expectType < unknown > ( arguments [ 0 ] ) ; } ) ( ) ; { expectType < JSONValue > ( JSON . parse ( "{}" ) ) ; const arr = [ 1 , 2 , "foo" ] ; expectType < string > ( JSON . stringify ( arr ) ) ; const obj = { foo : { bar : 1 } } ; expectType < string > ( JSON . stringify ( obj ) ) ; const readonlyArr = [ 1 , 2 , 3 ] as const ; expectType < string > ( JSON . stringify ( readonlyArr ) ) ; const readonlyObj = { foo : { bar : 1 } } as const ; expectType < string > ( JSON . stringify ( readonlyObj ) ) ; interface Param { id : string ; value : number ; } + function foo ( param , readonlyParam ) { JSON . stringify ( param ) ; JSON . stringify ( readonlyParam ) ; } ; } { const a1 = new Array ( ) ; expectType < unknown [ ] > ( a1 ) ; const a2 = new Array < number > ( ) ; expectType < number [ ] > ( a2 ) ; const a3 = new Array ( ) ; expectType < number [ ] > ( a3 ) ; const a4 = new Array ( "foo" , "bar" ) ; expectType < string [ ] > ( a4 ) ; const a5 = new Array ( 1 ) ; expectType < unknown [ ] > ( a5 ) ; const a6 = new Array < boolean > ( 1 ) ; expectType < boolean [ ] > ( a6 ) ; const a7 = new Array ( 1 ) ; expectType < boolean [ ] > ( a7 ) ; const a8 = { } ; if ( Array . isArray ( a7 ) ) { expectType < boolean > ( a7 [ 0 ] ) ; } if ( Array . isArray ( a8 ) ) { expectType < unknown > ( a8 [ 0 ] ) ; } } export { } ;