@@ -47,11 +47,7 @@ export function createTypings(moduleName: string|null, programAst: any, options:
4747 const tripleSlashDirectives : dom . TripleSlashDirective [ ] = [ ] ;
4848 const m = dom . create . module ( moduleName || 'moduleName' ) ;
4949
50- if ( hasReactClass ( ast , reactComponentName ) ) {
51- m . members . push ( dom . create . importNamed ( reactComponentName || 'Component' , reactImport ) ) ;
52- } else {
53- tripleSlashDirectives . push ( dom . create . tripleSlashReferenceTypesDirective ( 'react' ) ) ;
54- }
50+ m . members . push ( dom . create . importAll ( 'React' , reactImport ) ) ;
5551
5652 if ( importStatements . length > 0 ) {
5753 importStatements . forEach ( importStatement => {
@@ -104,7 +100,7 @@ function createExportedTypes(m: dom.ModuleDeclaration, ast: AstQuery, componentN
104100function createExportedClassComponent ( m : dom . ModuleDeclaration , componentName : string ,
105101 reactComponentName : string | undefined , exportType : dom . DeclarationFlags , interf : dom . InterfaceDeclaration ) : void {
106102 const classDecl = dom . create . class ( componentName ) ;
107- classDecl . baseType = dom . create . interface ( `${ reactComponentName || 'Component' } <${ interf . name } , any>` ) ;
103+ classDecl . baseType = dom . create . interface ( `React. ${ reactComponentName || 'Component' } <${ interf . name } , any>` ) ;
108104 classDecl . flags = exportType ;
109105 classDecl . members . push ( dom . create . method ( 'render' , [ ] , dom . create . namedTypeReference ( 'JSX.Element' ) ) ) ;
110106 m . members . push ( classDecl ) ;
@@ -271,36 +267,6 @@ function getImportedPropTypes(ast: AstQuery): ImportedPropType[] {
271267 } ) ) ;
272268}
273269
274- function hasReactClass ( ast : AstQuery , reactComponentName : string | undefined ) : boolean {
275- const res = ast . query ( `
276- // ClassDeclaration[
277- '${ reactComponentName } ' == 'undefined'
278- ?
279- /:superClass MemberExpression[
280- /:object Identifier[@name == 'React'] &&
281- /:property Identifier[@name == 'Component']
282- ]
283- :
284- /:superClass Identifier[@name == '${ reactComponentName } ']
285- ]
286- ,
287- // VariableDeclaration
288- / VariableDeclarator[
289- /:init CallExpression[
290- '${ reactComponentName } ' == 'undefined'
291- ?
292- /:arguments MemberExpression[
293- /:object Identifier[@name == 'React'] &&
294- /:property Identifier[@name == 'Component']
295- ]
296- :
297- /:arguments Identifier[@name == '${ reactComponentName } ']
298- ]
299- ]
300- ` ) ;
301- return res . length > 0 ;
302- }
303-
304270function getInstanceOfPropTypes ( ast : AstQuery , importedPropTypes : ImportedPropTypes ) : string [ ] {
305271 const { propTypesName, propTypes} = importedPropTypes ;
306272 const instanceOfPropType = propTypes . find ( ( { importedName} ) => importedName === 'instanceOf' ) ;
0 commit comments