Screeps-Typescript-Declarations icon indicating copy to clipboard operation
Screeps-Typescript-Declarations copied to clipboard

Interfaces instead of declared classes

Open dbaileychess opened this issue 8 years ago • 4 comments

Wouldn't it make more sense to have the screeps.d.ts generated with 'Interfaces' instead of 'declare class'? This repo isn't providing any implementation, its more used as a type system.

See (https://stackoverflow.com/questions/14311675/typescript-declaration-files-contain-class-definitions-with-no-member-implementa/14323673#14323673 and https://stackoverflow.com/questions/14345485/whats-the-difference-between-declare-class-and-interface-in-typescript)

dbaileychess avatar Sep 13 '17 01:09 dbaileychess

Taking a look at the repo, the only instance of a declare class is for RoomVisual which can be an interface as well, I think.

thaelina avatar Sep 15 '17 13:09 thaelina

The npm package (4.2.1) is outdated or pointing to the 'classes' branch then, most definitions are still 'classes' in the npm package.

dbaileychess avatar Sep 15 '17 17:09 dbaileychess

Ah, well the repo is almost all interfaces. Personally I use typings

thaelina avatar Sep 15 '17 18:09 thaelina

Yes, interfaces allow extension, especially static extension using the duet declaration with a constructor interface, so this is the preference set by the Typescript standard library.

Dessix avatar Oct 01 '17 18:10 Dessix