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.
This PR adds the source of axios to the user tests. I'm tracking the amount of work that would be needed to add a tsconfig to these projects with checkJs turned on. We already have axios' npm install in the user tests under
axios/
, since it's a popular package that ships a d.ts — we want to avoid breaking users of the package.I skipped checking everything except lib: dist, examples, test and sandbox.
Errors
We don't let you import package.json.
url.parse returns a UrlObjectCommon, whose fields are all optional. Doesn't seem like anybody remembers to check for undefined, though. The documentation doesn't mention it either.
JSDoc optionality only adds undefined to the type, not null. So passing
null
isn't allowed.Assigning a value of a different type to a variable isn't allowed without declaring the variable as a union.
We don't even allow you to check
window.XDomainRequest
for existence. Maybewindow
should have a string indexer. Would be fixed by Bind toplevel this assignments as global declarations #22891 ifwindow: global & Window
.We don't understand that
util.extend
adds properties to its argument via assignment.We don't recognise variables initialised with call expressions as namespaces (In JS, any declaration with a non-primitive initializer should be a JS container #22637).
We don't understand aliasing of
this
and subsequent assignments as adding instance properties.We don't treat parameters as namespaces that can be special-assigned to. See (7).
undefined << 8
is not allowed even though it's well-defined.Prototype assignment followed by prototype property assignment doesn't allow addition of prototype properties (In JS, function declarations should allow subsequent prototype assignment #23007).
We expect jsdoc for
arguments
to be an array type, but the author of merge in utils.js thought of it as the type of "the first parameter" and gives a scalar type.(unrelated to this PR) axios.d.ts uses
export default
even though code in sandbox usesvar axios = require('../index')
Note that I just saw (1, 2) in create-react-app too.
Result
This result is not great. There aren't a lot of errors, but none of them are really useful, and 6 of 12 are a failure to understand complex aliasing of declarations. Most of those aliases would require a fundamental overhaul of Javascript binding since the aliasing assignments would have to be understood first, and then property-assignment-as-declaration understood second.