tsdjs / tsd

Check TypeScript type definitions
MIT License
2.4k stars 66 forks source link

Verbose API results #75

Open smartclash opened 4 years ago

smartclash commented 4 years ago

This PR is dependent on #74

TSD either returns a null array if there is no test failures or an array of Diagnostic objects. This PR aims to make TSD return with ExtendedDiagnostic object no matter if the tests fail or not.

Merging this PR allows custom test runners like Jest to report the number of assertions it evaluated in each file.

It also means that it introduces a breaking change because TSD now returns...


This PR is Co-Authored By:

SimenB commented 3 years ago

rebase this now that #74 has landed?

SimenB commented 3 years ago

Still very interested in seeing this land 😀

tommy-mitchell commented 1 year ago

Instead of making a breaking change, maybe tsd can just have verbose: boolean option?

const diagnostics = await tsd();
//=> Diagnostic[]

console.log(diagnostics.length);
//=> '0'
const verboseResults = await tsd({verbose: true});
//=> {testCount: number, diagnostics: Diagnostic[]}

console.log(verboseResults.testCount);
//=> '1024'

console.log(verboseResults.diagnostics.length);
//=> '0'
sindresorhus commented 1 year ago

I'm fine with this change. Having an object also gives us the opportunity to add additional properties in the future.

sindresorhus commented 1 year ago

Instead of making a breaking change, maybe tsd can just have verbose: boolean option?

I don't like options that change the return value type.

I think a breaking change is ok here. Programmatic use is not that common.