gramps-graphql / gramps--legacy

The core data source combination engine of GrAMPS.
https://gramps.js.org
MIT License
197 stars 13 forks source link

Migrate code to TypeScript #80

Open corycook opened 6 years ago

corycook commented 6 years ago

This is my initial attempt to convert gramps to TypeScript.

Some notes:

TypeScript interfaces don't need to be implemented so the following is valid:

interface MyInterface {
  name: string;
}

function test(input: MyInterface) {
  console.log(input.name);
}

test({ name: 'testing' });

Interface files are not output during compilation and there is no executable code in files that just export interfaces so I'm using a naming convention to differentiate interface files to exclude them from coverage reporting. If we ever need to make a file that fits this naming convention (interface files are prefixed with a capital 'I') and is not an interface file then we may need to change how these files are excluded. They need to be excluded since coverage is reported as 0% statement coverage.

This implementation uses some loose definitions to fit the existing code. Implicit "any" type is not allowed; however, there is a lot of use of explicit any that could be more strictly defined. Most of the inputs and outputs are defined via interfaces to improve usability.