This repository has been archived by the owner on Feb 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 63
Make MediaService generic #868
Closed
sarayourfriend
wants to merge
1
commit into
refactor_media_services
from
refactor_media_services-add_types
Closed
Changes from all commits
Commits
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,45 @@ | ||
export const CC_LICENSES = [ | ||
export const CC_LICENSES = /** @type {const} */ ([ | ||
'by', | ||
'by-sa', | ||
'by-nd', | ||
'by-nc', | ||
'by-nc-sa', | ||
'by-nc-nd', | ||
] | ||
]) | ||
|
||
/** | ||
* @template T | ||
* @typedef {T extends `${infer P}-${infer PP}-${infer PPP}` ? [P, PP, PPP] : T extends `${infer P}-${infer PP}` ? [P, PP] : [T]} PartitionLicense | ||
*/ | ||
|
||
/** @typedef {PartitionLicense<CCLicense>[number]} LicensePart */ | ||
Comment on lines
+10
to
+15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is just me being kind of silly with TS string types. We could just as easily (and probably should just) use a type directly as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tend to agree with your comment 😆 I mean it looks very interesting, but it would probably take me years to understand what it means :) |
||
|
||
/** @typedef {typeof CC_LICENSES[number]} CCLicense */ | ||
|
||
export const NON_CC_LICENSES = /** @type {const} */ (['cc0', 'pdm']) | ||
|
||
export const NON_CC_LICENSES = ['cc0', 'pdm'] | ||
/** @typedef {typeof NON_CC_LICENSES[number]} NonCCLicense */ | ||
|
||
export const DEPRECATED_LICENSES = ['nc-sampling+', 'sampling+'] | ||
export const DEPRECATED_LICENSES = /** @type {const} */ ([ | ||
'nc-sampling+', | ||
'sampling+', | ||
]) | ||
|
||
/** @typedef {typeof DEPRECATED_LICENSES[number]} DeprecatedLicense */ | ||
|
||
export const ALL_LICENSES = [ | ||
...CC_LICENSES, | ||
...NON_CC_LICENSES, | ||
...DEPRECATED_LICENSES, | ||
] | ||
|
||
/** @typedef {typeof ALL_LICENSES[number]} License */ | ||
|
||
export const MARKS = /** @type {const} */ (['cc0', 'pdm']) | ||
|
||
/** @typedef {typeof MARKS[number]} Mark */ | ||
|
||
/** @type {Record<LicensePart | Mark, string>} */ | ||
export const LICENSE_ICON_MAPPING = { | ||
by: 'by', | ||
nc: 'nc', | ||
|
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
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
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.
@sarayourfriend , can you give me a reference I can read about the
type {const}
declaration? I couldn't find anything searching fortypescript const type
.The reason I'm asking this is the messages I see in my IDEs.
WebStorm is trying to find something in the
node_modules
, I guess?VS Code just shows it as unresolved, even when I set language mode to TypeScript (I don't know what other information can I get about VS Code TS hints)
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's the JSDoc version of this feature: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-4.html#const-assertions
The TypeScript JSDoc documentation for it is here: https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html#casts (the second example in that section)
I'm not sure why TS isn't picking it up. In VSCode have you tried running the "Restart TS Service" command? I have to do that anytime
tsconfig.json
changes.For WebStorm it might be the same. You will probably also have to enable the TS language server using the instructions described here: https://www.jetbrains.com/help/webstorm/typescript-support.html#ws_ts_use_ts_service_checkbox