Skip to content

Commit

Permalink
feat: Enable TS on cozy-harvest
Browse files Browse the repository at this point in the history
  • Loading branch information
acezard committed Feb 24, 2023
1 parent c80e2cb commit 0eb444b
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 18 deletions.
4 changes: 2 additions & 2 deletions packages/cozy-harvest-lib/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
browser: true,
collectCoverageFrom: [
'src/**/*.{js,jsx}',
'src/**/*.{js,jsx,ts,tsx}',
'!**/node_modules/**',
'!**/vendor/**'
],
Expand All @@ -10,7 +10,7 @@ module.exports = {
testPathIgnorePatterns: ['node_modules', 'dist'],
testEnvironment: 'jest-environment-jsdom-sixteen',
testURL: 'http://localhost/',
moduleFileExtensions: ['js', 'jsx', 'json', 'styl'],
moduleFileExtensions: ['js', 'jsx', 'ts', 'tsx', 'json', 'styl'],
moduleDirectories: ['src', 'node_modules'],
moduleNameMapper: {
'^cozy-logger$': 'cozy-logger/dist/index.js',
Expand Down
6 changes: 4 additions & 2 deletions packages/cozy-harvest-lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@
"url": "https://github.com/cozy/cozy-libs/issues"
},
"scripts": {
"build": "babel src -d dist --copy-files --verbose",
"build": "babel --extensions .js,.jsx,.ts,.tsx --ignore '**/*.spec.tsx','**/*.spec.ts' ./src -d ./dist --copy-files --verbose",
"build:watch": "yarn build --watch",
"build:doc:react": "(cd ../.. && TARGET=cozy-harvest-lib yarn build:doc:react)",
"deploy:doc": "(cd ../.. && yarn deploy:doc)",
"prepublishOnly": "yarn check-locales && yarn build",
"check-locales": "./scripts/check-locales.sh",
"test": "jest --runInBand",
"lint": "cd .. && yarn eslint --ext js,jsx packages/cozy-harvest-lib",
"start": "yarn build --watch",
"start": "yarn build:watch",
"cli": "env BABEL_ENV=es5 node src/cli/index.js",
"watch:doc:react": "(cd ../.. && TARGET=cozy-harvest-lib yarn watch:doc:react)"
},
Expand Down Expand Up @@ -57,6 +58,7 @@
"cozy-intent": "^2.9.0",
"cozy-keys-lib": "^4.1.9",
"cozy-realtime": "^4.3.0",
"cozy-tsconfig": "^1.0.0",
"cozy-ui": "^80.1.1",
"enzyme": "3.11.0",
"enzyme-adapter-react-16": "1.15.6",
Expand Down
14 changes: 14 additions & 0 deletions packages/cozy-harvest-lib/src/cozy-ui.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
declare module 'cozy-ui/transpiled/react/*' {
interface UiProps {
className?: string
children?: React.ReactNode
[key: string]: unknown
}

const element: (props: UiProps) => JSX.Element
export default element

export const useI18n: () => {
t: (key: string, vars?: Record<string, unknown>) => string
}
}
2 changes: 2 additions & 0 deletions packages/cozy-harvest-lib/src/logger.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
declare const logger: (severity: string, ...args: unknown[]) => void
export default logger
35 changes: 35 additions & 0 deletions packages/cozy-harvest-lib/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"extends": "cozy-tsconfig",
"include": [
"src/**/*",
"tests"
],
"exclude": [
"node_modules",
"dist"
],
"compilerOptions": {
"allowJs": false,
"allowSyntheticDefaultImports": true,
"baseUrl": "./src",
"declaration": true,
"declarationDir": "./dist",
"emitDeclarationOnly": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"isolatedModules": true,
"jsx": "react",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"module": "esnext",
"moduleResolution": "node",
"noFallthroughCasesInSwitch": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"strict": true,
"target": "es5"
}
}
28 changes: 14 additions & 14 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5603,7 +5603,7 @@ browserslist@^4.20.2, browserslist@^4.20.3:
node-releases "^2.0.5"
picocolors "^1.0.0"

browserslist@^4.21.3, browserslist@^4.21.4:
browserslist@^4.21.3, browserslist@^4.21.5:
version "4.21.5"
resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.21.5.tgz#75c5dae60063ee641f977e00edd3cfb2fb7af6a7"
integrity sha512-tUkiguQGW7S3IhB7N+c2MV/HZPSCPAAiYBZXLsBhFB/PCy6ZKKsZrmBayHV9fdGV/ARIfJ14NkxKzRDjvp7L6w==
Expand Down Expand Up @@ -5914,9 +5914,9 @@ caniuse-lite@^1.0.30001349:
integrity sha512-GUgH8w6YergqPQDGWhJGt8GDRnY0L/iJVQcU3eJ46GYf52R8tk0Wxp0PymuFVZboJYXGiCqwozAYZNRjVj6IcA==

