definitelytyped.github.io icon indicating copy to clipboard operation
definitelytyped.github.io copied to clipboard

Best Practies

Open basarat opened this issue 10 years ago • 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
}

basarat avatar Jul 12 '14 07:07 basarat

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

https://github.com/Microsoft/TypeScript/issues/305


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

vvakame avatar Jul 30 '14 03:07 vvakame

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.

SynerG avatar Nov 05 '15 09:11 SynerG

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

Engid avatar Jul 06 '18 02:07 Engid