Skip to content

Commit

Permalink
fix: only import props type for top-level component
Browse files Browse the repository at this point in the history
  • Loading branch information
alharris-at committed Nov 2, 2021
1 parent 6ab4cdf commit c850b8c
Show file tree
Hide file tree
Showing 7 changed files with 5 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@ Object {
import React from \\"react\\";
import {
Button,
ButtonProps,
EscapeHatchProps,
Flex,
FlexProps,
Heading,
HeadingProps,
findChildOverrides,
getOverrideProps,
} from \\"@aws-amplify/ui-react\\";
Expand Down Expand Up @@ -149,12 +147,10 @@ import React from \\"react\\";
import { User, UserPreferences } from \\"../models\\";
import {
Button,
ButtonProps,
Collection,
CollectionProps,
EscapeHatchProps,
Flex,
FlexProps,
getOverrideProps,
useDataStoreBinding,
} from \\"@aws-amplify/ui-react\\";
Expand Down Expand Up @@ -237,12 +233,10 @@ import React from \\"react\\";
import { User, UserPreferences } from \\"../models\\";
import {
Button,
ButtonProps,
Collection,
CollectionProps,
EscapeHatchProps,
Flex,
FlexProps,
getOverrideProps,
useDataStoreBinding,
} from \\"@aws-amplify/ui-react\\";
Expand Down Expand Up @@ -422,7 +416,6 @@ import {
CollectionProps,
EscapeHatchProps,
ListingCard,
ListingCardProps,
findChildOverrides,
getOverrideProps,
useDataStoreBinding,
Expand Down Expand Up @@ -480,7 +473,6 @@ import {
CollectionProps,
EscapeHatchProps,
ListingCard,
ListingCardProps,
findChildOverrides,
getOverrideProps,
} from \\"@aws-amplify/ui-react\\";
Expand Down Expand Up @@ -519,7 +511,6 @@ exports[`amplify render tests complex component tests should generate a button w
import React from \\"react\\";
import {
Button,
ButtonProps,
EscapeHatchProps,
View,
ViewProps,
Expand Down Expand Up @@ -552,7 +543,6 @@ exports[`amplify render tests complex component tests should generate a componen
import React from \\"react\\";
import {
CustomButton,
CustomButtonProps,
EscapeHatchProps,
View,
ViewProps,
Expand Down Expand Up @@ -586,7 +576,6 @@ exports[`amplify render tests complex component tests should generate a componen
import React from \\"react\\";
import {
Button,
ButtonProps,
EscapeHatchProps,
View,
ViewProps,
Expand Down Expand Up @@ -622,7 +611,6 @@ import {
Flex,
FlexProps,
Text,
TextProps,
getOverrideProps,
} from \\"@aws-amplify/ui-react\\";
Expand Down Expand Up @@ -670,7 +658,6 @@ exports[`amplify render tests complex examples should render complex sample 2 1`
import React from \\"react\\";
import {
Box,
BoxProps,
EscapeHatchProps,
Flex,
FlexProps,
Expand Down Expand Up @@ -741,14 +728,11 @@ exports[`amplify render tests complex examples should render complex sample 3 1`
import React from \\"react\\";
import {
Box,
BoxProps,
EscapeHatchProps,
Flex,
FlexProps,
ReneButton,
ReneButtonProps,
Text,
TextProps,
findChildOverrides,
getOverrideProps,
} from \\"@aws-amplify/ui-react\\";
Expand Down Expand Up @@ -829,7 +813,6 @@ exports[`amplify render tests complex examples should render complex sample 4 1`
import React from \\"react\\";
import {
Box,
BoxProps,
EscapeHatchProps,
Flex,
FlexProps,
Expand Down Expand Up @@ -947,7 +930,6 @@ exports[`amplify render tests complex examples should render complex sample 5 1`
import React from \\"react\\";
import {
Box,
BoxProps,
EscapeHatchProps,
Flex,
FlexProps,
Expand Down Expand Up @@ -1004,7 +986,6 @@ import {
Flex,
FlexProps,
Text,
TextProps,
getOverrideProps,
} from \\"@aws-amplify/ui-react\\";
Expand Down Expand Up @@ -1084,9 +1065,7 @@ import {
BoxProps,
EscapeHatchProps,
Image,
ImageProps,
Text,
TextProps,
findChildOverrides,
getOverrideProps,
} from \\"@aws-amplify/ui-react\\";
Expand Down Expand Up @@ -1157,7 +1136,6 @@ exports[`amplify render tests complex examples should render complex sample 8 1`
import React from \\"react\\";
import {
Box,
BoxProps,
EscapeHatchProps,
Flex,
FlexProps,
Expand Down Expand Up @@ -1308,7 +1286,6 @@ import {
Flex,
FlexProps,
Text,
TextProps,
getOverrideProps,
} from \\"@aws-amplify/ui-react\\";
Expand Down Expand Up @@ -1371,7 +1348,6 @@ import {
ButtonProps,
EscapeHatchProps,
Text,
TextProps,
getOverrideProps,
} from \\"@aws-amplify/ui-react\\";
Expand Down Expand Up @@ -1454,7 +1430,6 @@ import {
ButtonProps,
EscapeHatchProps,
Text,
TextProps,
getOverrideProps,
} from \\"@aws-amplify/ui-react\\";
Expand Down Expand Up @@ -1488,7 +1463,6 @@ import {
ButtonProps,
EscapeHatchProps,
Text,
TextProps,
getOverrideProps,
} from \\"@aws-amplify/ui-react\\";
Expand Down Expand Up @@ -1808,7 +1782,6 @@ import {
CollectionProps,
EscapeHatchProps,
Text,
TextProps,
getOverrideProps,
useDataStoreBinding,
} from \\"@aws-amplify/ui-react\\";
Expand Down Expand Up @@ -1928,7 +1901,6 @@ exports[`amplify render tests sample code snippet tests should generate a sample
import React from \\"react\\";
import {
CustomButton,
CustomButtonProps,
EscapeHatchProps,
View,
ViewProps,
Expand Down Expand Up @@ -1964,12 +1936,10 @@ Object {
import React from \\"react\\";
import {
Button,
ButtonProps,
EscapeHatchProps,
Flex,
FlexProps,
Heading,
HeadingProps,
findChildOverrides,
getOverrideProps,
} from \\"@aws-amplify/ui-react\\";
Expand Down Expand Up @@ -2047,7 +2017,6 @@ import React from \\"react\\";
import {
EscapeHatchProps,
Input,
InputProps,
View,
ViewProps,
findChildOverrides,
Expand Down Expand Up @@ -2225,12 +2194,10 @@ exports[`amplify render tests user specific attributes should render user specif
import React from \\"react\\";
import {
Button,
ButtonProps,
EscapeHatchProps,
Flex,
FlexProps,
Image,
ImageProps,
getOverrideProps,
} from \\"@aws-amplify/ui-react\\";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export default class CollectionRenderer extends ReactComponentWithChildrenRender
);

this.importCollection.addImport('@aws-amplify/ui-react', this.component.componentType);
this.importCollection.addImport('@aws-amplify/ui-react', `${this.component.componentType}Props`);

return element;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export default class CustomComponentRenderer extends ReactComponentWithChildrenR
);

this.importCollection.addImport('@aws-amplify/ui-react', this.component.componentType);
this.importCollection.addImport('@aws-amplify/ui-react', `${this.component.componentType}Props`);

return element;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export default class TextRenderer extends ReactComponentRenderer<TextProps> {
);

this.importCollection.addImport('@aws-amplify/ui-react', this.component.componentType);
this.importCollection.addImport('@aws-amplify/ui-react', `${this.component.componentType}Props`);

return element;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export class ReactComponentRenderer<TPropIn> extends ComponentRendererBase<TProp
);

this.importCollection.addImport('@aws-amplify/ui-react', this.component.componentType);
this.importCollection.addImport('@aws-amplify/ui-react', `${this.component.componentType}Props`);

return element;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ export class ReactComponentWithChildrenRenderer<TPropIn> extends ComponentWithCh
);

this.importCollection.addImport('@aws-amplify/ui-react', this.component.componentType);
this.importCollection.addImport('@aws-amplify/ui-react', `${this.component.componentType}Props`);

return element;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,10 +311,13 @@ export abstract class ReactStudioTemplateRenderer extends StudioTemplateRenderer
return undefined;
}

const propsType = `${component.componentType}Props`;

this.importCollection.addImport('@aws-amplify/ui-react', propsType);

const parameterizedPrimitivePropType = this.getParameterizedPrimitivePropType(component);
const primitivePropType =
parameterizedPrimitivePropType ||
factory.createTypeReferenceNode(factory.createIdentifier(`${component.componentType}Props`), undefined);
parameterizedPrimitivePropType || factory.createTypeReferenceNode(factory.createIdentifier(propsType), undefined);

return factory.createTypeReferenceNode(factory.createIdentifier('Partial'), [primitivePropType]);
}
Expand Down

0 comments on commit c850b8c

Please sign in to comment.