fix flow to ts (#115)

* fix flow to ts

* fixes

* fixes

* fixes

* fix(flow): hack to fix flow to typescript

* cleanup
This commit is contained in:
Ritesh Kumar authored and GitHub committed 2019-07-20 23:58:05 +05:30
1 parent 41c42e2664
commit 7d762c87eb
8 files changed
+31 -99

No files matched your search

+1
View File
@@ -4,3 +4,4 @@ node_modules
yarn-error.log
static
dist
.DS_Store
-44
View File
@@ -4,8 +4,6 @@ import { categorizedRoutes, Route } from "@utils/routes";
import Link from "next/link";
import { useRouter } from "next/router";
import SearchBox from "@components/Searchbox";
import Twtr from "react-share/lib/TwitterShareButton";
import TwtrIcon from "react-share/lib/TwitterIcon";
export default function() {
const router = useRouter();
@@ -74,48 +72,6 @@ export default function() {
})}
</Pane>
<Pane
backgroundColor="#fff"
borderTop
paddingY={10}
paddingX={10}
display="flex"
flexDirection="row"
alignItems="center"
justifyContent="space-between"
>
<a
href="https://www.producthunt.com/posts/transform-3?utm_source=badge-featured&utm_medium=badge&utm_souce=badge-transform-3"
target="_blank"
style={{
display: "inline-flex"
}}
>
<img
src="https://api.producthunt.com/widgets/embed-image/v1/featured.svg?post_id=161868&theme=light"
alt="transform - A polyglot web converter. | Product Hunt Embed"
style={{ width: 170, height: 40 }}
width="250px"
height="54px"
/>
</a>
<a
style={{
cursor: "pointer"
}}
>
<Twtr
round
via="ritz078"
title="Transform - A polyglot web converter to convert JSON, GraphQL, HTML, SVG, TypeScript and many more."
url="https://transform.tools"
>
<TwtrIcon size={36} round />
</Twtr>
</a>
</Pane>
<Pane paddingY={15} background="#f6f6f6" borderTop>
<Heading size={400} textAlign="center">
Created by{" "}
-1
View File
@@ -1,6 +1,5 @@
export enum BabelTransforms {
JSON_TO_PROPTYPES = 1,
OBJECT_STYLES_TO_TEMPLATE,
FLOW_TO_TYPESCRIPT,
JSON_TO_MOBX_TREE
}
+1 -2
View File
@@ -39,12 +39,12 @@
"@svgr/plugin-jsx": "^4.3.2",
"@types/jsonld": "^1.5.0",
"@walmartlabs/json-to-simple-graphql-schema": "^2.0.0",
"babel-plugin-flow-to-typescript": "^0.4.0",
"babel-plugin-json-to-proptypes": "^0.1.0",
"babel-plugin-object-styles-to-template": "^0.2.2",
"babel-standalone": "^6.26.0",
"clipboard-copy": "^3.0.0",
"evergreen-ui": "^4.18.1",
"flow-to-ts": "gist:3f49c8bd7a2b71429dcae28f2c2d1d97",
"formik": "^1.5.8",
"generate-schema": "^2.6.0",
"gofmt.js": "^0.0.2",
@@ -69,7 +69,6 @@
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-ga": "^2.6.0",
"react-share": "^3.0.0",
"snack-sdk": "^2.3.1",
"stringify-object": "^3.3.0",
"svg-to-dataurl": "^1.0.0",
+7 -10
View File
@@ -1,19 +1,16 @@
import ConversionPanel from "@components/ConversionPanel";
import * as React from "react";
import { useCallback } from "react";
import BabelWorker from "@workers/babel.worker";
import { getWorker } from "@utils/workerWrapper";
import { BabelTransforms } from "@constants/babelTransforms";
let babelWorker;
let x;
if (IN_BROWSER) {
require("flow-to-ts");
// @ts-ignore
x = window.flow2ts;
}
export default function() {
const transformer = useCallback(async ({ value }) => {
babelWorker = babelWorker || getWorker(BabelWorker);
return babelWorker.send({
type: BabelTransforms.FLOW_TO_TYPESCRIPT,
value
});
return x(value);
}, []);
return (
+13
View File
@@ -0,0 +1,13 @@
diff --git a/node_modules/flow-to-ts/flow-to-typescript.js b/node_modules/flow-to-ts/flow-to-typescript.js
index 04d034f..99371df 100644
--- a/node_modules/flow-to-ts/flow-to-typescript.js
+++ b/node_modules/flow-to-ts/flow-to-typescript.js
@@ -119061,6 +119061,8 @@ __webpack_require__.r(__webpack_exports__);
/* harmony import */ var _src_convert_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_src_convert_js__WEBPACK_IMPORTED_MODULE_0__);
console.log(_src_convert_js__WEBPACK_IMPORTED_MODULE_0___default()("\ntype A = {a: string}\n"));
+
+window.flow2ts = _src_convert_js__WEBPACK_IMPORTED_MODULE_0___default();
/* harmony default export */ __webpack_exports__["default"] = (_src_convert_js__WEBPACK_IMPORTED_MODULE_0___default.a);
/***/ }),
-12
View File
@@ -5,7 +5,6 @@ import { merge } from "lodash";
import { prettify } from "@utils/prettify";
import { BabelTransforms } from "@constants/babelTransforms";
import objStylesToTemplate from "babel-plugin-object-styles-to-template";
import babelFlowToTs from "babel-plugin-flow-to-typescript";
const _self: any = self;
@@ -46,15 +45,6 @@ function objectStylesToTemplate(value, id, settings) {
});
}
function flowToTS(value, id) {
_self.postMessage({
id,
payload: transform(value, {
plugins: [babelFlowToTs]
}).code
});
}
function jsonToMobx(value, id) {
_self.postMessage({
id,
@@ -72,8 +62,6 @@ _self.onmessage = ({ data: { id, payload } }: { data: Data }) => {
handleJsonToProptypes(value, id);
} else if (type === BabelTransforms.OBJECT_STYLES_TO_TEMPLATE) {
objectStylesToTemplate(value, id, settings);
} else if (type === BabelTransforms.FLOW_TO_TYPESCRIPT) {
flowToTS(value, id);
} else if (type === BabelTransforms.JSON_TO_MOBX_TREE) {
jsonToMobx(value, id);
}
+9 -30
View File
@@ -780,7 +780,7 @@
"@babel/parser" "^7.4.4"
"@babel/types" "^7.4.4"
"@babel/traverse@^7.1.0", "@babel/traverse@^7.2.3", "@babel/traverse@^7.4.4":
"@babel/traverse@^7.1.0", "@babel/traverse@^7.4.4":
version "7.4.5"
resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.4.5.tgz#4e92d1728fd2f1897dafdd321efbff92156c3216"
integrity sha512-Vc+qjynwkjRmIFGxy0KYoPj4FdVDxLej89kMHFsWScq999uX+pwcX4v9mWRjW0KcAYTPAuVQl2LKP1wEVLsp+A==
@@ -810,7 +810,7 @@
globals "^11.1.0"
lodash "^4.17.13"
"@babel/types@^7.0.0", "@babel/types@^7.1.2", "@babel/types@^7.2.0", "@babel/types@^7.2.2", "@babel/types@^7.3.0", "@babel/types@^7.4.4":
"@babel/types@^7.0.0", "@babel/types@^7.1.2", "@babel/types@^7.2.0", "@babel/types@^7.3.0", "@babel/types@^7.4.4":
version "7.4.4"
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.4.4.tgz#8db9e9a629bb7c29370009b4b779ed93fe57d5f0"
integrity sha512-dOllgYdnEFOebhkKCjzSVFqw/PmmB8pH6RGOWkY4GsboQNd47b1fBThBSwlHAq9alF9vc1M3+6oqR47R50L0tQ==
@@ -2093,14 +2093,6 @@ babel-plugin-dynamic-import-node@2.2.0:
dependencies:
object.assign "^4.1.0"
babel-plugin-flow-to-typescript@^0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/babel-plugin-flow-to-typescript/-/babel-plugin-flow-to-typescript-0.4.0.tgz#bea7fdb7fea30f537d1665de7987741ca2ec2bf9"
integrity sha512-+/LNrmouQmJhJ3XBxqza4Gjfmy+qpinUVm3r9rNH9Rb6d1I6CqyXSKPyUrWmGjJw3TWl/drkBQbSvTY8FlqVxg==
dependencies:
"@babel/traverse" "^7.2.3"
"@babel/types" "^7.2.2"
babel-plugin-json-to-proptypes@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/babel-plugin-json-to-proptypes/-/babel-plugin-json-to-proptypes-0.1.0.tgz#a087bdfad142a2c886413fc63754547f2e39abce"
@@ -2721,7 +2713,7 @@ class-utils@^0.3.5:
isobject "^3.0.0"
static-extend "^0.1.1"
classnames@^2.2, classnames@^2.2.5, classnames@^2.2.6:
classnames@^2.2, classnames@^2.2.6:
version "2.2.6"
resolved "https://registry.yarnpkg.com/classnames/-/classnames-2.2.6.tgz#43935bffdd291f326dad0a205309b38d00f650ce"
integrity sha512-JR/iSQOSt+LQIWwrwEzJ9uk0xfN3mTVYMwt1Ir5mUcSN6pU+V4zQFFaJsclJbPuAUQH+yfWef6tm7l1quW3C8Q==
@@ -3268,7 +3260,7 @@ date-now@^0.1.4:
resolved "https://registry.yarnpkg.com/date-now/-/date-now-0.1.4.tgz#eaf439fd4d4848ad74e5cc7dbef200672b9e345b"
integrity sha1-6vQ5/U1ISK105cx9vvIAZyueNFs=
debug@2.6.9, debug@^2.1.3, debug@^2.2.0, debug@^2.3.3:
debug@2.6.9, debug@^2.2.0, debug@^2.3.3:
version "2.6.9"
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"
integrity sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==
@@ -4247,6 +4239,10 @@ find-yarn-workspace-root@^1.2.1:
fs-extra "^4.0.3"
micromatch "^3.1.4"
"flow-to-ts@gist:3f49c8bd7a2b71429dcae28f2c2d1d97":
version "1.0.0"
resolved "https://gist.github.com/3f49c8bd7a2b71429dcae28f2c2d1d97.git#6b8f373939221c750a128ba6e301283494e635d9"
flush-write-stream@^1.0.0:
version "1.1.1"
resolved "https://registry.yarnpkg.com/flush-write-stream/-/flush-write-stream-1.1.1.tgz#8dd7d873a1babc207d94ead0c2e0e44276ebf2e8"
@@ -5807,13 +5803,6 @@ jsonld@^1.6.2:
semver "^5.6.0"
xmldom "0.1.19"
jsonp@^0.2.1:
version "0.2.1"
resolved "https://registry.yarnpkg.com/jsonp/-/jsonp-0.2.1.tgz#a65b4fa0f10bda719a05441ea7b94c55f3e15bae"
integrity sha1-pltPoPEL2nGaBUQep7lMVfPhW64=
dependencies:
debug "^2.1.3"
jsprim@^1.2.2:
version "1.4.1"
resolved "https://registry.yarnpkg.com/jsprim/-/jsprim-1.4.1.tgz#313e66bc1e5cc06e438bc1b7499c2e5c56acb6a2"
@@ -7645,7 +7634,7 @@ prop-types@15.6.2:
loose-envify "^1.3.1"
object-assign "^4.1.1"
prop-types@^15.5.10, prop-types@^15.5.7, prop-types@^15.5.8, prop-types@^15.6.0, prop-types@^15.6.1, prop-types@^15.6.2, prop-types@^15.7.2:
prop-types@^15.5.10, prop-types@^15.5.7, prop-types@^15.6.0, prop-types@^15.6.1, prop-types@^15.6.2, prop-types@^15.7.2:
version "15.7.2"
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.7.2.tgz#52c41e75b8c87e72b9d9360e0206b99dcbffa6c5"
integrity sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ==
@@ -7914,16 +7903,6 @@ react-scrollbar-size@^2.0.2:
react-event-listener "^0.5.1"
stifle "^1.0.2"
react-share@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/react-share/-/react-share-3.0.0.tgz#4855cfccfadbb3c6ef490047ccd144dc38ff7421"
integrity sha512-7UZ+QWGGZ1P4g9/5oVSIWTEXXFgQ6KgA+H6GW84iioOjM93EoaVMM/LZNiHk0hgYJLsSIGcePTKemIv1yWhYiQ==
dependencies:
babel-runtime "^6.26.0"
classnames "^2.2.5"
jsonp "^0.2.1"
prop-types "^15.5.8"
react-ssr-prepass@1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/react-ssr-prepass/-/react-ssr-prepass-1.0.2.tgz#f411414cbc043a90254cddcef0793b2aaf14b086"