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

[typescript-migration] initial ts config and the first calendar_container.jsx module #4704

Merged
merged 4 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 5 additions & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
const { NODE_ENV } = process.env;

const presets = ["@babel/preset-env", "@babel/preset-react"];
const presets = [
"@babel/preset-typescript",
"@babel/preset-env",
"@babel/preset-react",
];
const plugins = [
"@babel/plugin-transform-react-jsx",
"@babel/plugin-proposal-class-properties",
Expand Down
4 changes: 2 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ module.exports = {
setupFilesAfterEnv: ["<rootDir>/test/index.js"],
testEnvironment: "jest-environment-jsdom",
collectCoverageFrom: [
"**/*.{js,jsx}",
"**/*.{js,jsx, ts, tsx}",
"!**/node_modules/**",
"!**/vendor/**",
],
transformIgnorePatterns: ["/node_modules/(?!date-fns)"],
transform: {
"^.+\\.(js|jsx)$": "babel-jest",
"^.+\\.(js|jsx|ts|tsx)$": "babel-jest",
"^.+\\.ts?$": "ts-jest",
"node_modules/(?!date-fns/.*)": "ts-jest",
},
Expand Down
17 changes: 12 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,15 @@
"@babel/plugin-proposal-class-properties": "^7.18.6",
"@babel/preset-env": "^7.22.10",
"@babel/preset-react": "^7.22.5",
"@babel/preset-typescript": "^7.24.1",
"@react-docgen/cli": "^2.0.3",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-typescript": "^11.1.6",
"@testing-library/react": "^15.0.0",
"@types/jest": "^29.5.4",
"@types/jest": "^29.5.12",
"@types/node": "20",
"axe-core": "^4.4.1",
"babel-jest": "^29.6.4",
Expand All @@ -74,7 +76,9 @@
"stylelint-config-standard": "^36.0.0",
"stylelint-config-standard-scss": "^13.0.0",
"stylelint-scss": "^6.2.1",
"ts-jest": "^29.1.1"
"ts-jest": "^29.1.1",
"tslib": "^2.6.2",
"typescript": "^5.4.5"
},
"peerDependencies": {
"react": "^16.9.0 || ^17 || ^18",
Expand All @@ -98,13 +102,16 @@
"test": "NODE_ENV=test jest",
"test:ci": "NODE_ENV=test jest --ci --coverage",
"test:watch": "NODE_OPTIONS=--openssl-legacy-provider NODE_ENV=test jest --watch",
"build": "NODE_ENV=production yarn run build:js && NODE_ENV=production yarn run css:prod && NODE_ENV=production yarn run css:modules:dev && NODE_ENV=production yarn run css:dev && NODE_ENV=production yarn run css:modules:dev",
"build-dev": "NODE_ENV=development yarn run js:dev && NODE_ENV=development yarn run css:dev && NODE_ENV=development yarn run css:modules:dev",
"build": "NODE_ENV=production yarn run build:src && NODE_ENV=production yarn run css:prod && NODE_ENV=production yarn run css:modules:dev && NODE_ENV=production yarn run css:dev && NODE_ENV=production yarn run css:modules:dev && NODE_ENV=production yarn run build:types",
"build-dev": "NODE_ENV=development yarn run js:dev && NODE_ENV=development yarn run css:dev && NODE_ENV=development yarn run css:modules:dev && NODE_ENV=production yarn run build:types",
"css:prod": "sass --style compressed src/stylesheets/datepicker.scss > dist/react-datepicker.min.css",
"css:modules:prod": "sass --style compressed src/stylesheets/datepicker-cssmodules.scss | tee dist/react-datepicker-cssmodules.min.css dist/react-datepicker-min.module.css",
"css:dev": "sass --style expanded src/stylesheets/datepicker.scss > dist/react-datepicker.css",
"css:modules:dev": "sass --style expanded src/stylesheets/datepicker-cssmodules.scss | tee dist/react-datepicker-cssmodules.css dist/react-datepicker.module.css",
"build:js": "rollup -c",
"type-check": "tsc --noEmit",
"type-check:watch": "npm run type-check -- --watch",
"build:types": "tsc --emitDeclarationOnly",
"build:src": "rollup -c",
"js:dev": "rollup -cw",
"prepare": "husky install"
},
Expand Down
8 changes: 7 additions & 1 deletion rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import resolve from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import filesize from "rollup-plugin-filesize";
import terser from "@rollup/plugin-terser";
import typescript from "@rollup/plugin-typescript";

const pkg = JSON.parse(
fs
Expand Down Expand Up @@ -95,10 +96,15 @@ const config = {
plugins: [
resolve({
mainFields: ["module"],
extensions: [".js", ".jsx"],
extensions: [".js", ".jsx", ".ts", ".tsx"],
}),
babel(),
commonjs(),
typescript({
tsconfig: "./tsconfig.json",
declaration: true,
declarationDir: "dist",
}),
filesize(),
],
external: [
Expand Down
17 changes: 8 additions & 9 deletions src/calendar_container.jsx → src/calendar_container.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import PropTypes from "prop-types";
import React from "react";

interface CalendarContainerProps {
showTimeSelectOnly?: boolean;
showTime?: boolean;
className?: string;
children?: React.ReactNode;
}

export default function CalendarContainer({
showTimeSelectOnly = false,
showTime = false,
className,
children,
}) {
}: Readonly<CalendarContainerProps>) {
let ariaLabel = showTimeSelectOnly
? "Choose Time"
: `Choose Date${showTime ? " and Time" : ""}`;
Expand All @@ -22,10 +28,3 @@ export default function CalendarContainer({
</div>
);
}

CalendarContainer.propTypes = {
showTimeSelectOnly: PropTypes.bool,
showTime: PropTypes.bool,
className: PropTypes.string,
children: PropTypes.node,
};
27 changes: 27 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"noFallthroughCasesInSwitch": true,
"noUnusedParameters": true,
"noUnusedLocals": true,
"declarationDir": "dist/types",
"declaration": true,
"strict": true,
martijnrusschen marked this conversation as resolved.
Show resolved Hide resolved
"noUncheckedIndexedAccess": true,
"module": "esnext",
"target": "es5",
"lib": ["es6", "dom"],
"sourceMap": true,
"jsx": "react",
"moduleResolution": "node",
"rootDir": "src",
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
"strictNullChecks": true,
"esModuleInterop": true,
"baseUrl": "src/"
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist"]
}
52 changes: 49 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@
dependencies:
"@babel/helper-plugin-utils" "^7.8.0"

"@babel/plugin-syntax-jsx@^7.23.3":
"@babel/plugin-syntax-jsx@^7.23.3", "@babel/plugin-syntax-jsx@^7.24.1":
version "7.24.1"
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.24.1.tgz#3f6ca04b8c841811dbc3c5c5f837934e0d626c10"
integrity sha512-2eCtxZXf+kbkMIsXS4poTvT4Yu5rXiRa+9xGVT56raghjmBTKMpFNc9R4IDiB4emao9eO22Ox7CxuJG7BgExqA==
Expand Down Expand Up @@ -542,6 +542,13 @@
dependencies:
"@babel/helper-plugin-utils" "^7.14.5"

"@babel/plugin-syntax-typescript@^7.24.1":
version "7.24.1"
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.24.1.tgz#b3bcc51f396d15f3591683f90239de143c076844"
integrity sha512-Yhnmvy5HZEnHUty6i++gcfH1/l68AHnItFHnaCv6hn9dNh0hQvvQJsxpi4BMBFN5DLeHBuucT/0DgzXif/OyRw==
dependencies:
"@babel/helper-plugin-utils" "^7.24.0"

"@babel/plugin-syntax-typescript@^7.7.2":
version "7.22.5"
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.22.5.tgz#aac8d383b062c5072c647a31ef990c1d0af90272"
Expand Down Expand Up @@ -946,6 +953,16 @@
dependencies:
"@babel/helper-plugin-utils" "^7.24.0"

"@babel/plugin-transform-typescript@^7.24.1":
version "7.24.4"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.24.4.tgz#03e0492537a4b953e491f53f2bc88245574ebd15"
integrity sha512-79t3CQ8+oBGk/80SQ8MN3Bs3obf83zJ0YZjDmDaEZN8MqhMI760apl5z6a20kFeMXBwJX99VpKT8CKxEBp5H1g==
dependencies:
"@babel/helper-annotate-as-pure" "^7.22.5"
"@babel/helper-create-class-features-plugin" "^7.24.4"
"@babel/helper-plugin-utils" "^7.24.0"
"@babel/plugin-syntax-typescript" "^7.24.1"

"@babel/plugin-transform-unicode-escapes@^7.24.1":
version "7.24.1"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-unicode-escapes/-/plugin-transform-unicode-escapes-7.24.1.tgz#fb3fa16676549ac7c7449db9b342614985c2a3a4"
Expand Down Expand Up @@ -1085,6 +1102,17 @@
"@babel/plugin-transform-react-jsx-development" "^7.22.5"
"@babel/plugin-transform-react-pure-annotations" "^7.24.1"

"@babel/preset-typescript@^7.24.1":
version "7.24.1"
resolved "https://registry.yarnpkg.com/@babel/preset-typescript/-/preset-typescript-7.24.1.tgz#89bdf13a3149a17b3b2a2c9c62547f06db8845ec"
integrity sha512-1DBaMmRDpuYQBPWD8Pf/WEwCrtgRHxsZnP4mIy9G/X+hFfbI47Q2G4t1Paakld84+qsk2fSsUPMKg71jkoOOaQ==
dependencies:
"@babel/helper-plugin-utils" "^7.24.0"
"@babel/helper-validator-option" "^7.23.5"
"@babel/plugin-syntax-jsx" "^7.24.1"
"@babel/plugin-transform-modules-commonjs" "^7.24.1"
"@babel/plugin-transform-typescript" "^7.24.1"

"@babel/regjsgen@^0.8.0":
version "0.8.0"
resolved "https://registry.yarnpkg.com/@babel/regjsgen/-/regjsgen-0.8.0.tgz#f0ba69b075e1f05fb2825b7fad991e7adbb18310"
Expand Down Expand Up @@ -1691,7 +1719,15 @@
smob "^1.0.0"
terser "^5.17.4"

"@rollup/pluginutils@^5.0.1":
"@rollup/plugin-typescript@^11.1.6":
version "11.1.6"
resolved "https://registry.yarnpkg.com/@rollup/plugin-typescript/-/plugin-typescript-11.1.6.tgz#724237d5ec12609ec01429f619d2a3e7d4d1b22b"
integrity sha512-R92yOmIACgYdJ7dJ97p4K69I8gg6IEHt8M7dUBxN3W6nrO8uUxX5ixl0yU/N3aZTi8WhPuICvOHXQvF6FaykAA==
dependencies:
"@rollup/pluginutils" "^5.1.0"
resolve "^1.22.1"

"@rollup/pluginutils@^5.0.1", "@rollup/pluginutils@^5.1.0":
version "5.1.0"
resolved "https://registry.yarnpkg.com/@rollup/pluginutils/-/pluginutils-5.1.0.tgz#7e53eddc8c7f483a4ad0b94afb1f7f5fd3c771e0"
integrity sha512-XTIWOPPcpvyKI6L1NHo0lFlCyznUEyPmPY1mc3KpPVDYulHSTvyeLNVW00QTLIAFNhR3kYnJTQHeGqU4M3n09g==
Expand Down Expand Up @@ -1927,7 +1963,7 @@
dependencies:
"@types/istanbul-lib-report" "*"

"@types/jest@^29.5.4":
"@types/jest@^29.5.12":
version "29.5.12"
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-29.5.12.tgz#7f7dc6eb4cf246d2474ed78744b05d06ce025544"
integrity sha512-eDC8bTvT/QhYdxJAulQikueigY5AsdBRH2yDKW3yveW7svY3+DzN84/2NUgkw10RTiJbWqZrTtoGVdYlvFJdLw==
Expand Down Expand Up @@ -7017,6 +7053,11 @@ ts-jest@^29.1.1:
semver "^7.5.3"
yargs-parser "^21.0.1"

tslib@^2.6.2:
version "2.6.2"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.2.tgz#703ac29425e7b37cd6fd456e92404d46d1f3e4ae"
integrity sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==

tuf-js@^1.1.7:
version "1.1.7"
resolved "https://registry.yarnpkg.com/tuf-js/-/tuf-js-1.1.7.tgz#21b7ae92a9373015be77dfe0cb282a80ec3bbe43"
Expand Down Expand Up @@ -7136,6 +7177,11 @@ typed-array-length@^1.0.5:
is-typed-array "^1.1.13"
possible-typed-array-names "^1.0.0"

typescript@^5.4.5:
version "5.4.5"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.4.5.tgz#42ccef2c571fdbd0f6718b1d1f5e6e5ef006f611"
integrity sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==

unbox-primitive@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/unbox-primitive/-/unbox-primitive-1.0.2.tgz#29032021057d5e6cdbd08c5129c226dff8ed6f9e"
Expand Down
Loading