-
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: Convert text-sets
package
#12274
Merged
Merged
Changes from 18 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
a18878f
First type at converting to typescript for text sets.
spacedmonkey 8543fb5
Fixes.
spacedmonkey 9b4d600
Merge branch 'main' into feature/text-sets
spacedmonkey 95e9135
Merge branch 'main' into feature/text-sets
spacedmonkey 7209133
Change order.
spacedmonkey 97c8de2
Merge branch 'main' into feature/text-sets
spacedmonkey 76964ae
Merge branch 'main' into feature/text-sets
spacedmonkey b8a5983
Merge branch 'main' into feature/text-sets
spacedmonkey 65a2cbc
Fixes.
spacedmonkey 25d20a8
Fix lints and typing.
spacedmonkey e30554b
Merge branch 'main' into feature/text-sets
spacedmonkey 909a194
Merge branch 'main' into feature/text-sets
spacedmonkey 22491fa
Change type name.
spacedmonkey 02bbe8e
Merge branch 'main' into feature/text-sets
spacedmonkey 77e387f
Add references.
spacedmonkey e99fad8
Improve logic.
spacedmonkey 42f7603
Infer some types.
spacedmonkey ef56344
More infered some types.
spacedmonkey ed4be89
Cleaner `loadTextSets` function.
spacedmonkey 9f30175
Merge branch 'main' into feature/text-sets
spacedmonkey e255104
Fix lint.
spacedmonkey 366b793
Merge branch 'main' into feature/text-sets
spacedmonkey 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
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,64 @@ | ||
/* | ||
* 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. | ||
*/ | ||
/** | ||
* External dependencies | ||
*/ | ||
import type { Page, Story, Element } from '@googleforcreators/types'; | ||
|
||
export interface TextSetData extends Omit<Story, 'pages'> { | ||
current: null; | ||
selection: never[]; | ||
story: Record<string, never>; | ||
version: number; | ||
pages: TextSetPage[]; | ||
} | ||
|
||
export interface TextSetPage extends Page { | ||
fonts: string[]; | ||
id: string; | ||
} | ||
|
||
export interface MinMax { | ||
minX: number; | ||
maxX: number; | ||
minY: number; | ||
maxY: number; | ||
} | ||
|
||
export interface TextSetElement extends Element { | ||
normalizedOffsetX: number; | ||
normalizedOffsetY: number; | ||
textSetWidth: number; | ||
textSetHeight: number; | ||
} | ||
|
||
export interface TextSet { | ||
id: string; | ||
elements: TextSetElement[]; | ||
textSetCategory: string; | ||
textSetFonts: string[]; | ||
} | ||
|
||
export interface TextSets { | ||
cover: TextSet[]; | ||
step: TextSet[]; | ||
section_header: TextSet[]; | ||
editorial: TextSet[]; | ||
contact: TextSet[]; | ||
table: TextSet[]; | ||
list: TextSet[]; | ||
quote: TextSet[]; | ||
} |
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" }, { "path": "../types" }], | ||
"include": ["src/**/*"] | ||
barklund marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} |
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.
as
is a rather crude tool that should only be applied if no better tool exists, as it will actually ignore and suppress some potential errors. However, moving it to a typed variable or just setting the return type won't do the trick, becausefromEntries
doesn't play nice (typed as returningany
).This required updating the type system a bit as:
And then
loadTextSets
becomes:The
Partial<>
is a bit annoying but I don't see a clean way around it? I feel this is cleaner, but it's probably just a nit really.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 I am honest, I don't find your code easier to read or understand. I have pushed up my own version of the code, that is a little easier to follow. See ed4be89
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.
@barklund Can you take a look ?