Skip to content
This repository has been archived by the owner on Sep 21, 2019. It is now read-only.

Commit

Permalink
replace helpers.isKind with ts.isXXX
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentbel committed Jan 20, 2018
1 parent eaa518d commit 046857a
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 1,217 deletions.
11 changes: 4 additions & 7 deletions src/helpers/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import * as ts from 'typescript';
import { find, indexOf, slice } from 'lodash';
import * as kinds from './isKind';

export * from './isKind';

/**
* If a class declaration a react class?
Expand Down Expand Up @@ -55,7 +52,7 @@ export function isReactComponent(classDeclaration: ts.ClassDeclaration, typeChec
export function isReactHeritageClause(clause: ts.HeritageClause) {
return clause.token === ts.SyntaxKind.ExtendsKeyword &&
clause.types.length === 1 &&
kinds.isExpressionWithTypeArguments(clause.types[0]) &&
ts.isExpressionWithTypeArguments(clause.types[0]) &&
/Component/.test(clause.types[0].expression.getText());
}

Expand All @@ -66,10 +63,10 @@ export function isReactHeritageClause(clause: ts.HeritageClause) {
* @param statement
*/
export function isReactPropTypeAssignmentStatement(statement: ts.Statement): statement is ts.ExpressionStatement {
return kinds.isExpressionStatement(statement)
&& kinds.isBinaryExpression(statement.expression)
return ts.isExpressionStatement(statement)
&& ts.isBinaryExpression(statement.expression)
&& statement.expression.operatorToken.kind === ts.SyntaxKind.FirstAssignment
&& kinds.isPropertyAccessExpression(statement.expression.left)
&& ts.isPropertyAccessExpression(statement.expression.left)
&& /\.propTypes$|\.propTypes\..+$/.test(statement.expression.left.getText())
}

Expand Down
Loading

0 comments on commit 046857a

Please sign in to comment.