Skip to content

fix(#7410): add proper typings for registerWidget and CmsBackendClass #7411

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

Open
wants to merge 25 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
250c212
fix: emit types for every package
fgnass Feb 24, 2025
1419cae
fix(#7410): migrate registry to typescript
fgnass Feb 24, 2025
1b5083b
fix: move type guards into core too
fgnass Feb 13, 2025
cbdb932
fix: properly type getI18nDefaults
fgnass Feb 24, 2025
045b8cd
fix: promised type is void not undefined
fgnass Feb 24, 2025
724141c
fix: add a type assertion, collection keys are always strings
fgnass Feb 24, 2025
b4c4d60
fix: allow empty state objects
fgnass Feb 24, 2025
220912f
fix: properly type getGroup
fgnass Feb 24, 2025
fbdaf82
fix: properly type CmsBackendClass and CmsRegistryBackend
fgnass Feb 24, 2025
a6afcd5
Revert "fix: properly type getI18nDefaults"
fgnass Feb 24, 2025
55ce259
fix: correctly handle i18n being a boolean
fgnass Feb 24, 2025
5fedc9d
fix: update typescript for better type inference
fgnass Feb 24, 2025
ce460fd
refactor: convert files to ts
fgnass Feb 26, 2025
4e02c9f
fix: move exclude to base and ignore .js tests too
fgnass Feb 26, 2025
57fc57f
fix: repoFilesUnpublished is a record not an array
fgnass Feb 26, 2025
fe48b18
fix: properly declare commitAutor in base class
fgnass Feb 26, 2025
baa4f6f
fix: editor-component depends on core not vice versa
fgnass Feb 26, 2025
cabbe63
fix: let types match the actual implementation
fgnass Feb 26, 2025
a292ab7
fix: properly type editor-component-image
fgnass Feb 26, 2025
b6c42a8
fix: make core a dev dependency
fgnass Feb 26, 2025
c0a912d
fix: reflect the file renaming
fgnass Feb 26, 2025
9fb0807
fix: type is the constructor, not the impl
fgnass Feb 26, 2025
92dcb91
fix: widgets may have only subset of props
fgnass Feb 26, 2025
512e7d6
chore: update lockfile
fgnass Feb 26, 2025
99d914c
fix: match the actual implementation type
fgnass Feb 27, 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
2 changes: 2 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ module.exports = {
rules: {
'no-duplicate-imports': [0], // handled by @typescript-eslint
'@typescript-eslint/ban-types': [0], // TODO enable in future
'@typescript-eslint/no-explicit-any': [0], // TODO enable in future
'@typescript-eslint/no-non-null-assertion': [0],
'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/explicit-function-return-type': [0],
Expand All @@ -102,4 +103,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
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = {
'decap-cms-ui-default': '<rootDir>/packages/decap-cms-ui-default/src/index.js',
'decap-cms-backend-github': '<rootDir>/packages/decap-cms-backend-github/src/index.ts',
'decap-cms-lib-widgets': '<rootDir>/packages/decap-cms-lib-widgets/src/index.ts',
'decap-cms-widget-object': '<rootDir>/packages/decap-cms-widget-object/src/index.js',
'decap-cms-widget-object': '<rootDir>/packages/decap-cms-widget-object/src/index.ts',
'\\.(css|less)$': '<rootDir>/__mocks__/styleMock.js',
},
snapshotSerializers: ['@emotion/jest/serializer'],
Expand Down
54 changes: 48 additions & 6 deletions package-lock.json

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

8 changes: 4 additions & 4 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 Expand Up @@ -141,7 +141,7 @@
"stylelint-processor-styled-components": "^1.10.0",
"svg-inline-loader": "^0.8.0",
"to-string-loader": "^1.1.5",
"typescript": "^4.9.4",
"typescript": "^5.3.0",
"unist-util-visit": "^1.4.0",
"webpack": "^5.75.0",
"webpack-cli": "^5.0.1",
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
9 changes: 9 additions & 0 deletions packages/decap-cms-app/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"composite": true,
"outDir": "./dist/esm",
"rootDir": "./src"
},
"include": ["src/**/*"]
}
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,9 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"composite": true,
"outDir": "./dist/esm",
"rootDir": "./src"
},
"include": ["src/**/*"]
}
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"
}
}
9 changes: 9 additions & 0 deletions packages/decap-cms-backend-azure/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"composite": true,
"outDir": "./dist/esm",
"rootDir": "./src"
},
"include": ["src/**/*"]
}
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
Loading