Skip to content

Commit

Permalink
chore: add initial TS support (4Catalyzer#997)
Browse files Browse the repository at this point in the history
* chore: add initial TS support

* minor changes

* fix script

Co-authored-by: Szymon Wiszczuk <[email protected]>
  • Loading branch information
golota60 and szymon-nordsec authored Nov 30, 2022
1 parent 45406a0 commit 1feea81
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 42 deletions.
12 changes: 9 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
module.exports = {
extends: ['4catalyzer-react', '4catalyzer-jest', 'prettier'],
plugins: ['prettier'],
parserOptions: {
requireConfigFile: false,
plugins: ['prettier', 'import'],
parser: '@typescript-eslint/parser',
settings: {
'import/resolver': {
typescript: {
alwaysTryTypes: true,
},
},
},
rules: {
'react/prop-types': 'off',
'prettier/prettier': 'error',
'no-use-before-define': 'off',
},
};
12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,20 @@
"url": "https://github.com/4Catalyzer/found.git"
},
"scripts": {
"build": "rimraf lib && 4c build --types false src && npm run build:pick && npm run build:types",
"tsc": "tsc",
"build:ts": "yarn tsc --outDir lib/cjs --module commonjs && yarn tsc --outDir lib/esm --module es2020 && mv lib/esm/*.d.ts lib && mv lib/cjs/*.d.ts lib",
"build": "rimraf lib && 4c build --types false src && yarn build:pick && yarn build:types && yarn build:ts",
"build:pick": "cherry-pick --cjs-dir cjs --esm-dir esm --cwd lib ../src",
"build:types": "cpy types/*.d.ts lib",
"build:docs": "yarn --cwd www build",
"format": "4c format --prettier-ignore .eslintignore .",
"lint": "4c lint --prettier-ignore .eslintignore .",
"prepublishOnly": "npm run build",
"prepublishOnly": "yarn build",
"publishLocal": "yarn prepublishOnly && yarn file-butler prepare-publish-dir lib && yalc push lib",
"release": "4c release",
"tdd": "jest --watch",
"test": "npm run lint && npm run test:ts && npm run testonly -- --coverage",
"test:ts": "dtslint --expectOnly types",
"test": "yarn lint && yarn test:ts && yarn testonly -- --coverage",
"test:ts": "dtslint --expectOnly types && yarn tsc --noEmit",
"testonly": "jest --runInBand --verbose",
"docs": "yarn --cwd www start"
},
Expand Down Expand Up @@ -82,7 +84,7 @@
"@4c/cli": "^3.0.1",
"@4c/file-butler": "^6.0.0",
"@4c/prettier-config": "^1.1.0",
"@4c/tsconfig": "^0.4.0",
"@4c/tsconfig": "^0.4.1",
"@babel/core": "^7.17.9",
"@types/react-dom": "^17.0.15",
"@typescript-eslint/eslint-plugin": "^5.19.0",
Expand Down
4 changes: 3 additions & 1 deletion src/ActionTypes.js → src/ActionTypes.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export default {
const ActionTypes = {
UPDATE_MATCH: '@@found/UPDATE_MATCH',
RESOLVE_MATCH: '@@found/RESOLVE_MATCH',
};

export default ActionTypes;
58 changes: 29 additions & 29 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
export ActionTypes from './ActionTypes';
export createBaseRouter from './createBaseRouter';
export createBrowserRouter from './createBrowserRouter';
export createConnectedRouter from './createConnectedRouter';
export createElements from './createElements';
export createFarceRouter from './createFarceRouter';
export createFarceStore from './createFarceStore';
export createInitialBrowserRouter from './createInitialBrowserRouter';
export createInitialFarceRouter from './createInitialFarceRouter';
export createMatchEnhancer from './createMatchEnhancer';
export createRender from './createRender';
export createStoreRouterObject from './createStoreRouterObject';
export ElementsRenderer from './ElementsRenderer';
export foundReducer from './foundReducer';
export getRenderArgs from './getRenderArgs';
export getStoreRenderArgs from './getStoreRenderArgs';
export hotRouteConfig from './hotRouteConfig';
export HttpError from './HttpError';
export Link from './Link';
export makeRouteConfig from './makeRouteConfig';
export Matcher from './Matcher';
export { default as ActionTypes } from './ActionTypes';
export { default as createBaseRouter } from './createBaseRouter';
export { default as createBrowserRouter } from './createBrowserRouter';
export { default as createConnectedRouter } from './createConnectedRouter';
export { default as createElements } from './createElements';
export { default as createFarceRouter } from './createFarceRouter';
export { default as createFarceStore } from './createFarceStore';
export { default as createInitialBrowserRouter } from './createInitialBrowserRouter';
export { default as createInitialFarceRouter } from './createInitialFarceRouter';
export { default as createMatchEnhancer } from './createMatchEnhancer';
export { default as createRender } from './createRender';
export { default as createStoreRouterObject } from './createStoreRouterObject';
export { default as ElementsRenderer } from './ElementsRenderer';
export { default as foundReducer } from './foundReducer';
export { default as getRenderArgs } from './getRenderArgs';
export { default as getStoreRenderArgs } from './getStoreRenderArgs';
export { default as hotRouteConfig } from './hotRouteConfig';
export { default as HttpError } from './HttpError';
export { default as Link } from './Link';
export { default as makeRouteConfig } from './makeRouteConfig';
export { default as Matcher } from './Matcher';
export { matcherShape, matchShape, routerShape } from './PropTypes';
export Redirect from './Redirect';
export RedirectException from './RedirectException';
export resolver from './resolver';
export resolveRenderArgs from './resolveRenderArgs';
export { default as Redirect } from './Redirect';
export { default as RedirectException } from './RedirectException';
export { default as resolver } from './resolver';
export { default as resolveRenderArgs } from './resolveRenderArgs';
export * as ResolverUtils from './ResolverUtils';
export Route from './Route';
export RouterContext from './RouterContext';
export useRouter from './useRouter';
export withRouter from './withRouter';
export { default as Route } from './Route';
export { default as RouterContext } from './RouterContext';
export { default as useRouter } from './useRouter';
export { default as withRouter } from './withRouter';
7 changes: 7 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "@4c/tsconfig/web.json",
"compilerOptions": {
"allowJs": true
},
"include": ["./src/**/*.ts"]
}
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,10 @@
webpack-notifier "^1.13.0"
webpackbar "^5.0.0-3"

"@4c/tsconfig@^0.4.0":
version "0.4.0"
resolved "https://registry.yarnpkg.com/@4c/tsconfig/-/tsconfig-0.4.0.tgz#30088bb8689c6db0f9dcf1426e1552a86181aacd"
integrity sha512-71kWn/hccTUYeQpnxUvKFDaGetQj7T1+Dd18Eo1RAnRsqLznk0wFykm1KFOuNGxMNUupHRoe9Z8C6LNR3il8Eg==
"@4c/tsconfig@^0.4.1":
version "0.4.1"
resolved "https://npm.mountaininfra.net/@4c%2ftsconfig/-/tsconfig-0.4.1.tgz#90f7edc7780387788cb6b1d9885b5350ae50431a"
integrity sha512-uCS2WRXvDPj/8i6zOWfiLMj/n4AwVRNMy8FhhEdIie2/DT7PkIzomRXL5Hgq2TRcG0g80lgQRtBYiRYcx9xC1A==
dependencies:
typescript-workspace-plugin "^2.0.1"

Expand Down

0 comments on commit 1feea81

Please sign in to comment.