{} 타입은 Object 타입과 같습니다. 이름은 객체이지만 객체만 대입할 수 있는 타입은 아닙니다. object 타입과는 다른 타입으로 O를 대문자로 씁니다.

    const str: Object = 'hello';
    const num: Object = 123;
    const bool: Object = true;
    const obj: Object = { name: 'zero' };
    const arr: Object = [];
    const func: Object = () => {};
    const n: Object = null; 
    // Type 'null' is not assignable to type 'Object'.
    const u: Object = undefined; 
    // Type 'undefined' is not assignable to type 'Object'.
    

    실제로 사용할 수 없으니, {} 타입은 대부분의 경우 쓸모가 없는 타입입니다. 이는 원시값이 아닌 객체를 의미하는 object 타입도 마찬가지입니다.

    const obj: Object = { name: 'zero' };
    const arr: Object = [];
    const func: Object = () => {};
    obj.name; 
    // Property 'name' does not exist on type '{}'.
    arr[0]; 
    // Element implicitly has an 'any' type because expression of type '0' can't be used to index type '{}'. Property '0' does not exist on type '{}'.
    func(); 
    // This expression is not callable. Type '{}' has no call signatures.
    
    신간 소식 구독하기
    뉴스레터에 가입하시고 이메일로 신간 소식을 받아 보세요.