Closed angeloashmore closed 3 years ago
Merging #15 (3025f5e) into master (05c7ea8) will not change coverage. The diff coverage is
n/a
.
@@ Coverage Diff @@
## master #15 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 3 3
Lines 59 59
=========================================
Hits 59 59
Impacted Files | Coverage Δ | |
---|---|---|
src/customType.ts | 100.00% <ø> (ø) |
|
src/fields.ts | 100.00% <ø> (ø) |
|
src/index.ts | 100.00% <ø> (ø) |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update 05c7ea8...3025f5e. Read the comment docs.
+4,462 −55
For once, it's not package-lock.json causing a huge diff. 😅
You're right, it is verbose. Most of the code here is copy/pasted in each file to ensure the same test structure is used. This is something we won't need to touch often since the API is stable.
This is ready to merge if you think the general approach is good. I wanted to check with you @lihbr before merging.
Yup, works like a charm, updated the CI workflow to run those.
Do you think we should get this setup available on the starter? Might encourage us to write a few of those elsewhere?
Types of changes
Description
This PR adds static tests for all public APIs. It uses
ts-expect
in combination with the TypeScript compiler (tsc
) to determine type validity.Tests are structured using the following order:
typeof
check to ensure only permitted primitive types are allowed. For example, we can ensure a type isstring | null
by checking fortypeof value
againststring
andobject
. This verifies that anumber
cannot be passed without needing to manually check all possible types.ts-expect
was selected over other options because:These alternatives were considered:
tsd
is a CLI that runs the TypeScript type checker over assertionsexpect-type
does type checks using a Jest-like APIChecklist:
🎎