From 433b9ccbc6469740db129668e53becec581c378a Mon Sep 17 00:00:00 2001 From: Andrew MacLeay Date: Mon, 18 Jun 2018 13:01:07 -0400 Subject: [PATCH] Add failing test for synthetic default Adds a new test file which imports `React` with a synthetic default: ``` import React from 'react'; ``` instead of ``` import * as React from 'react'; ``` This should be fine using the compiler option allowSyntheticDefaultImports; however it induces a test failure. --- .../data/SyntheticDefaultComponent.tsx | 17 +++++++++++++++++ src/__tests__/parser.ts | 8 ++++++++ 2 files changed, 25 insertions(+) create mode 100644 src/__tests__/data/SyntheticDefaultComponent.tsx diff --git a/src/__tests__/data/SyntheticDefaultComponent.tsx b/src/__tests__/data/SyntheticDefaultComponent.tsx new file mode 100644 index 00000000..b22cd32c --- /dev/null +++ b/src/__tests__/data/SyntheticDefaultComponent.tsx @@ -0,0 +1,17 @@ +import React from 'react'; + +export interface Props { + /** prop1 description */ + prop1: boolean; + /** prop2 description */ + prop2: string; +} + +/** + * SyntheticDefaultComponent description + */ +export default class SimpleComponent extends React.Component { + render() { + return
{this.props.prop1 && this.props.prop2}
; + } +} diff --git a/src/__tests__/parser.ts b/src/__tests__/parser.ts index 300a8347..f9cc02da 100644 --- a/src/__tests__/parser.ts +++ b/src/__tests__/parser.ts @@ -6,6 +6,14 @@ import { check, checkComponent, fixturePath } from './testUtils'; describe('parser', () => { const children = { type: 'ReactNode', required: false, description: '' }; + it('should parse a react class component using synthetic default export', () => { + check('SyntheticDefaultComponent', { + SyntheticDefaultComponent: { + prop1: { type: 'boolean' }, + prop2: { type: 'string' } + } + }); + }); it('should parse simple react class component', () => { check('Column', { Column: {