-
Notifications
You must be signed in to change notification settings - Fork 179
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: Convert pageDataUrls
provider
#12727
Conversation
This pull request introduces 1 alert when merging 0078336 into d01beaa - view on LGTM.com new alerts:
Heads-up: LGTM.com's PR analysis will be disabled on the 5th of December, and LGTM.com will be shut down ⏻ completely on the 16th of December 2022. Please enable GitHub code scanning, which uses the same CodeQL engine ⚙️ that powers LGTM.com. For more information, please check out our post on the GitHub blog. |
packages/story-editor/src/app/pageDataUrls/pageDataUrlsProvider.tsx
Outdated
Show resolved
Hide resolved
Plugin builds for fba8475 are ready 🛎️!
|
Size Change: +18 B (0%) Total Size: 2.71 MB ℹ️ View Unchanged
|
packages/story-editor/src/app/pageDataUrls/pageDataUrlsProvider.tsx
Outdated
Show resolved
Hide resolved
pageDataUrls
provider
tests/js/jest.config.js
Outdated
@@ -44,7 +44,7 @@ export default { | |||
// See https://jestjs.io/docs/configuration#transformignorepatterns-arraystring | |||
transformIgnorePatterns: ['/node_modules/(?!(use-reduction)/)'], | |||
testEnvironment: 'jsdom', | |||
testMatch: ['**/test/**/*.[jt]s'], | |||
testMatch: ['**/test/**/*.[jt]s?(x)'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Due to enabling .tsx files, the following tests are now failing:
https://github.com/GoogleForCreators/web-stories-wp/actions/runs/3824643543/jobs/6506964376#step:9:286
Thoughts @barklund @swissspidy?
Since it's not related to this PR, I'll just revert it back, however, these need to get fixes.
Created an issue for it: #12895 12895
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just some comments to make our efforts look more uniform across the codebase.
packages/design-system/tsconfig.json
Outdated
@@ -19,6 +19,7 @@ | |||
"src/types/*", | |||
"src/types.ts", | |||
"src/utils/*.ts", | |||
"src/utils/*.tsx", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this change if this PR doesn't actually contain any files from the design system?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh, not sure. I took this PR over, perhaps there was a .tsx file originally that was not needed anymore 🤔
Will remove this.
function PageDataUrlProvider({ children }) { | ||
const [dataUrls, setDataUrls] = useState({}); | ||
function PageDataUrlProvider({ children }: PropsWithChildren<unknown>) { | ||
const [dataUrls, setDataUrls] = useState<PageDataUrlsState['dataUrls']>({}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a big fan of this notation here. I'd rather we just made separate types for these and used those types in the state as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(also because the state only contains this one single prop)
export interface PageDataUrlsState { | ||
dataUrls: Record<string, string>; | ||
} | ||
|
||
export interface PageDataUrlsActions { | ||
queuePageImageGeneration: (Page: Page) => void; | ||
} | ||
|
||
export interface PageDataUrlsContext { | ||
state: PageDataUrlsState; | ||
actions: PageDataUrlsActions; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this would be:
export type PageDataUrls = Record<string, string>;
export type QueuePageImageGeneration: (page: Page) => void;
export interface PageDataUrlsContext {
state: { dataUrls: PageDataUrls }
actions: { queuePageImageGeneration: QueuePageImageGeneration};
}
@@ -24,7 +24,7 @@ const requestIdleCallback = | |||
return setTimeout(() => { | |||
callback({ | |||
get didTimeout() { | |||
return options.timeout | |||
return typeof options.timeout !== 'undefined' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'timeout' in options
is a bit cleaner.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If options.timeout
is undefined
but set, 'options' in timeout
would give true
though.
Context
Summary
Relevant Technical Choices
To-do
User-facing changes
Testing Instructions
This PR can be tested by following these steps:
Reviews
Does this PR have a security-related impact?
No
Does this PR change what data or activity we track or use?
No
Does this PR have a legal-related impact?
No
Checklist
Type: XYZ
label to the PRFixes #12668