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

feat: initialize typescript #60

Merged
merged 3 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
chore: keep babel
  • Loading branch information
johncardiologs committed Jun 8, 2024
commit afe4443646b1a5028f8d9591225f66cd39e3c068
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ props_template/performance/**/*.png
.tool-versions
testapp/

built/
5 changes: 4 additions & 1 deletion superglue/.babelrc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
plugins: [
["transform-react-remove-prop-types", {removeImport: true}]
["transform-react-remove-prop-types", { removeImport: true }]
],
presets: [
[
Expand All @@ -14,5 +14,8 @@ module.exports = {
[
"@babel/preset-react"
],
[
"@babel/preset-typescript"
],
],
};
25 changes: 7 additions & 18 deletions superglue/lib/components/Nav.tsx
Original file line number Diff line number Diff line change
@@ -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
}

Expand Down Expand Up @@ -229,14 +228,4 @@ class Nav extends React.Component<Props, State> {
}
}

// TODO: remove now that we have Props ?
// Nav.propTypes = {
// store: object,
// history: object,
// mapping: object,
// visit: func,
// remote: func,
// initialPageKey: string,
// }

export default Nav
17 changes: 7 additions & 10 deletions superglue/lib/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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<Props> {
export class ApplicationBase extends React.Component<Props, Store> {
public hasWindow: any
public navigatorRef: any
public initialPageKey: any
Expand Down Expand Up @@ -232,10 +236,3 @@ export class ApplicationBase extends React.Component<Props> {
)
}
}

ApplicationBase.propTypes = {
initialPage: PropTypes.object,
baseUrl: PropTypes.string,
path: PropTypes.string,
appEl: PropTypes.object,
}
6 changes: 5 additions & 1 deletion superglue/lib/utils/ujs.ts
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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')) {
Expand Down
9 changes: 6 additions & 3 deletions superglue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
"clean": "rm -rf ./dist",
"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",
johncardiologs marked this conversation as resolved.
Show resolved Hide resolved
"type-check": "tsc --noEmit",
"type-check:watch": "npm run type-check -- --watch",
"prepublishOnly": "npm run build"
},
"repository": {
Expand All @@ -27,6 +29,8 @@
"@babel/core": "^7.14.3",
"@babel/preset-env": "^7.14.4",
"@babel/preset-react": "^7.13.13",
"@babel/preset-typescript": "^7.24.6",
"@types/url-parse": "^1.4.11",
johncardiologs marked this conversation as resolved.
Show resolved Hide resolved
"core-js": "^2.6.12",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.6",
Expand Down Expand Up @@ -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"
Expand Down
7 changes: 4 additions & 3 deletions superglue/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"compilerOptions": {
"jsx": "react",
"outDir": "./built",
"allowJs": true,
"target": "es5",
"allowSyntheticDefaultImports": true,
"esModuleInterop": true
},
"include": ["./lib/**/*"]
}
"include": [
"./lib/**/*"
]
}
Loading