Skip to content

Commit

Permalink
Add TypeScript support, replace Babel with TypeScript compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtekmaj committed Mar 2, 2023
1 parent 0c878a7 commit e253cd3
Show file tree
Hide file tree
Showing 7 changed files with 353 additions and 198 deletions.
2 changes: 1 addition & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"presets": ["@babel/env", "@babel/react"]
"presets": ["@babel/typescript", "@babel/env", "@babel/react"]
}
8 changes: 7 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
{
"extends": "wojtekmaj/react-no-automatic-runtime",
"extends": [
"wojtekmaj/react-no-automatic-runtime",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"overrides": [
{
"files": ["sample/**", "test/**"],
Expand Down
35 changes: 0 additions & 35 deletions index.d.ts

This file was deleted.

24 changes: 17 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,26 @@
"name": "react-date-picker",
"version": "9.2.0",
"description": "A date picker for your React app.",
"main": "dist/index.js",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"source": "src/index.js",
"types": "./index.d.ts",
"sideEffects": [
"*.css"
],
"scripts": {
"build": "yarn build-js && yarn copy-styles",
"build-js": "babel src -d dist --ignore \"**/*.spec.js,**/*.spec.jsx\"",
"build-js": "yarn build-js-esm && yarn build-js-cjs",
"build-js-esm": "tsc --project tsconfig.build.json --outDir dist/esm --module esnext",
"build-js-cjs": "tsc --project tsconfig.build.json --outDir dist/cjs --module commonjs",
"clean": "rimraf dist",
"copy-styles": "node ./copy-styles.mjs",
"jest": "jest",
"lint": "eslint . --ext .js,.jsx",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
"postinstall": "husky install",
"prepack": "yarn clean && yarn build",
"prettier": "prettier --check . --cache",
"test": "yarn lint && yarn prettier && yarn jest"
"test": "yarn lint && yarn tsc && yarn prettier && yarn jest",
"tsc": "tsc --noEmit"
},
"keywords": [
"calendar",
Expand All @@ -41,13 +47,16 @@
"update-input-width": "^1.2.2"
},
"devDependencies": {
"@babel/cli": "^7.15.0",
"@babel/core": "^7.15.0",
"@babel/preset-env": "^7.15.0",
"@babel/preset-react": "^7.14.0",
"@babel/preset-typescript": "^7.18.6",
"@testing-library/jest-dom": "^5.15.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^14.4.0",
"@types/jest": "^29.0.0",
"@typescript-eslint/eslint-plugin": "^5.41.0",
"@typescript-eslint/parser": "^5.44.0",
"eslint": "^8.26.0",
"eslint-config-wojtekmaj": "^0.7.1",
"husky": "^8.0.0",
Expand All @@ -57,7 +66,8 @@
"pretty-quick": "^3.1.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"rimraf": "^3.0.0"
"rimraf": "^3.0.0",
"typescript": "^4.9.5"
},
"peerDependencies": {
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
Expand Down
4 changes: 4 additions & 0 deletions tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "./tsconfig.json",
"exclude": ["src/**/*.spec.js", "src/**/*.spec.jsx", "src/**/*.spec.ts", "src/**/*.spec.tsx"]
}
18 changes: 18 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"compilerOptions": {
"allowJs": true,
"declaration": false,
"downlevelIteration": true,
"esModuleInterop": true,
"importsNotUsedAsValues": "error",
"isolatedModules": true,
"jsx": "react",
"moduleResolution": "node",
"noUncheckedIndexedAccess": true,
"outDir": "dist",
"strict": true,
"strictNullChecks": true,
"target": "es5"
},
"include": ["src"]
}
Loading

0 comments on commit e253cd3

Please sign in to comment.