caniuse-lite@^1.0.30001449:
version "1.0.30001451"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001451.tgz#2e197c698fc1373d63e1406d6607ea4617c613f1"
integrity sha512-XY7UbUpGRatZzoRft//5xOa69/1iGJRBlrieH6QYrkKLIFn3m7OVEJ81dSrKoy2BnKsdbX5cLrOispZNYo9v2w==
version "1.0.30001457"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001457.tgz#6af34bb5d720074e2099432aa522c21555a18301"
integrity sha512-SDIV6bgE1aVbK6XyxdURbUE89zY7+k1BBBaOwYwkNCglXlel/E7mELiHC64HQ+W0xSKlqWhV9Wh7iHxUjMs4fA==

capture-exit@^2.0.0:
version "2.0.0"
Expand Down Expand Up @@ -6749,11 +6749,11 @@ core-js-compat@^3.21.0, core-js-compat@^3.22.1:
semver "7.0.0"

core-js-compat@^3.25.1:
version "3.27.2"
resolved "https://registry.yarnpkg.com/core-js-compat/-/core-js-compat-3.27.2.tgz#607c50ad6db8fd8326af0b2883ebb987be3786da"
integrity sha512-welaYuF7ZtbYKGrIy7y3eb40d37rG1FvzEOfe7hSLd2iD6duMDqUhRfSvCGyC46HhR6Y8JXXdZ2lnRUMkPBpvg==
version "3.28.0"
resolved "https://registry.yarnpkg.com/core-js-compat/-/core-js-compat-3.28.0.tgz#c08456d854608a7264530a2afa281fadf20ecee6"
integrity sha512-myzPgE7QodMg4nnd3K1TDoES/nADRStM8Gpz0D6nhkwbmwEnE0ZGJgoWsvQ722FR8D7xS0n0LV556RcEicjTyg==
dependencies:
browserslist "^4.21.4"
browserslist "^4.21.5"

core-js-pure@^3.20.2:
version "3.24.0"
Expand Down Expand Up @@ -8361,9 +8361,9 @@ electron-to-chromium@^1.4.147:
integrity sha512-XaG2LpZi9fdiWYOqJh0dJy4SlVywCvpgYXhzOlZTp4JqSKqxn5URqOjbm9OMYB3aInA2GuHQiem1QUOc1yT0Pw==

electron-to-chromium@^1.4.284:
version "1.4.295"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.295.tgz#911d5df67542bf7554336142eb302c5ec90bba66"
integrity sha512-lEO94zqf1bDA3aepxwnWoHUjA8sZ+2owgcSZjYQy0+uOSEclJX0VieZC+r+wLpSxUHRd6gG32znTWmr+5iGzFw==
version "1.4.302"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.302.tgz#5770646ffe7051677b489226144aad9386d420f2"
integrity sha512-Uk7C+7aPBryUR1Fwvk9VmipBcN9fVsqBO57jV2ZjTm+IZ6BMNqu7EDVEg2HxCNufk6QcWlFsBkhQyQroB2VWKw==

elliptic@^6.0.0:
version "6.5.1"
Expand Down Expand Up @@ -18416,9 +18416,9 @@ regexpu-core@^5.1.0:
unicode-match-property-value-ecmascript "^2.0.0"

regexpu-core@^5.2.1:
version "5.3.0"
resolved "https://registry.yarnpkg.com/regexpu-core/-/regexpu-core-5.3.0.tgz#4d0d044b76fedbad6238703ae84bfdedee2cf074"
integrity sha512-ZdhUQlng0RoscyW7jADnUZ25F5eVtHdMyXSb2PiwafvteRAOJUjFoUPEYZSIfP99fBIs3maLIRfpEddT78wAAQ==
version "5.3.1"
resolved "https://registry.yarnpkg.com/regexpu-core/-/regexpu-core-5.3.1.tgz#66900860f88def39a5cb79ebd9490e84f17bcdfb"
integrity sha512-nCOzW2V/X15XpLsK2rlgdwrysrBq+AauCn+omItIz4R1pIcmeot5zvjdmOBRLzEH/CkC6IxMJVmxDe3QcMuNVQ==
dependencies:
"@babel/regjsgen" "^0.8.0"
regenerate "^1.4.2"
Expand Down

0 comments on commit 0eb444b

Please sign in to comment.