This repository has been archived by the owner on Mar 25, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 885
Conversation
This file contains 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
adidahiya
approved these changes
Oct 20, 2017
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
overall looks good, feel free to merge after fixing minor comments
src/rules/noUnsafeAnyRule.ts
Outdated
sourceFile.statements.forEach(this.noCheck); | ||
} | ||
|
||
private noCheck = (node: ts.Node) => void this.visitNode(node); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this method name is a little unintuitive; can you make it more verbose and add a comment explaining its usage?
src/rules/noUnsafeAnyRule.ts
Outdated
/** OK for this value to be 'any' if that's its contextual type. */ | ||
function checkContextual(arg: ts.Expression): void { | ||
return cb(arg, /*anyOk*/ isAny(checker.getContextualType(arg))); | ||
private checkContextual(node: ts.Expression, allowIfNoContextualType?: boolean) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor: would prefer the verbosity of naming this checkContextualType
adidahiya
approved these changes
Oct 20, 2017
HyphnKnight
pushed a commit
to HyphnKnight/tslint
that referenced
this pull request
Apr 9, 2018
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
PR checklist
Overview of change:
any
, e.g.function foo({a, b}: any){}
yield
expressions.export = x
andexport default x
any
in certain locations when there is no contextual type, e.g.declare let x: any; let obj = {x};
or() => x
.x
ofx.y
is of typeany
and we also reported that error, we don't add another forx.y
,x.y.z
orx.y()
, etc.Is there anything you'd like reviewers to focus on?
CHANGELOG.md entry:
[enhancement]
no-unsafe-any
checks more expressions, for example destructuring,yield
, property initializer