-
Notifications
You must be signed in to change notification settings - Fork 177
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
Convert transform
package to TypeScript
#12202
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
3b456d1
Rename files.
miina 1bbaa4f
TS updates
miina d0bd283
More updates
miina dc0cc98
Lint
miina 8d52081
Add all state values
miina 65841b8
Merge remote-tracking branch 'origin/main' into add/12173-typescript-…
miina f91a0b8
Adjust useTransform
miina 5001227
Revert to generic
miina 837862e
Attempted ts fix
90e367b
Attempted more ts fixes
178e98d
Merge remote-tracking branch 'origin/main' into add/12173-typescript-…
miina 4409765
Add types to package.json
miina 684e7e3
Use DependencyList for deps
miina 95885f9
Merge remote-tracking branch 'origin/main' into add/12173-typescript-…
miina c1c5ff1
Merge branch 'main' into add/12173-typescript-transform
swissspidy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright 2022 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
export type TransformHandler = (frame: object | null) => void; | ||
export type HandlerRegister = ( | ||
id: string, | ||
handler: TransformHandler | ||
) => () => void; | ||
|
||
export type HandlersList = Record<string, TransformHandler[]>; | ||
|
||
export type TransformsList = Record<string, Record<string, unknown> | null>; | ||
|
||
export interface Transform { | ||
staticTransformation: boolean; | ||
} | ||
|
||
export type PushTransform = (id: string, transform: Transform) => void; | ||
export type ClearTransform = () => void; | ||
|
||
export interface State { | ||
actions: { | ||
registerTransformHandler?: HandlerRegister; | ||
pushTransform?: PushTransform; | ||
clearTransforms?: ClearTransform; | ||
}; | ||
state: { | ||
isAnythingTransforming?: boolean; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"extends": "../../tsconfig.shared.json", | ||
"compilerOptions": { | ||
"rootDir": "src", | ||
"declarationDir": "dist-types" | ||
}, | ||
"references": [{ "path": "../react" }], | ||
"include": ["src/**/*"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@swissspidy Do you happen to have a good example of creating a context with actions and state that I could check? Not sure exactly how to do this here, had to use type casting which doesn't seem right here. Or is this an example of the
useContextSelector
that might still need work (since it's all related to that, and has to match the typing of the context selector)?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 far I only attempted this in
packages/units/src/context.ts
/packages/units/src/contextProvider.tsx
but yeah it still needs some work to get type support when usinguseContextSelector
.This might do the trick though:
https://github.com/GoogleForCreators/web-stories-wp/tree/try/fix-context-state
This way I get type support when doing something like
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.
Hm, not sure if I did something incorrectly but I still have to assign types in the provider for it not to throw errors.