Skip to content

Pathway to getting rid of hand-crafted .d.ts files #7402

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

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
71a7065
refactor: add tsconfig to each package
fgnass Feb 12, 2025
edabf73
refactor: use references instead of path aliases
fgnass Feb 12, 2025
0834623
refactor: gitignore tsconfig.tsbuildinfo files
fgnass Feb 12, 2025
e549dd3
feat: add "types" to each package
fgnass Feb 12, 2025
ca80a24
fix: add missing types
fgnass Feb 12, 2025
a3810d2
fix: match generated js types
fgnass Feb 12, 2025
9b31a12
fix: add missing tsconfig
fgnass Feb 12, 2025
c80339e
fix: add type assertion
fgnass Feb 12, 2025
2feef87
fix: skip lib check
fgnass Feb 12, 2025
e47ad2d
chore: clean .tsbuildinfo files
fgnass Feb 12, 2025
db775f6
chore: don't lint files in dist
fgnass Feb 12, 2025
1726b75
fix: add types field
fgnass Feb 12, 2025
70f7e99
fix: move test-helpers into typescript root
fgnass Feb 12, 2025
41b2fef
fix: move test-helpers so they are under the typescript root dir
fgnass Feb 12, 2025
2b79806
fix: move stega util to decap-cms-core
fgnass Feb 12, 2025
e5e8a28
refactor: turn index into ts file and export public types
fgnass Feb 12, 2025
e0e1174
fix: use relative path to import type from same package
fgnass Feb 12, 2025
2721762
fix: make root type-check script work
fgnass Feb 12, 2025
625e6c1
chore: update lockfile
fgnass Feb 12, 2025
bf478ae
style: apply prettier
fgnass Feb 12, 2025
ac3be1b
fix: allow explicit any
fgnass Feb 12, 2025
472d4cc
fix: remove duplicate field
fgnass Feb 12, 2025
a0a2907
fix: generate index.d.ts from typescript source
fgnass Feb 12, 2025
b400616
fix: don't run type-check before build
fgnass Feb 12, 2025
0320aa5
fix: move test-helpers out of __tests__ folder
fgnass Feb 12, 2025
c146dcb
fix: import missing JSX namespace
fgnass Feb 23, 2025
e55b4d1
fix: add missing --extensions flag to babel
fgnass Feb 23, 2025
b365ea6
fix: add visualEditing prop to types
fgnass Feb 23, 2025
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
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,5 @@ module.exports = {
},
},
],
ignorePatterns: ['**/dist/**'],
};
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ coverage/
.temp/
storybook-static/
.nx/cache
tsconfig.tsbuildinfo
28 changes: 28 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
"build:esm": "nx run-many -t build:esm",
"build:demo": "npm run build && ncp packages/decap-cms/dist dev-test/dist/",
"build-preview": "npm run build && nx run decap-cms:build-preview --output-style=stream",
"type-check": "tsc --noEmit",
"type-check": "tsc --build",
"type-check:watch": "npm run type-check -- --watch",
"clean": "rimraf \"packages/*/dist\" dev-test/dist \"packages/*/node_modules\" \".nx/cache\"",
"clean": "rimraf \"packages/*/dist\" dev-test/dist \"packages/*/node_modules\" \".nx/cache\" \"packages/*/tsconfig.tsbuildinfo\"",
"reset": "npm run clean",
"test": "npm run lint && npm run type-check && npm run test:unit",
"test:all": "npm run test && npm run test:e2e",
"test:ci": "npm run lint-quiet && npm run type-check && npm run test:unit",
"test:ci": "npm run lint-quiet && npm run test:unit",
"test:unit": "cross-env NODE_ENV=test jest --no-cache",
"test:e2e": "npm run build:demo && npm run test:e2e:run",
"test:e2e:ci": "npm run build:demo && npm run test:e2e:run-ci",
Expand Down
7 changes: 0 additions & 7 deletions packages/decap-cms-app/index.d.ts

This file was deleted.

