studye / typescript

타입스크립트는 자바스크립트랑 다른 언어인가요?
7 stars 0 forks source link

[Chapter 5 - Declaration] Declaration syntax reference #24

Open junthus opened 7 years ago

junthus commented 7 years ago

.d.ts advanced

이런건 어떻게 쓰지 ?

function overrides

declare function trace(arg: string | number | boolean );
declare function trace(arg: { id: number; name: string });

nested namespaces

js에서 네임 스페이스를 사용하는 경우 패스를 일치시켜야 정상적으로 사용할 수 있음

FirstNamespace.SecondNamespace.ThirdNamespace.log("test");
declare module FirstNamespace {
    module SecondNamespace {
        module ThirdNamespace {
            function log(msg: string);
        }
    }
}

classes

declare class MyClass {}

global namespace

namespace 계열 키워드(namespace/module) 가 없으면 global namespace 로 간주

declare function globalLogError(msg: string);

callback (function signatures)

describe("test", function (str) { console.log(str)});
declare function describe(name: string, callback: (name: string) => void); 

optional properties

property_name + ?

seemore