support for TypeScript dependencies

This commit is contained in:
Alan Hamlett 2018-03-11 13:40:48 -07:00
parent a212d48c57
commit 799fe92c21
4 changed files with 61 additions and 2 deletions

View file

@ -0,0 +1,37 @@
import Alpha from './bravo'
import { charlie, delta } from '../../echo/foxtrot'
import golf from './hotel/india.js'
import juliett from 'kilo'
import {
lima,
mike,
} from './november'
import * from '/modules/oscar'
import * as papa from 'quebec'
import {romeo as sierra} from from 'tango.jsx'
import 'uniform.js'
import victorDefault, * as victorModule from '/modules/victor.js'
import whiskeyDefault, {whiskeyOne, whiskeyTwo} from 'whiskey'
const propTypes = {}
const defaultProps = {}
class Link extends Alpha.Component {
static method() {
return true
}
render() {
return (
<a href={this.props.url} data-id={this.props.id}>
{this.props.text}
</a>
)
}
}
Link.propTypes = propTypes
Link.defaultProps = defaultProps
export default Link

View file

@ -377,3 +377,23 @@ class DependenciesTestCase(TestCase):
expected_lines=37,
entity='es6.js',
)
def test_typescript_dependencies_detected(self):
self.shared(
expected_dependencies=[
'bravo',
'foxtrot',
'india',
'kilo',
'november',
'oscar',
'quebec',
'tango',
'uniform',
'victor',
'whiskey',
],
expected_language='TypeScript',
expected_lines=37,
entity='typescript.ts',
)

View file

@ -123,8 +123,6 @@ class DependencyParser(object):
@property
def root_lexer(self):
if not self.lexer:
return None
if hasattr(self.lexer, 'root_lexer'):
return self.lexer.root_lexer
return self.lexer

View file

@ -54,3 +54,7 @@ class JavascriptParser(TokenParser):
content = content.split('/')[-1].split('\\')[-1]
content = self.extension.sub('', content, count=1)
return content
class TypeScriptParser(JavascriptParser):
pass