Convert the utilities package to typescript.#750
Open
martinfrances107 wants to merge 10 commits into
Open
Conversation
…alls to [].includes .. must support new es7 syntax.
…: now we are using es7 we can use private keyword, and undo variable name change.
…intrc.json which copies over some preferences from existing eslint rules.
…d artifact. Removed errors associateted with appending to the Headers object. Reverted some indentation changes that are out of scope.
Contributor
Author
|
Now the tests are passing .. here is my todo list a) I think tslint is deprecated. - I think I could refactor so that eslint could be used to work with typescript |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The intention here is to convert the utilities package into typescript.
packages/utilities/src/api.ts is a good candidate for conversion, it is central point to contact for all interaction with the back-end. So I want the parameters to the fetch call - strongly typed, semantically clean and free of any idiosyncrasies which will lead to bugs or exploits.
a) I have use foundational types like 'RequestInit' and 'response' to lock things down. Until fixed what the linting errors showed was that we were misusing an object, passing in unexpected parameters and expecting it to be available once the object was returned. In the code look for the new variable 'isResponseText' for the alteration.
b) This line below forced the use of es7 transpilers. In other places I introduced a private class methods which are only valid in es7 [ see error.ts ]
if (![200, 201, 204].includes(res.status)c) For *.ts files the webpack loaders have been chained together so that all the targeted browser constraints still apply.
d) As a discussion point this increases the size of the build, the output from
npm run build [ in the packages/utilities directory] from 16.3KiB to 19.5Kib ( 20% increase )
I think this is small in absolute numbers, but no summary would be complete without mentioning it.
Anyway I hope this is seen as a good change.
There is a discussion to be had about the use of "d.ts" files.. If any reviewer want to ask for changes I will be very flexible and be happy to change my approach.