Skip to content

Commit

Permalink
Social: Improve TS error reporting in publicize
Browse files Browse the repository at this point in the history
  • Loading branch information
manzoorwanijk committed Aug 29, 2024
1 parent 32ec5cc commit 12bccc8
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 6 deletions.
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Social: Improve ts error reporting in publicize
1 change: 1 addition & 0 deletions projects/js-packages/publicize-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"@testing-library/user-event": "14.5.2",
"@types/jest": "29.5.12",
"@types/react": "18.3.3",
"@types/wordpress__editor": "13.6.8",
"@types/wordpress__media-utils": "4.14.4",
"@wordpress/babel-plugin-import-jsx-pragma": "5.5.0",
"@wordpress/core-data": "7.5.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { useCallback } from '@wordpress/element';
* @return {Function} Function to handle autosaving and redirecting.
*/
export function useAutoSaveAndRedirect(): React.DOMAttributes< HTMLAnchorElement >[ 'onClick' ] {
// @ts-expect-error -- `@wordpress/editor` is a nightmare to work with TypeScript
const { isEditedPostDirty } = useSelect( editorStore, [] );
const { autosave } = useDispatch( editorStore );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ export function PostPublishShareStatus() {
const { featureFlags, postId, isPostPublised } = useSelect( select => {
const store = select( socialStore );

// eslint-disable-next-line @typescript-eslint/no-explicit-any -- `@wordpress/editor` is a nightmare to work with TypeScript
const _editorStore = select( editorStore ) as any;
const _editorStore = select( editorStore );

return {
featureFlags: store.featureFlags(),
// @ts-expect-error -- `@wordpress/editor` is a nightmare to work with TypeScript
postId: _editorStore.getCurrentPostId(),
// @ts-expect-error -- `@wordpress/editor` is a nightmare to work with TypeScript
isPostPublised: _editorStore.isCurrentPostPublished(),
};
}, [] );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ export function ShareStatus( { postId }: ShareStatusProps ) {

// Whether the post has been published more than one minute ago.
const hasBeenMoreThanOneMinute = useSelect( select => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- `@wordpress/editor` is a nightmare to work with TypeScript
const date = ( select( editorStore ) as any ).getEditedPostAttribute( 'date' );
// @ts-expect-error -- `@wordpress/editor` is a nightmare to work with TypeScript
const date = select( editorStore ).getEditedPostAttribute( 'date' );

const oneMinuteAfterPostDate = new Date( Number( getDate( date ) ) + ONE_MINUTE_IN_MS );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ import { useEffect, useRef, useState } from '@wordpress/element';
*/
export function usePostPrePublishValue< V >( value: V ) {
const isPublishing = useSelect(
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- `@wordpress/editor` is a nightmare to work with TypeScript
select => ( select( editorStore ) as any ).isPublishingPost(),
// @ts-expect-error -- `@wordpress/editor` is a nightmare to work with TypeScript

select => select( editorStore ).isPublishingPost(),
[]
);

Expand Down

0 comments on commit 12bccc8

Please sign in to comment.