8 changes: 5 additions & 3 deletions packages/decap-cms-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,20 @@
"repository": "https://github.com/decaporg/decap-cms/tree/main/packages/decap-cms-app",
"bugs": "https://github.com/decaporg/decap-cms/issues",
"module": "dist/esm/index.js",
"types": "dist/esm/index.d.ts",
"main": "dist/decap-cms-app.js",
"files": [
"src/",
"dist/",
"index.d.ts"
],
"types": "index.d.ts",
"scripts": {
"develop": "npm run build:esm -- --watch",
"webpack": "node --max_old_space_size=4096 ../../node_modules/webpack/bin/webpack.js",
"build": "cross-env NODE_ENV=production run-s webpack",
"build:esm": "cross-env NODE_ENV=esm babel src --out-dir dist/esm --ignore \"**/__tests__\" --root-mode upward"
"build": "cross-env NODE_ENV=production webpack",
"build:esm": "run-p build:types build:babel",
"build:babel": "cross-env NODE_ENV=esm babel src --out-dir dist/esm --ignore \"**/__tests__\" --root-mode upward --extensions \".js,.jsx,.ts,.tsx\"",
"build:types": "tsc"
},
"keywords": [
"cms",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import { DecapCmsCore as CMS } from 'decap-cms-core';
import './extensions.js';

export * from 'decap-cms-core';

declare global {
// This is not really a global but a literal injected by babel
const DECAP_CMS_APP_VERSION: string;
}

// Log version
if (typeof window !== 'undefined') {
if (typeof DECAP_CMS_APP_VERSION === 'string') {
Expand Down
10 changes: 10 additions & 0 deletions packages/decap-cms-app/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"composite": true,
"outDir": "./dist/esm",
"rootDir": "./src"
},
"include": ["src/**/*"],
"exclude": ["**/*.spec.ts", "**/*.test.ts"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"repository": "https://github.com/decaporg/decap-cms/tree/main/packages/decap-cms-backend-aws-cognito-github-proxy",
"bugs": "https://github.com/decaporg/decap-cms/issues",
"module": "dist/esm/index.js",
"types": "dist/esm/index.d.ts",
"main": "dist/decap-cms-backend-aws-cognito-github-proxy.js",
"keywords": [
"decap-cms",
Expand All @@ -17,7 +18,9 @@
"scripts": {
"develop": "npm run build:esm -- --watch",
"build": "cross-env NODE_ENV=production webpack",
"build:esm": "cross-env NODE_ENV=esm babel src --out-dir dist/esm --ignore **/__tests__ --root-mode upward --extensions \".js,.jsx,.ts,.tsx\""
"build:esm": "run-p build:types build:babel",
"build:babel": "cross-env NODE_ENV=esm babel src --out-dir dist/esm --ignore \"**/__tests__\" --root-mode upward --extensions \".js,.jsx,.ts,.tsx\"",
"build:types": "tsc"
},
"dependencies": {
"apollo-cache-inmemory": "^1.6.2",
Expand All @@ -40,5 +43,8 @@
"lodash": "^4.17.11",
"prop-types": "^15.7.2",
"react": "^18.2.0"
},
"devDependencies": {
"@types/semaphore": "^1.1.4"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"composite": true,
"outDir": "./dist/esm",
"rootDir": "./src"
},
"include": ["src/**/*"],
"exclude": ["**/*.spec.ts", "**/*.test.ts"]
}
8 changes: 7 additions & 1 deletion packages/decap-cms-backend-azure/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"repository": "https://github.com/decaporg/decap-cms/tree/main/packages/decap-cms-backend-azure",
"bugs": "https://github.com/decaporg/decap-cms/issues",
"module": "dist/esm/index.js",
"types": "dist/esm/index.d.ts",
"main": "dist/decap-cms-backend-azure.js",
"keywords": [
"decap-cms",
Expand All @@ -17,7 +18,9 @@
"scripts": {
"develop": "npm run build:esm -- --watch",
"build": "cross-env NODE_ENV=production webpack",
"build:esm": "cross-env NODE_ENV=esm babel src --out-dir dist/esm --ignore **/__tests__ --root-mode upward --extensions \".js,.jsx,.ts,.tsx\""
"build:esm": "run-p build:types build:babel",
"build:babel": "cross-env NODE_ENV=esm babel src --out-dir dist/esm --ignore \"**/__tests__\" --root-mode upward --extensions \".js,.jsx,.ts,.tsx\"",
"build:types": "tsc"
},
"dependencies": {
"js-base64": "^3.0.0",
Expand All @@ -33,5 +36,8 @@
"lodash": "^4.17.11",
"prop-types": "^15.7.2",
"react": "^18.2.0"
},
"devDependencies": {
"@types/semaphore": "^1.1.4"
}
}
10 changes: 10 additions & 0 deletions packages/decap-cms-backend-azure/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"composite": true,
"outDir": "./dist/esm",
"rootDir": "./src"
},
"include": ["src/**/*"],
"exclude": ["**/*.spec.ts", "**/*.test.ts"]
}
8 changes: 7 additions & 1 deletion packages/decap-cms-backend-bitbucket/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"repository": "https://github.com/decaporg/decap-cms/tree/main/packages/decap-cms-backend-bitbucket",
"bugs": "https://github.com/decaporg/decap-cms/issues",
"module": "dist/esm/index.js",
"types": "dist/esm/index.d.ts",
"main": "dist/decap-cms-backend-bitbucket.js",
"license": "MIT",
"keywords": [
Expand All @@ -16,7 +17,9 @@
"scripts": {
"develop": "npm run build:esm -- --watch",
"build": "cross-env NODE_ENV=production webpack",
"build:esm": "cross-env NODE_ENV=esm babel src --out-dir dist/esm --ignore \"**/__tests__\" --root-mode upward --extensions \".js,.jsx,.ts,.tsx\""
"build:esm": "run-p build:types build:babel",
"build:babel": "cross-env NODE_ENV=esm babel src --out-dir dist/esm --ignore \"**/__tests__\" --root-mode upward --extensions \".js,.jsx,.ts,.tsx\"",
"build:types": "tsc"
},
"dependencies": {
"common-tags": "^1.8.0",
Expand All @@ -34,5 +37,8 @@
"lodash": "^4.17.11",
"prop-types": "^15.7.2",
"react": "^18.2.0"
},
"devDependencies": {
"@types/semaphore": "^1.1.4"
}
}
6 changes: 5 additions & 1 deletion packages/decap-cms-backend-bitbucket/src/API.ts
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,11 @@ export default class API {
branch: filesBranch,
parseText: false,
});
formData.append(file.path.replace(sourceDir, destDir), content, basename(file.path));
formData.append(
file.path.replace(sourceDir, destDir),
content as Blob,
basename(file.path),
);
}
}

