Skip to content

Commit

Permalink
fix(typescript): fix ts build can not transplie jsx
Browse files Browse the repository at this point in the history
  • Loading branch information
janryWang committed Jul 15, 2019
1 parent 24956f7 commit 0dfcba7
Show file tree
Hide file tree
Showing 13 changed files with 146 additions and 10 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ node_modules/
examples/test
.idea/
.vscode/
TODO.md
TODO.md
tsconfig.tsbuildinfo
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"scripts": {
"bootstrap": "lerna bootstrap",
"clean": "lerna clean",
"build": "node ./scripts/build.js",
"build": "node ./scripts/build.js && npm run build:ts",
"build:ts": "tsc -b packages/react packages/core packages/antd packages/validator packages/utils packages/types",
"build:docs": "node ./scripts/docs.js build -i docs -o docs",
"start": "node ./scripts/docs.js start -i docs",
"sort-api": "node ./scripts/sort-api-table.js",
Expand Down Expand Up @@ -124,4 +125,4 @@
"type": "opencollective",
"url": "https://opencollective.com/uform"
}
}
}
8 changes: 4 additions & 4 deletions packages/antd/src/fields/cards.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Fragment } from 'react'
import React, { Fragment, ReactElement } from 'react'
import styled from 'styled-components'
import { registerFormField } from '@uform/react'
import { Card } from 'antd'
Expand All @@ -18,14 +18,14 @@ const FormCardsField = styled(
)
}

public renderEmpty = title => {
public renderCardEmpty = (title: string | ReactElement) => {
return (
<Card
style={this.getProps('style')}
title={title}
className="card-list"
>
{super.renderEmpty()}
{this.renderEmpty()}
</Card>
)
}
Expand Down Expand Up @@ -68,7 +68,7 @@ const FormCardsField = styled(
</Card>
)
})}
{value.length === 0 && this.renderEmpty(title)}
{value.length === 0 && this.renderCardEmpty(title)}
<div className="addition-wrapper">
{value.length > 0 && this.renderAddition()}
</div>
Expand Down
24 changes: 24 additions & 0 deletions packages/antd/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"extends": "../tsconfig.settings.json",
"compilerOptions": {
"rootDir": "src",
"outDir": "lib"
},
"references": [
{
"path": "../react"
},
{
"path": "../core"
},
{
"path": "../utils"
},
{
"path": "../validator"
},
{
"path": "../types"
}
]
}
18 changes: 18 additions & 0 deletions packages/core/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"extends": "../tsconfig.settings.json",
"compilerOptions": {
"rootDir": "src",
"outDir": "lib"
},
"references": [
{
"path": "../utils"
},
{
"path": "../validator"
},
{
"path": "../types"
}
]
}
21 changes: 21 additions & 0 deletions packages/react/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"extends": "../tsconfig.settings.json",
"compilerOptions": {
"rootDir": "src",
"outDir": "lib"
},
"references": [
{
"path": "../core"
},
{
"path": "../utils"
},
{
"path": "../validator"
},
{
"path": "../types"
}
]
}
23 changes: 23 additions & 0 deletions packages/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"files": [],
"references": [
{
"path": "antd"
},
{
"path": "react"
},
{
"path": "core"
},
{
"path": "utils"
},
{
"path": "validator"
},
{
"path": "types"
}
]
}
3 changes: 3 additions & 0 deletions packages/tsconfig.settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "../tsconfig",
}
8 changes: 8 additions & 0 deletions packages/types/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "../tsconfig.settings.json",
"compilerOptions": {
"rootDir": "src",
"outDir": "lib"
},
"references": []
}
8 changes: 8 additions & 0 deletions packages/utils/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "../tsconfig.settings.json",
"compilerOptions": {
"rootDir": "src",
"outDir": "lib"
},
"references": []
}
12 changes: 12 additions & 0 deletions packages/validator/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "../tsconfig.settings.json",
"compilerOptions": {
"rootDir": "src",
"outDir": "lib"
},
"references": [
{
"path": "../utils"
}
]
}
20 changes: 18 additions & 2 deletions scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,23 @@ const complieJSPackages = async callback => {
}

const transformFilesAsync = async (fileNames, options) => {
let program = ts.createProgram(fileNames, options.compilerOptions)
let program = ts.createProgram(fileNames, {
"esModuleInterop": true,
"jsx": "react",
"module": "commonjs",
"target": "ES5",
"allowJs": false,
"noUnusedLocals": true,
"removeComments": true,
"preserveConstEnums": true,
"sourceMap": false,
"declaration": true,
"outDir": "../lib",
"baseUrl": ".",
"paths": {
"rxjs/*": ["./node_modules/rxjs/*"]
}
})
let emitResult = program.emit()

let allDiagnostics = ts
Expand Down Expand Up @@ -117,5 +133,5 @@ const complieTSPackages = async callback => {
})
}

complieTSPackages()
//complieTSPackages()
complieJSPackages()
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
"esModuleInterop": true,
"jsx": "react",
"module": "commonjs",
"target": "es6",
"target": "ES5",
"allowJs": false,
"noUnusedLocals": true,
"removeComments": true,
"preserveConstEnums": true,
"sourceMap": false,
"declaration": true,
"composite": true,
"outDir": "../lib",
"baseUrl": ".",
"paths": {
Expand Down

0 comments on commit 0dfcba7

Please sign in to comment.