diff --git a/.gitignore b/.gitignore index 0033ca6f..b031ad81 100644 --- a/.gitignore +++ b/.gitignore @@ -15,4 +15,3 @@ props_template/performance/**/*.png .tool-versions testapp/ -built/ \ No newline at end of file diff --git a/superglue/.babelrc.js b/superglue/.babelrc.js index 2e594d08..33ef79d9 100644 --- a/superglue/.babelrc.js +++ b/superglue/.babelrc.js @@ -1,6 +1,6 @@ module.exports = { plugins: [ - ["transform-react-remove-prop-types", {removeImport: true}] + ["transform-react-remove-prop-types", { removeImport: true }] ], presets: [ [ @@ -14,5 +14,8 @@ module.exports = { [ "@babel/preset-react" ], + [ + "@babel/preset-typescript" + ], ], }; diff --git a/superglue/lib/components/Nav.tsx b/superglue/lib/components/Nav.tsx index 0d6e4f50..2b286be2 100644 --- a/superglue/lib/components/Nav.tsx +++ b/superglue/lib/components/Nav.tsx @@ -1,19 +1,18 @@ import React from 'react' import { urlToPageKey, pathWithoutBZParams } from '../utils' import { REMOVE_PAGE, HISTORY_CHANGE } from '../actions' -import { object, func, string } from 'prop-types' interface Props { - store: any, // object - history: any, // object - mapping: any, // object - visit: any, // fund - remote: any, // func - initialPageKey: string, + store: any + history: any + mapping: any + visit: any + remote: any + initialPageKey: any } interface State { - pageKey: any, + pageKey: any ownProps: any } @@ -229,14 +228,4 @@ class Nav extends React.Component { } } -// TODO: remove now that we have Props ? -// Nav.propTypes = { -// store: object, -// history: object, -// mapping: object, -// visit: func, -// remote: func, -// initialPageKey: string, -// } - export default Nav diff --git a/superglue/lib/index.tsx b/superglue/lib/index.tsx index d6957e0d..3ae3fb19 100644 --- a/superglue/lib/index.tsx +++ b/superglue/lib/index.tsx @@ -15,7 +15,6 @@ import thunk from 'redux-thunk' import { Provider, connect } from 'react-redux' import { createBrowserHistory, createMemoryHistory } from 'history' import Nav from './components/Nav' -import PropTypes from 'prop-types' export { BEFORE_FETCH, @@ -93,10 +92,15 @@ class NotImplementedError extends Error { } } +interface Props { + initialPage: any + baseUrl: any + path: any +} -interface Props {} +interface Store {} -export class ApplicationBase extends React.Component { +export class ApplicationBase extends React.Component { public hasWindow: any public navigatorRef: any public initialPageKey: any @@ -232,10 +236,3 @@ export class ApplicationBase extends React.Component { ) } } - -ApplicationBase.propTypes = { - initialPage: PropTypes.object, - baseUrl: PropTypes.string, - path: PropTypes.string, - appEl: PropTypes.object, -} diff --git a/superglue/lib/utils/ujs.ts b/superglue/lib/utils/ujs.ts index ee8f1255..f65e89e8 100644 --- a/superglue/lib/utils/ujs.ts +++ b/superglue/lib/utils/ujs.ts @@ -1,6 +1,10 @@ import { withoutBusters, urlToPageKey } from './url' export class HandlerBuilder { + public attributePrefix: any + public visit: any + public remote: any + constructor({ ujsAttributePrefix, visit, remote }) { this.attributePrefix = ujsAttributePrefix this.isUJS = this.isUJS.bind(this) @@ -84,7 +88,7 @@ export class HandlerBuilder { this.visitOrRemote(link, url, { method: 'GET' }) } - visitOrRemote(linkOrForm, url, opts = {}) { + visitOrRemote(linkOrForm, url, opts: any = {}) { let target if (linkOrForm.getAttribute(this.attributePrefix + '-visit')) { diff --git a/superglue/package.json b/superglue/package.json index 7019de55..9be81719 100644 --- a/superglue/package.json +++ b/superglue/package.json @@ -9,7 +9,10 @@ "copy:package": "cat ./package.json | jq 'del(.scripts)' > dist/package.json", "copy:readme": "cp ../README.md dist/", "build:index": "babel lib -d dist", - "build": "npm run clean && npm run build:index && npm run copy:package && npm run copy:readme", + "build": "npm run clean && npm run build:js && npm run copy:package && npm run copy:readme", + "build:js": "babel lib --out-dir dist --extensions \".ts,.tsx\" --source-maps inline", + "type-check": "tsc --noEmit", + "type-check:watch": "npm run type-check -- --watch", "prepublishOnly": "npm run build" }, "repository": { @@ -27,6 +30,7 @@ "@babel/core": "^7.14.3", "@babel/preset-env": "^7.14.4", "@babel/preset-react": "^7.13.13", + "@types/url-parse": "^1.4.11", "core-js": "^2.6.12", "enzyme": "^3.11.0", "enzyme-adapter-react-16": "^1.15.6", @@ -56,7 +60,6 @@ "redux-thunk": ">=2.3" }, "dependencies": { - "@types/url-parse": "^1.4.11", "abortcontroller-polyfill": "^1.7.3", "babel-plugin-transform-react-remove-prop-types": "^0.4.24", "url-parse": "^1.5.1" diff --git a/superglue/tsconfig.json b/superglue/tsconfig.json index 83f8a684..ad3b30dc 100644 --- a/superglue/tsconfig.json +++ b/superglue/tsconfig.json @@ -1,11 +1,12 @@ { "compilerOptions": { "jsx": "react", - "outDir": "./built", "allowJs": true, "target": "es5", "allowSyntheticDefaultImports": true, "esModuleInterop": true }, - "include": ["./lib/**/*"] -} \ No newline at end of file + "include": [ + "./lib/**/*" + ] +}