Skip to content

Commit 3ac8f9a

Browse files
author
Yann VR
committed
feat(ts) support for typescript
1 parent 82ab0f3 commit 3ac8f9a

File tree

6 files changed

+7
-16
lines changed

6 files changed

+7
-16
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.idea
2+
.history
23
node_modules/
34
*~

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
"Automate every single boring and repetitive tasks" -- DevOps Handbook
44

55
Create a styled component with test (Jest ready) including optionals story and style
6-
component
6+
component. Supports Typescript.
77

8-
Create components based on the following structure:
8+
Create components based on the following structure (example given in js)
99
- `src/components/new-component/index.jsx`
1010
- `src/components/new-component/test.jsx`
1111
- `src/components/new-component/story.js` (optional)
@@ -43,7 +43,6 @@ will create a function component `<FunctionComponent />` in `src/component/profi
4343
![screen recording](http://g.recordit.co/XMuQeSSrgy.gif)
4444
4545
### TODO
46-
- Handle typescript
4746
- Cypress template
4847
4948
Note: the template can generate unstyled component but you'll just have to remove styled component references.

plop-templates/ts/component.function-component.hbs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import React from 'react'
1+
import React, { FunctionComponent } from 'react'
22
import { Styled{{name}} } from './style'
3-
import PropTypes from 'prop-types'
43

54
export interface {{name}}Props {
65

@@ -10,7 +9,7 @@ export interface {{name}}State {
109

1110
}
1211

13-
const {{name}}:React.FunctionComponent<Props, State> = () => {
12+
const {{name}}:FunctionComponent<{{name}}Props, {{name}}State> = () => {
1413

1514
return (
1615
<Styled{{name}}>

plop-templates/ts/component.pure-component.hbs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,4 @@ class {{name}} extends PureComponent:React.PureComponent<Props, State> {
2727
}
2828
}
2929

30-
{{name}}.defaultProps = {
31-
32-
}
33-
34-
{{name}}.propTypes = {
35-
36-
}
37-
3830
export default {{name}}

plop-templates/ts/test.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react'
22
import 'jest-styled-components'
33
import renderer from 'react-test-renderer'
44
import JssProvider from 'react-jss/lib/JssProvider'
5-
import {{name}}Props from './{{name}}'
5+
import { {{name}}Props } from './{{name}}'
66
import {{ name }} from './index'
77

88
// Avoids inconsistent class names between snapshots

plopfile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ module.exports = function(plop) {
6161
},
6262

6363
{
64-
type: 'typescript',
64+
type: 'confirm',
6565
name: 'ts',
6666
message: 'Typescript?',
6767
default: false,

0 commit comments

Comments
 (0)