DefinitelyTyped/definitelytyped.github.io

Best Practies

basarat opened this issue · 3 comments

Another one

Prefer func() style function declarations on interfaces instead of func:Function as they allow overriding i.e. DO

interface Foo{
    take():number;
    take(num:number):void;
}

instead of

interface Foo {
    take: () => number;
    // No way to define this now, 
    take(num: number): void; // Error : duplicate identifier
}

How to debug .d.ts. (Type annotation is being used as intended.)

If you write .d.ts(callee).
try write testcast(caller) without type annotations and compile with --noImplicitAny.

e.g. http://goo.gl/4A24hk

microsoft/TypeScript#305


https://twitter.com/vvakame/statuses/494322013809307650
https://twitter.com/vvakame/statuses/494322400322797569

The Best Practices guide (repo file: /src/documents/guides/best-practices.html.md.eco) states at the beginning:

"As much as it hurts to say it, TypeScript v1.0 is not flawless. There are certain minor flaws / shortcomings in the language which have implicatations for how typings are created. Here we will detail those limitations, how they can be worked around at present"

As TypeScript is currently at v1.6.2, the guide should probably be updated. I wonder if the flaws presented in the guide are still present.

Please, fix also the typo in the title of the issue to be able to find it using the search engine.

Engid commented

Typescript is up to 2.9 now, so the page is definitely out of date