Expand Down
14 changes: 9 additions & 5 deletions packages/decap-cms-backend-bitbucket/src/implementation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export default class BitbucketBackend implements Implementation {
}

async status() {
const api = await fetch(BITBUCKET_STATUS_ENDPOINT)
const api = await fetch(BITBUCKET_STATUS_ENDPOINT, undefined)
.then(res => res.json())
.then(res => {
return res['components']
Expand Down Expand Up @@ -272,10 +272,14 @@ export default class BitbucketBackend implements Implementation {
this.authenticator = new NetlifyAuthenticator(cfg);
}

this.refreshedTokenPromise = this.authenticator!.refresh({
provider: 'bitbucket',
refresh_token: this.refreshToken as string,
}).then(({ token, refresh_token }) => {
this.refreshedTokenPromise = this.authenticator!.refresh(
{
provider: 'bitbucket',
refresh_token: this.refreshToken as string,
},
undefined,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
).then(({ token, refresh_token }: any) => {
this.token = token;
this.refreshToken = refresh_token;
this.refreshedTokenPromise = undefined;
Expand Down
10 changes: 10 additions & 0 deletions packages/decap-cms-backend-bitbucket/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"composite": true,
"outDir": "./dist/esm",
"rootDir": "./src"
},
"include": ["src/**/*"],
"exclude": ["**/*.spec.ts", "**/*.test.ts"]
}
5 changes: 4 additions & 1 deletion packages/decap-cms-backend-git-gateway/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"repository": "https://github.com/decaporg/decap-cms/tree/main/packages/decap-cms-backend-git-gateway",
"bugs": "https://github.com/decaporg/decap-cms/issues",
"module": "dist/esm/index.js",
"types": "dist/esm/index.d.ts",
"main": "dist/decap-cms-backend-git-gateway.js",
"license": "MIT",
"keywords": [
Expand All @@ -17,7 +18,9 @@
"scripts": {
"develop": "npm run build:esm -- --watch",
"build": "cross-env NODE_ENV=production webpack",
"build:esm": "cross-env NODE_ENV=esm babel src --out-dir dist/esm --ignore \"**/__tests__\" --root-mode upward --extensions \".js,.jsx,.ts,.tsx\""
"build:esm": "run-p build:types build:babel",
"build:babel": "cross-env NODE_ENV=esm babel src --out-dir dist/esm --ignore \"**/__tests__\" --root-mode upward --extensions \".js,.jsx,.ts,.tsx\"",
"build:types": "tsc"
},
"dependencies": {
"gotrue-js": "^0.9.24",
Expand Down
10 changes: 10 additions & 0 deletions packages/decap-cms-backend-git-gateway/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"composite": true,
"outDir": "./dist/esm",
"rootDir": "./src"
},
"include": ["src/**/*"],
"exclude": ["**/*.spec.ts", "**/*.test.ts"]
}
8 changes: 7 additions & 1 deletion packages/decap-cms-backend-gitea/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"bugs": "https://github.com/decaporg/decap-cms/issues",
"license": "MIT",
"module": "dist/esm/index.js",
"types": "dist/esm/index.d.ts",
"main": "dist/decap-cms-backend-gitea.js",
"keywords": [
"decap-cms",
Expand All @@ -16,7 +17,9 @@
"scripts": {
"develop": "npm run build:esm -- --watch",
"build": "cross-env NODE_ENV=production webpack",
"build:esm": "cross-env NODE_ENV=esm babel src --out-dir dist/esm --ignore \"**/__tests__\" --root-mode upward --extensions \".js,.jsx,.ts,.tsx\""
"build:esm": "run-p build:types build:babel",
"build:babel": "cross-env NODE_ENV=esm babel src --out-dir dist/esm --ignore \"**/__tests__\" --root-mode upward --extensions \".js,.jsx,.ts,.tsx\"",
"build:types": "tsc"
},
"dependencies": {
"js-base64": "^3.0.0",
Expand All @@ -32,5 +35,8 @@
"lodash": "^4.17.11",
"prop-types": "^15.7.2",
"react": "^18.2.0"
},
"devDependencies": {
"@types/semaphore": "^1.1.4"
}
}
Loading