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

Introduce TypeScript support into the dev & build systems #1317

Merged
merged 64 commits into from
Nov 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
b8a1600
initial setup for TS in codebase
chandlerprall Aug 3, 2018
146f5a4
Running TypeScript in jest tests
chandlerprall Aug 6, 2018
5587db5
use ts-jest 23.1.4 for json5 babelrc support
chandlerprall Aug 27, 2018
5070e43
include typescript sources and declarations in output to lib
chandlerprall Sep 25, 2018
aa7df95
ts defs to proptypes
chandlerprall Sep 27, 2018
e22bc4a
ts-to-proptype conversion interacting with react-docgen
chandlerprall Sep 27, 2018
3a1f96b
Convert Array<> types to prop types
chandlerprall Oct 1, 2018
f1091be
Refactor how required/optional types are passed
chandlerprall Oct 1, 2018
a74601c
Array tests, understand object/shape types
chandlerprall Oct 1, 2018
993fd77
Fixed bug in Array type support, added full support for union types
chandlerprall Oct 1, 2018
1827d91
Understands intersections, unknown types resolve to PropTypes.any
chandlerprall Oct 4, 2018
9e4465f
Correctly resolving typescript type imports through files
chandlerprall Oct 5, 2018
2ca8b35
Support typescript conversion to element and node prop types
chandlerprall Oct 10, 2018
4a59927
Clean up some bugs
chandlerprall Oct 10, 2018
1014e39
compile type declarations into types/ directory
chandlerprall Oct 15, 2018
752404f
iteration
chandlerprall Oct 25, 2018
0d30a28
iteration
chandlerprall Oct 26, 2018
f946ebd
property merging generated and written defs
chandlerprall Oct 30, 2018
85bf071
Merge branch 'master' into feature/typescript
chandlerprall Oct 30, 2018
fd14ec6
updated yarn.lock
chandlerprall Oct 30, 2018
37d916f
don't generate ts defs when linting
chandlerprall Oct 30, 2018
b9d6d34
Default TS typechecking to not emit files
chandlerprall Nov 1, 2018
1afefec
Merge branch 'master' into feature/typescript
chandlerprall Nov 1, 2018
03f67dd
clean up and fix a lot of TS issues
chandlerprall Nov 1, 2018
4911617
better TS import resolving
chandlerprall Nov 1, 2018
9a57a05
point types at eui.d.ts
chandlerprall Nov 1, 2018
f584b40
Merge branch 'master' into feature/typescript
chandlerprall Nov 8, 2018
aee2549
get passing tests
chandlerprall Nov 8, 2018
4c014db
fixed ts issues
chandlerprall Nov 8, 2018
f5537b0
typescript support via babel
chandlerprall Nov 8, 2018
1ff73ec
remove ts-jest
chandlerprall Nov 8, 2018
0d5ec5c
progress on the babel plugin
chandlerprall Nov 8, 2018
bda6ab4
majority of babel ts->proptype plugin functioning
chandlerprall Nov 9, 2018
6d70023
typescript defs to proptype babel plugin passing all test
chandlerprall Nov 9, 2018
f4a867d
babel plugin for ts->proptypes is working
chandlerprall Nov 12, 2018
d883a41
Merge branch 'master' into feature/typescript
chandlerprall Nov 12, 2018
6972bce
small cleanup
chandlerprall Nov 12, 2018
a91cc24
small cleanup
chandlerprall Nov 12, 2018
8b4203b
Merge branch 'master' into feature/typescript
chandlerprall Nov 15, 2018
f0adf02
fix test runner
chandlerprall Nov 16, 2018
b48e4fa
update spacer test file to tsx
chandlerprall Nov 16, 2018
83d94f1
typescript -> proptypes now understands shorthand array type syntax
chandlerprall Nov 16, 2018
7715509
clean up ts->proptypes script
chandlerprall Nov 16, 2018
22667f5
convert spacer example doc to tsx
chandlerprall Nov 16, 2018
5d65a2d
ts build cleanup
chandlerprall Nov 16, 2018
7945d78
Merge branch 'master' into feature/typescript
chandlerprall Nov 16, 2018
ec62844
don't need to ignore the types dir 3 times
chandlerprall Nov 16, 2018
2e67e5f
dtsgenerator is not a distributed dependency
chandlerprall Nov 16, 2018
8af0911
validate typescript code during build
chandlerprall Nov 16, 2018
9c313ec
small cleanup
chandlerprall Nov 16, 2018
1eed3cb
support ts enums in proptype generation
chandlerprall Nov 19, 2018
a0a35d7
PR feedback
chandlerprall Nov 19, 2018
c8f6eb2
Added more comments to the typescript->proptype babel plugin; fixed b…
chandlerprall Nov 21, 2018
dcd95ad
Add support for 'keyof typeof [object expression]'
chandlerprall Nov 26, 2018
c939146
horizontal rule conversion to ts
snide Nov 28, 2018
1ccff65
Update src/components/horizontal_rule/horizontal_rule.tsx
chandlerprall Nov 28, 2018
1f848de
feedback
snide Nov 28, 2018
fa50bc5
feedback
snide Nov 28, 2018
c04bd73
Updated yeoman templates for typescript
chandlerprall Nov 29, 2018
f4b81b5
Update docs code gen to point at @elastic/eui more often
chandlerprall Nov 29, 2018
d92fb51
Update yeoman generator for docs
chandlerprall Nov 29, 2018
63c1d53
don't require 'public' keyword on public class methods
chandlerprall Nov 30, 2018
1a1b88a
Merge branch 'master' into feature/typescript
chandlerprall Nov 30, 2018
b2085ca
changelog
chandlerprall Nov 30, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .babelrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ module.exports = {
"useBuiltIns": "usage",
"modules": process.env.BABEL_MODULES ? process.env.BABEL_MODULES : "commonjs" // babel's default is commonjs
}],
"@babel/typescript",
"@babel/react"
],
"plugins": [
"pegjs-inline-precompile",
"./scripts/babel/proptypes-from-ts-props",
"add-module-exports",
[
"react-docgen",
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ tmp/
dist/
lib/
es/
types/
.idea
.vscode/
.DS_Store
Expand All @@ -19,3 +18,7 @@ types/
npm-debug.log
yarn-error.log
eui.d.ts

# typescript output
types/
eui.d.ts
4 changes: 3 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ tmp/
wiki/
generator-eui/
test/
types/
src-docs/
src-framer/
.nvmrc

# typescript output
types/

# ignore everything in `scripts` except postinstall.js
scripts/!(postinstall.js)

Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## [`master`](https://github.com/elastic/eui/tree/master)

No public interface changes since `5.2.0`.
- Introduced TypeScript support, converted `EuiSpacer` and `EuiHorizontalRule` ([#1317](https://github.com/elastic/eui/pull/1317))

## [`5.2.0`](https://github.com/elastic/eui/tree/v5.2.0)

Expand Down
19 changes: 9 additions & 10 deletions generator-eui/component/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ module.exports = class extends Generator {
const vars = config.vars = {
componentName,
cssClassName,
fileName,
fileName: fileName.replace('.ts', ''),
};

const componentPath = config.componentPath = `${path}/${fileName}.js`;
const testPath = config.testPath = `${path}/${fileName}.test.js`;
const componentPath = config.componentPath = `${path}/${fileName}.tsx`;
const testPath = config.testPath = `${path}/${fileName}.test.tsx`;
const stylesPath = config.stylesPath = `${path}/_${fileName}.scss`;
config.stylesImportPath = `./_${fileName}.scss`;

Expand All @@ -66,24 +66,24 @@ module.exports = class extends Generator {
);

this.fs.copyTpl(
this.templatePath('index.js'),
this.destinationPath(`${path}/index.js`),
this.templatePath('index.ts'),
this.destinationPath(`${path}/index.ts`),
vars
);
}

// Create component file.
this.fs.copyTpl(
isStatelessFunction ?
this.templatePath('stateless_function.js') :
this.templatePath('component.js'),
this.templatePath('stateless_function.tsx') :
this.templatePath('component.tsx'),
this.destinationPath(componentPath),
vars
);

// Create component test file.
this.fs.copyTpl(
this.templatePath('test.js'),
this.templatePath('test.tsx'),
this.destinationPath(testPath),
vars
);
Expand All @@ -110,9 +110,8 @@ module.exports = class extends Generator {
end() {
const showImportComponentSnippet = () => {
const componentName = this.config.vars.componentName;
const componentPath = this.config.componentPath;

this.log(chalk.white(`\n// Export component (e.. from component's index.js).`));
this.log(chalk.white(`\n// Export component (e.. from component's index.ts).`));
this.log(
`${chalk.magenta('export')} {\n` +
` ${componentName},\n` +
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import React, {
Component,
HTMLAttributes,
} from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import { CommonProps } from '../common';

export class <%= componentName %> extends Component {
static propTypes = {
children: PropTypes.node,
className: PropTypes.string,
}
export type <%= componentName %>Props = HTMLAttributes<HTMLDivElement> & CommonProps & {

};

constructor(props) {
export class <%= componentName %> extends Component<<%= componentName %>Props> {
constructor(props: <%= componentName %>Props) {
super(props);
}

render() {
const {
children,
className,
...rest,
...rest
} = this.props;

const classes = classNames(
Expand Down
25 changes: 0 additions & 25 deletions generator-eui/component/templates/stateless_function.js

This file was deleted.

24 changes: 24 additions & 0 deletions generator-eui/component/templates/stateless_function.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React, { HTMLAttributes, SFC } from 'react';
import { CommonProps } from '../common';
import classNames from 'classnames';

export type <%= componentName %>Props = HTMLAttributes<HTMLDivElement> & CommonProps & {

};

export const <%= componentName %>: React.SFC<<%= componentName %>Props> = ({
children,
className,
...rest
}) => {
const classes = classNames('<%= cssClassName %>', className);

return (
<div
className={classes}
{...rest}
>
{children}
</div>
);
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { render } from 'enzyme';
import { requiredProps } from '../../test';
import { requiredProps } from '../../test/required_props';

import { <%= componentName %> } from './<%= fileName %>';

Expand Down
4 changes: 2 additions & 2 deletions generator-eui/documentation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ module.exports = class extends Generator {

const documentationPageDemoPath
= config.documentationPageDemoPath
= `${path}/${folderName}/${fileName}.js`;
= `${path}/${folderName}/${fileName}.tsx`;

this.fs.copyTpl(
this.templatePath('documentation_page_demo.js'),
this.templatePath('documentation_page_demo.tsx'),
this.destinationPath(documentationPageDemoPath),
vars
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';

import {
<%= componentName %>,
} from '../../../../src/components';
} from '../../../../src/components/<%= fileName %>';

export default () => (
<<%= componentName %>>
Expand Down
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"lint-es-fix": "eslint --fix --cache --ignore-pattern \"**/*.snap.js\" \"src/**/*.js\" \"src-docs/**/*.js\"",
"lint-sass": "sass-lint -v --max-warnings 0",
"lint-sass-fix": "sass-lint-auto-fix -c ./.sass-lint-fix.yml",
"lint-ts": "tslint -c ./tslint.yaml -p ./tsconfig.json && tsc -p ./tsconfig.json",
"lint-ts": "tslint -c ./tslint.yaml -p ./tsconfig.json && tsc -p ./tsconfig.json --noEmit",
"lint-ts-fix": "tslint -c ./tslint.yaml -p ./tsconfig.json --fix",
"lint-framer": "tslint -c ./tslint.yaml -p ./src-framer/tsconfig.json",
"lint-framer-fix": "tslint -c ./tslint.yaml -p ./src-framer/tsconfig.json --fix",
Expand Down Expand Up @@ -68,8 +68,12 @@
"@babel/polyfill": "^7.0.0",
"@babel/preset-env": "^7.1.0",
"@babel/preset-react": "^7.0.0",
"@babel/preset-typescript": "^7.1.0",
"@elastic/eslint-config-kibana": "^0.15.0",
"@types/classnames": "^2.2.6",
"@types/enzyme": "^3.1.13",
"@types/jest": "^23.3.9",
"@types/lodash": "^4.14.116",
"@types/react": "^16.0.31",
"@types/react-virtualized": "^9.18.6",
"autoprefixer": "^7.1.5",
Expand All @@ -81,6 +85,7 @@
"babel-plugin-inline-react-svg": "^1.0.1",
"babel-plugin-pegjs-inline-precompile": "^0.1.0",
"babel-plugin-react-docgen": "^2.0.0",
"babel-template": "^6.26.0",
"chai": "^4.1.2",
"chai-webdriverio": "^0.4.3",
"chalk": "^2.4.1",
Expand All @@ -105,6 +110,7 @@
"eslint-plugin-prettier": "^2.6.0",
"eslint-plugin-react": "^7.4.0",
"file-loader": "^1.1.11",
"fork-ts-checker-webpack-plugin": "^0.4.4",
"geckodriver": "^1.11.0",
"glob": "^7.1.2",
"html-webpack-plugin": "^3.2.0",
Expand Down
Loading