-
Notifications
You must be signed in to change notification settings - Fork 178
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 Conversion: media, units, react packages #12127
Conversation
Plugin builds for 5cee7a0 are ready 🛎️!
|
resolve(blob, 'image/jpeg'); | ||
}); | ||
resolve(blob); | ||
}, 'image/jpeg'); |
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.
We've never spotted this bug before
b2a29a6
to
0fa250f
Compare
Looking really solid |
@@ -19,6 +19,14 @@ | |||
*/ | |||
import { FULLBLEED_HEIGHT, PAGE_WIDTH } from '@googleforcreators/units'; |
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 Could not find a declaration file for module '@googleforcreators/units'.
error has been nagging me for a while now and can't figure out why it's not working 🤔
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.
Curious, what was the issue?
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.
That's the thing, I couldn't figure it out properly. Probably just some tsconfig misconfiguration somewhere, basically it did not like importing from this non-TS package. That's why I ended up just converting the units
package to TypeScript 🙃
For next time it would be great to resolve though. If you have any ideas, PLMK
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.
Looking great!
Use use-reduction directly Remove resize-observer-polyfill due to typing conflict, plus it should not be needed anymore anyway
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 assuming the failing Karma tests are just flaky (re-running). Lots of files to go through so would be great if someone else would review as well.
@@ -19,6 +19,14 @@ | |||
*/ | |||
import { FULLBLEED_HEIGHT, PAGE_WIDTH } from '@googleforcreators/units'; |
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.
Curious, what was the issue?
# Conflicts: # packages/media/src/getCanvasBlob.ts
Context
This is part of our ongoing effort to convert (parts of) our codebase to TypeScript. See #1715 for details.
Summary
This marks the first step of migrating the
media
package to TypeScript, unblocking better typing usage in all consumer packages relying on it.Due to my struggles with
Could not find a declaration file for module ...
errors, I also ended up converting theunits
andreact
packages (which are dependencies) to React.Figured I'll keep everything in this one PR since it seemed so intertwined.
Success story:
Relevant Technical Choices
shallow-equal
moduleWEB_STORIES_ENV
useReduction
fork in favor of theuse-reduction
package directly.Adapts Jest config to transpile
use-reduction
package because it's using ESMResizeObserver
polyfill. Ran into Typings collide with Typescripts DOM typings for ResizeObserver que-etc/resize-observer-polyfill#83 and figured we probably don't need this anymore anyway due to improved browser support.To-do
Element
type from a shared package (elements
package?)typings
folderCould not find a declaration file for module ...
errors so we can better convert packages one at a time.UnitsProvider
anduseUnits
anduseContextSelector
User-facing changes
N/A
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 #12087