-
Notifications
You must be signed in to change notification settings - Fork 105
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
Fix/address left config typing issues #27
Conversation
casaper
commented
Nov 22, 2020
•
edited
Loading
edited
- Add @type definitions for svg2ttf and ttf2woff2
- fix generator woff2 to use ttf2woff2 according to type definition
- remove these two declarations in "src/types/modules" and add the rest that are still there to the tsconfig.json
- replace custom type declarations with @types packages for ttf2eot, ttf2woff and svgicons2svgfont
- simplify RunnerOptions to one interface optional properties instead of merging another type with required properties as Optional properties... the concept was just a bit complicated, when typescript actually does optional properties on an interface so well 😉
eedda71
to
502b218
Compare
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.
Thank you so much for taking the time to get these typings published 🙏 looks good, just a couple comments (I think the type changes to Partial
is the most important)
src/constants.ts
Outdated
import { FontAssetType, OtherAssetType } from './types/misc'; | ||
|
||
export const TEMPLATES_DIR = resolve(__dirname, '../templates'); | ||
|
||
export const DEFAULT_OPTIONS: RunnerOptionalOptions = { | ||
export const DEFAULT_OPTIONS: Partial<RunnerOptions> = { |
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.
The reason I had split the optional options was to ensure that as they grew or changed this const definition would break if any of these default options was missing. This looks cleaner, but is less safe (as I could just comment out for example name
from defaults)
The Options are not nullable / can't be undefined when they get to the generator, optional just means they come from default values rather than necessarily user input.
Hence Partial
doesn't quite serve the same purpose here. Make sense?
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.
It frankly is a bit too far back in time. I don't remember what my reasons were here, and I currently do not have the time to dig into this problem. Perhaps in a week or two.
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.
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.
Lots of good work in this PR just wished this was a separate PR as it was a bit off scope here and made it difficult more me to review / merge (sorry for taking lots of time) as I care about keeping option types very very explicit and controllable - reverted just this and made a few additions here and there :)
(({ | ||
formatOptions: { [FontAssetType.WOFF2]: woffOptions } | ||
} as unknown) as FontGeneratorOptions); | ||
(({} as unknown) as FontGeneratorOptions); |
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 are we removing the woff options mock from tests? They check that the generator options are correctly passed to the font generator.
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.
Hello @tancredi
Fiddling in these @types/ definitions I discovered that ttf2woff2 does not have such options. For unknown rason it used to work, but anyhow, the lib will not process and do anything with it. So I removed the options from the font options type, and this spec conflicted with that fix. It expected the non-existent font option to be passable.
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.
Yes, I verified that now. It is definiteley because I found out taht ttf2woff2 simply does not have any such second param.
See:
https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/ttf2woff2/index.d.ts#L8
And in TTF2WOFF2 itself:
https://github.com/nfroidure/ttf2woff2/blob/master/jssrc/index.js#L5
No second param there...
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 great to know! I've removed some other unnecessary format options from the types! cheers
…itions and add the rest of the declarations to the tsconfig
And the metadata will be inherited from the ttf anyhow
- no more joins of multiple times and duplicates - the optional properties are real type script optional properties - the templates object allows only template paths for actually possible templateable formats
Replacing the custom declarations for external packages with fresh @types: - @types/svgicons2svgfont - @types/ttf2eot - @types/ttf2woff
59d58a7
to
e0e692a
Compare
🎉 This PR is included in version 1.0.31 🎉 The release is available on: Your semantic-release bot 📦🚀 |