From f7b9b33331164d0a1bb6c524dd6adc4e5f6bf235 Mon Sep 17 00:00:00 2001 From: John Cambefort Date: Wed, 8 May 2024 12:23:03 -0400 Subject: [PATCH] feat: initialize typescript --- .gitignore | 1 + package-lock.json | 5 ++- .../action_creators/{index.js => index.ts} | 0 .../{requests.js => requests.ts} | 0 superglue/lib/{actions.js => actions.ts} | 0 superglue/lib/components/{Nav.js => Nav.tsx} | 39 ++++++++++++++----- superglue/lib/{config.js => config.ts} | 0 superglue/lib/{index.js => index.tsx} | 16 +++++++- .../lib/{middleware.js => middleware.ts} | 0 superglue/lib/reducers/{index.js => index.ts} | 0 .../lib/utils/{helpers.js => helpers.ts} | 0 .../{immutability.js => immutability.ts} | 0 superglue/lib/utils/{index.js => index.ts} | 0 superglue/lib/utils/{react.js => react.ts} | 0 .../lib/utils/{request.js => request.ts} | 0 superglue/lib/utils/{ujs.js => ujs.ts} | 0 superglue/lib/utils/{url.js => url.ts} | 0 superglue/lib/utils/{window.js => window.ts} | 0 superglue/package.json | 1 + superglue/tsconfig.json | 11 ++++++ 20 files changed, 60 insertions(+), 13 deletions(-) rename superglue/lib/action_creators/{index.js => index.ts} (100%) rename superglue/lib/action_creators/{requests.js => requests.ts} (100%) rename superglue/lib/{actions.js => actions.ts} (100%) rename superglue/lib/components/{Nav.js => Nav.tsx} (90%) rename superglue/lib/{config.js => config.ts} (100%) rename superglue/lib/{index.js => index.tsx} (95%) rename superglue/lib/{middleware.js => middleware.ts} (100%) rename superglue/lib/reducers/{index.js => index.ts} (100%) rename superglue/lib/utils/{helpers.js => helpers.ts} (100%) rename superglue/lib/utils/{immutability.js => immutability.ts} (100%) rename superglue/lib/utils/{index.js => index.ts} (100%) rename superglue/lib/utils/{react.js => react.ts} (100%) rename superglue/lib/utils/{request.js => request.ts} (100%) rename superglue/lib/utils/{ujs.js => ujs.ts} (100%) rename superglue/lib/utils/{url.js => url.ts} (100%) rename superglue/lib/utils/{window.js => window.ts} (100%) create mode 100644 superglue/tsconfig.json diff --git a/.gitignore b/.gitignore index b031ad81..0033ca6f 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ props_template/performance/**/*.png .tool-versions testapp/ +built/ \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 48e341a0..18336f90 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,3 +1,6 @@ { - "lockfileVersion": 1 + "name": "superglue", + "lockfileVersion": 3, + "requires": true, + "packages": {} } diff --git a/superglue/lib/action_creators/index.js b/superglue/lib/action_creators/index.ts similarity index 100% rename from superglue/lib/action_creators/index.js rename to superglue/lib/action_creators/index.ts diff --git a/superglue/lib/action_creators/requests.js b/superglue/lib/action_creators/requests.ts similarity index 100% rename from superglue/lib/action_creators/requests.js rename to superglue/lib/action_creators/requests.ts diff --git a/superglue/lib/actions.js b/superglue/lib/actions.ts similarity index 100% rename from superglue/lib/actions.js rename to superglue/lib/actions.ts diff --git a/superglue/lib/components/Nav.js b/superglue/lib/components/Nav.tsx similarity index 90% rename from superglue/lib/components/Nav.js rename to superglue/lib/components/Nav.tsx index 191d53d8..0d6e4f50 100644 --- a/superglue/lib/components/Nav.js +++ b/superglue/lib/components/Nav.tsx @@ -1,9 +1,27 @@ import React from 'react' import { urlToPageKey, pathWithoutBZParams } from '../utils' import { REMOVE_PAGE, HISTORY_CHANGE } from '../actions' -import PropTypes from 'prop-types' +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, +} + +interface State { + pageKey: any, + ownProps: any +} + +class Nav extends React.Component { + public history + public hasWindow + public unsubscribeHistory -class Nav extends React.Component { constructor(props) { super(props) const { history, initialPageKey } = this.props @@ -211,13 +229,14 @@ class Nav extends React.Component { } } -Nav.propTypes = { - store: PropTypes.object, - history: PropTypes.object, - mapping: PropTypes.object, - visit: PropTypes.func, - remote: PropTypes.func, - initialPageKey: PropTypes.string, -} +// 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/config.js b/superglue/lib/config.ts similarity index 100% rename from superglue/lib/config.js rename to superglue/lib/config.ts diff --git a/superglue/lib/index.js b/superglue/lib/index.tsx similarity index 95% rename from superglue/lib/index.js rename to superglue/lib/index.tsx index bae238f7..d6957e0d 100644 --- a/superglue/lib/index.js +++ b/superglue/lib/index.tsx @@ -40,7 +40,6 @@ export { superglueReducer, pageReducer, rootReducer, - updateFragments, } from './reducers' export { fragmentMiddleware } from './middleware' export { getIn } from './utils/immutability' @@ -94,7 +93,20 @@ class NotImplementedError extends Error { } } -export class ApplicationBase extends React.Component { + +interface Props {} + +export class ApplicationBase extends React.Component { + public hasWindow: any + public navigatorRef: any + public initialPageKey: any + public store: any + public history: any + public connectedMapping: any + public ujsHandlers: any + public visit: any + public remote: any + constructor(props) { super(props) this.hasWindow = typeof window !== 'undefined' diff --git a/superglue/lib/middleware.js b/superglue/lib/middleware.ts similarity index 100% rename from superglue/lib/middleware.js rename to superglue/lib/middleware.ts diff --git a/superglue/lib/reducers/index.js b/superglue/lib/reducers/index.ts similarity index 100% rename from superglue/lib/reducers/index.js rename to superglue/lib/reducers/index.ts diff --git a/superglue/lib/utils/helpers.js b/superglue/lib/utils/helpers.ts similarity index 100% rename from superglue/lib/utils/helpers.js rename to superglue/lib/utils/helpers.ts diff --git a/superglue/lib/utils/immutability.js b/superglue/lib/utils/immutability.ts similarity index 100% rename from superglue/lib/utils/immutability.js rename to superglue/lib/utils/immutability.ts diff --git a/superglue/lib/utils/index.js b/superglue/lib/utils/index.ts similarity index 100% rename from superglue/lib/utils/index.js rename to superglue/lib/utils/index.ts diff --git a/superglue/lib/utils/react.js b/superglue/lib/utils/react.ts similarity index 100% rename from superglue/lib/utils/react.js rename to superglue/lib/utils/react.ts diff --git a/superglue/lib/utils/request.js b/superglue/lib/utils/request.ts similarity index 100% rename from superglue/lib/utils/request.js rename to superglue/lib/utils/request.ts diff --git a/superglue/lib/utils/ujs.js b/superglue/lib/utils/ujs.ts similarity index 100% rename from superglue/lib/utils/ujs.js rename to superglue/lib/utils/ujs.ts diff --git a/superglue/lib/utils/url.js b/superglue/lib/utils/url.ts similarity index 100% rename from superglue/lib/utils/url.js rename to superglue/lib/utils/url.ts diff --git a/superglue/lib/utils/window.js b/superglue/lib/utils/window.ts similarity index 100% rename from superglue/lib/utils/window.js rename to superglue/lib/utils/window.ts diff --git a/superglue/package.json b/superglue/package.json index 86294156..7019de55 100644 --- a/superglue/package.json +++ b/superglue/package.json @@ -56,6 +56,7 @@ "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 new file mode 100644 index 00000000..83f8a684 --- /dev/null +++ b/superglue/tsconfig.json @@ -0,0 +1,11 @@ +{ + "compilerOptions": { + "jsx": "react", + "outDir": "./built", + "allowJs": true, + "target": "es5", + "allowSyntheticDefaultImports": true, + "esModuleInterop": true + }, + "include": ["./lib/**/*"] +} \ No newline at end of file