Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to spread props at the start #166

Merged
merged 1 commit into from
Sep 15, 2018
Merged

Allow to spread props at the start #166

merged 1 commit into from
Sep 15, 2018

Conversation

TrySound
Copy link
Contributor

@TrySound TrySound commented Sep 7, 2018

The use case is flow which warns about inexact spread. My template looks
like this and I need to spread props before any other prop.

const template = (code, options, state) => `
// @flow
// Generated from ${state.filePath}

import * as React from "react";

type Props = {
  size?: string | number,
  fill?: string
};

const style = {
  display: "block",
  flex: "0 0 auto",
};

export const ${state.componentName} = ({ size, fill, ...props }: Props) => {
  return (
    ${code}
  );
};
`;

The use case is flow which warns about inexact spread. My template looks
like this and I need to spread props before any other prop.

```js
const template = (code, options, state) => `
// @flow
// Generated from ${state.filePath}

import * as React from "react";

type Props = {
  size?: string | number,
  fill?: string
};

const style = {
  display: "block",
  flex: "0 0 auto",
};

export const ${state.componentName} = ({ size, fill, ...props }: Props) => {
  return (
    ${code}
  );
};
`;

```
@codecov
Copy link

codecov bot commented Sep 7, 2018

Codecov Report

Merging #166 into master will increase coverage by 0.15%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #166      +/-   ##
==========================================
+ Coverage   88.73%   88.88%   +0.15%     
==========================================
  Files          26       26              
  Lines         435      441       +6     
  Branches       79       82       +3     
==========================================
+ Hits          386      392       +6     
  Misses         47       47              
  Partials        2        2
Impacted Files Coverage Δ
packages/core/src/h2x/expandProps.js 100% <100%> (ø) ⬆️
packages/core/src/plugins/h2x.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d1ae730...e368f67. Read the comment docs.

@gregberge
Copy link
Owner

I understand the use case, code looks great. Can you update all relative readme please?

@TrySound
Copy link
Contributor Author

TrySound commented Sep 8, 2018

I'm not sure how to make it work with cli. Currently svgr has --no-expand-props option. Should I add --expand-props?

Ideally it should be enum like start | end | none

@TrySound
Copy link
Contributor Author

So how would you like to go?

@gregberge
Copy link
Owner

You are right, so it is OK like that. We have to change it in the next major.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants