diff --git a/package.json b/package.json index 8565c902e74..5a89b8f943c 100644 --- a/package.json +++ b/package.json @@ -44,6 +44,7 @@ "commander": "^2.19.0", "doctrine": "^3.0.0", "node-dir": "^0.1.10", + "resolve": "^1.10.1", "strip-indent": "^3.0.0" }, "devDependencies": { @@ -79,5 +80,8 @@ "src" ], "testRegex": "/__tests__/.*-test\\.js$" + }, + "browser": { + "./dist/utils/resolveImportedValue.js": "./dist/utils/resolveImportedValue.browser.js" } } diff --git a/src/__tests__/__snapshots__/main-test.js.snap b/src/__tests__/__snapshots__/main-test.js.snap index 66bb69a47b6..2eb6471286a 100644 --- a/src/__tests__/__snapshots__/main-test.js.snap +++ b/src/__tests__/__snapshots__/main-test.js.snap @@ -1446,3 +1446,213 @@ Object { }, } `; + +exports[`main fixtures processes component "component_29.tsx" without errors 1`] = ` +Object { + "description": "This is a typescript component with imported prop types", + "displayName": "ImportedExtendedComponent", + "methods": Array [], +} +`; + +exports[`main fixtures processes component "component_30.js" without errors 1`] = ` +Object { + "description": "", + "displayName": "CustomButton", + "methods": Array [], + "props": Object { + "children": Object { + "description": "", + "required": true, + "type": Object { + "name": "string", + }, + }, + "color": Object { + "description": "", + "required": false, + "type": Object { + "name": "string", + }, + }, + "onClick": Object { + "description": "", + "required": false, + "type": Object { + "name": "func", + }, + }, + "style": Object { + "description": "", + "required": false, + "type": Object { + "name": "object", + }, + }, + }, +} +`; + +exports[`main fixtures processes component "component_31.js" without errors 1`] = ` +Object { + "description": "", + "displayName": "SuperCustomButton", + "methods": Array [], + "props": Object { + "children": Object { + "description": "", + "required": true, + "type": Object { + "name": "string", + }, + }, + "onClick": Object { + "description": "", + "required": false, + "type": Object { + "name": "func", + }, + }, + "style": Object { + "description": "", + "required": false, + "type": Object { + "name": "object", + }, + }, + }, +} +`; + +exports[`main fixtures processes component "component_32.js" without errors 1`] = ` +Object { + "description": "", + "displayName": "SuperDuperCustomButton", + "methods": Array [], + "props": Object { + "children": Object { + "description": "", + "required": true, + "type": Object { + "name": "string", + }, + }, + "onClick": Object { + "description": "", + "required": false, + "type": Object { + "name": "func", + }, + }, + "style": Object { + "description": "", + "required": false, + "type": Object { + "name": "object", + }, + }, + }, +} +`; + +exports[`main fixtures processes component "component_33.js" without errors 1`] = ` +Object { + "description": "", + "displayName": "SuperDuperCustomButton", + "methods": Array [], + "props": Object { + "children": Object { + "description": "", + "required": true, + "type": Object { + "name": "string", + }, + }, + "onClick": Object { + "description": "", + "required": false, + "type": Object { + "name": "func", + }, + }, + "style": Object { + "description": "", + "required": false, + "type": Object { + "name": "object", + }, + }, + }, +} +`; + +exports[`main fixtures processes component "component_34.js" without errors 1`] = ` +Object { + "description": "", + "displayName": "SuperDuperCustomButton", + "methods": Array [], + "props": Object { + "children": Object { + "description": "", + "required": true, + "type": Object { + "name": "string", + }, + }, + "onClick": Object { + "description": "", + "required": false, + "type": Object { + "name": "func", + }, + }, + "style": Object { + "description": "", + "required": false, + "type": Object { + "name": "object", + }, + }, + }, +} +`; + +exports[`main fixtures processes component "component_35.tsx" without errors 1`] = ` +Object { + "description": "This is a typescript component with imported prop types", + "displayName": "ImportedComponent", + "methods": Array [], + "props": Object { + "foo": Object { + "description": "", + "required": true, + "tsType": Object { + "name": "string", + }, + }, + }, +} +`; + +exports[`main fixtures processes component "component_36.js" without errors 1`] = ` +Object { + "description": "", + "displayName": "SuperDuperCustomButton", + "methods": Array [], + "props": Object { + "size": Object { + "defaultValue": Object { + "computed": true, + "value": "Sizes.EXTRA_LARGE", + }, + "description": "", + "required": false, + "type": Object { + "computed": true, + "name": "enum", + "value": "Object.values(Sizes)", + }, + }, + }, +} +`; diff --git a/src/__tests__/fixtures/component_27.tsx b/src/__tests__/fixtures/component_27.tsx index 9cd7c4187ae..b7c84d7dfb5 100644 --- a/src/__tests__/fixtures/component_27.tsx +++ b/src/__tests__/fixtures/component_27.tsx @@ -8,7 +8,7 @@ import React, { Component } from 'react'; -interface Props { +export interface Props { foo: string } diff --git a/src/__tests__/fixtures/component_29.tsx b/src/__tests__/fixtures/component_29.tsx new file mode 100644 index 00000000000..b0c7b95432a --- /dev/null +++ b/src/__tests__/fixtures/component_29.tsx @@ -0,0 +1,17 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + */ + +import React, { Component } from 'react'; +import ExtendedProps from './component_28'; + +/** + * This is a typescript component with imported prop types + */ +export function ImportedExtendedComponent(props: ExtendedProps) { + return

Hello world

; +} diff --git a/src/__tests__/fixtures/component_30.js b/src/__tests__/fixtures/component_30.js new file mode 100644 index 00000000000..4b227a5bc62 --- /dev/null +++ b/src/__tests__/fixtures/component_30.js @@ -0,0 +1,13 @@ +import Button from './component_6'; +import PropTypes from 'prop-types'; + +export function CustomButton({color, ...otherProps}) { + return