Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

refactor(types): enhance type system#1299

Merged
mydearxym merged 4 commits intodevfromenhance-ts-types
Apr 27, 2022
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions.eslintrc.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,6 +8,8 @@ module.exports = {
'@groupher/eslint-config-web',
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
// see: https://stackoverflow.com/a/56696478/4050784
'plugin:import/typescript',
],
// extends: ['@groupher/eslint-config-web'],
settings: {
Expand Down
31 changes: 26 additions & 5 deletionspackage-lock.json
View file
Open in desktop

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

1 change: 1 addition & 0 deletionspackage.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -161,6 +161,7 @@
"shelljs": "0.8.4",
"standard-version": "^8.0.1",
"start-server-and-test": "1.12.1",
"type-fest": "^2.12.2",
"typescript": "^4.2.3"
}
}
1 change: 1 addition & 0 deletionssrc/spec/article.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -210,6 +210,7 @@ export type TUpvoteLayout =
| 'comment'
| 'article'
| 'post-list'
| 'blog-list'
| 'works-article'
| 'works-card'
| 'guide-list'
Expand Down
3 changes: 3 additions & 0 deletionssrc/spec/enhance.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
// see: https://github.com/sindresorhus/type-fest#template-literal-types
export type { ScreamingSnakeCase as SnakeUpperCase } from 'type-fest'
export type holder = 1
3 changes: 3 additions & 0 deletionssrc/spec/index.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
import type { TRootStore as RootStoreType } from '@/stores/RootStore'

import type { TArticle } from './article'
import type { TCommunity } from './community'

export type { SnakeUpperCase } from './enhance'

export type { TMetric } from './metric'
export type {
TSIZE,
Expand Down
10 changes: 7 additions & 3 deletionssrc/spec/utils.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -96,7 +96,11 @@ export type TTabItem = {

export type TResState = 'LOADING' | 'DONE' | 'EMPTY'

export type TPaymentUsage = 'SENIOR' | 'GirlsCodeTooPlan' | 'DONATE' | 'SPONSOR'
export type TPaymentUsage =
| 'SENIOR'
| 'GIRLS_CODE_TOO_PLAN'
| 'DONATE'
| 'SPONSOR'
export type TPaymentMethod = 'ALIPAY' | 'WECHAT'

export type TFlexRule =
Expand DownExpand Up@@ -183,7 +187,7 @@ export type TModelineType =
| 'search'
| 'more'

export type TGtdType = 'BUG' | 'FEATURE' |null
export type TGtdState = 'TODO' | 'WIP' | 'DONE' |null
export type TGtdType = 'BUG' | 'FEATURE' |'DEFAULT'
export type TGtdState = 'TODO' | 'WIP' | 'DONE' |'DEFAULT'

export type TTagMode = 'default' | 'label'
18 changes: 9 additions & 9 deletionsutils/constant/GTD.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
import type { TGtdType, TGtdState } from '@/spec'

export const GTD_TYPE = {
FEATURE: 'FEATURE' as TGtdType,
BUG: 'BUG' as TGtdType,
DEFAULT:null as TGtdType,
}
FEATURE: 'FEATURE',
BUG: 'BUG',
DEFAULT:'DEFAULT',
} as Record<Uppercase<TGtdType>, Uppercase<TGtdType>>

export const GTD_STATE = {
TODO: 'TODO' as TGtdState,
WIP: 'WIP' as TGtdState,
DONE: 'DONE' as TGtdState,
DEFAULT:null as TGtdState,
}
TODO: 'TODO',
WIP: 'WIP',
DONE: 'DONE',
DEFAULT:'DEFAULT',
} as Record<Uppercase<TGtdState>, Uppercase<TGtdState>>
14 changes: 7 additions & 7 deletionsutils/constant/emotion.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
import type { TEmotionType } from '@/spec'

const EMOTION = {
DOWNVOTE: 'downvote' as TEmotionType,
BEER: 'beer' as TEmotionType,
HEART: 'heart' as TEmotionType,
CONFUSED: 'confused' as TEmotionType,
POPCORN: 'popcorn' as TEmotionType,
PILL: 'pill' as TEmotionType,
}
DOWNVOTE: 'downvote',
BEER: 'beer',
HEART: 'heart',
CONFUSED: 'confused',
POPCORN: 'popcorn',
PILL: 'pill',
} as Record<Uppercase<TEmotionType>, TEmotionType>

export default EMOTION
20 changes: 10 additions & 10 deletionsutils/constant/layout.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
import type { TUpvoteLayout } from '@/spec'
import type { TUpvoteLayout, SnakeUpperCase } from '@/spec'

export const UPVOTE_LAYOUT = {
DEFAULT: 'default' as TUpvoteLayout,
COMMENT: 'comment' as TUpvoteLayout,
ARTICLE: 'article' as TUpvoteLayout,
POST_LIST: 'post-list' as TUpvoteLayout,
BLOG_LIST: 'blog-list' as TUpvoteLayout,
WORKS_ARTICLE: 'works-article' as TUpvoteLayout,
WORKS_CARD: 'works-card' as TUpvoteLayout,
GUIDE_LIST: 'guide-list' as TUpvoteLayout,
}
DEFAULT: 'default',
COMMENT: 'comment',
ARTICLE: 'article',
POST_LIST: 'post-list',
BLOG_LIST: 'blog-list',
WORKS_ARTICLE: 'works-article',
WORKS_CARD: 'works-card',
GUIDE_LIST: 'guide-list',
} as Record<SnakeUpperCase<TUpvoteLayout>, TUpvoteLayout>

export const holder = 1
44 changes: 22 additions & 22 deletionsutils/constant/metric.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,32 +2,32 @@ import type { TMetric } from '@/spec'
// NOTE: the value is mapping to @/utils/media's key
// so do not change to lowercase etc...
const METRIC = {
COMMUNITY: 'COMMUNITY' as TMetric,
USER: 'USER' as TMetric,
COMMUNITY: 'COMMUNITY',
USER: 'USER',
// article
ARTICLE: 'ARTICLE' as TMetric,
BLOG_ARTICLE: 'BLOG_ARTICLE' as TMetric,
WORKS_ARTICLE: 'WORKS_ARTICLE' as TMetric,
ARTICLE: 'ARTICLE',
BLOG_ARTICLE: 'BLOG_ARTICLE',
WORKS_ARTICLE: 'WORKS_ARTICLE',

// 版块
WORKS: 'WORKS' as TMetric,
TRENDING: 'TRENDING' as TMetric,
COOL_GUIDE: 'COOL_GUIDE' as TMetric,
HAVE_A_DRINK: 'HAVE_A_DRINK' as TMetric,
RECIPES: 'RECIPES' as TMetric,
EXPLORE: 'EXPLORE' as TMetric,
SPONSOR: 'SPONSOR' as TMetric,
FRIENDS: 'FRIENDS' as TMetric,
SUPPORT_US: 'SUPPORT_US' as TMetric,
SUBSCRIBE: 'SUBSCRIBE' as TMetric,
MEETUPS: 'MEETUPS' as TMetric,
MEMBERSHIP: 'MEMBERSHIP' as TMetric,
HELP_CENTER: 'HELP_CENTER' as TMetric,
WORKS: 'WORKS',
TRENDING: 'TRENDING',
COOL_GUIDE: 'COOL_GUIDE',
HAVE_A_DRINK: 'HAVE_A_DRINK',
RECIPES: 'RECIPES',
EXPLORE: 'EXPLORE',
SPONSOR: 'SPONSOR',
FRIENDS: 'FRIENDS',
SUPPORT_US: 'SUPPORT_US',
SUBSCRIBE: 'SUBSCRIBE',
MEETUPS: 'MEETUPS',
MEMBERSHIP: 'MEMBERSHIP',
HELP_CENTER: 'HELP_CENTER',

// eidtors
WORKS_EDITOR: 'WORKS_EDITOR' as TMetric,
COMMUNITY_EDITOR: 'COMMUNITY_EDITOR' as TMetric,
ARTICLE_EDITOR: 'ARTICLE_EDITOR' as TMetric,
}
WORKS_EDITOR: 'WORKS_EDITOR',
COMMUNITY_EDITOR: 'COMMUNITY_EDITOR',
ARTICLE_EDITOR: 'ARTICLE_EDITOR',
} as Record<Uppercase<TMetric>, Uppercase<TMetric>>

export default METRIC
16 changes: 8 additions & 8 deletionsutils/constant/payment.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
import type { TPaymentUsage, TPaymentMethod } from '@/spec'

export const PAYMENT_USAGE = {
SENIOR: 'SENIOR' as TPaymentUsage,
GIRLS_CODE_TOO_PLAN: 'GirlsCodeTooPlan' as TPaymentUsage,
DONATE: 'DONATE' as TPaymentUsage,
SPONSOR: 'SPONSOR' as TPaymentUsage,
}
SENIOR: 'SENIOR',
GIRLS_CODE_TOO_PLAN: 'GIRLS_CODE_TOO_PLAN',
DONATE: 'DONATE',
SPONSOR: 'SPONSOR',
} as Record<Uppercase<TPaymentUsage>, Uppercase<TPaymentUsage>>

export const PAYMENT_METHOD = {
ALIPAY: 'ALIPAY' as TPaymentMethod,
WECHAT: 'WECHAT' as TPaymentMethod,
}
ALIPAY: 'ALIPAY',
WECHAT: 'WECHAT',
} as Record<Uppercase<TPaymentMethod>, Uppercase<TPaymentMethod>>
22 changes: 11 additions & 11 deletionsutils/constant/tab.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
import type { TWorksTab, TBlogTab } from '@/spec'

export const WORKS_TAB = {
STORY: 'story' as TWorksTab,
BASIC: 'basic' as TWorksTab,
TECHSTACKS: 'techstacks' as TWorksTab,
COMMUNITY: 'community' as TWorksTab,
MILESTONE: 'milestone' as TWorksTab,
INTERVIEW: 'interview' as TWorksTab,
}
STORY: 'story',
BASIC: 'basic',
TECHSTACKS: 'techstacks',
COMMUNITY: 'community',
MILESTONE: 'milestone',
INTERVIEW: 'interview',
} as Record<Uppercase<TWorksTab>, TWorksTab>

export const WORKS_TAB_ITEMS = [
{
Expand DownExpand Up@@ -41,10 +41,10 @@ export const WORKS_TAB_ITEMS = [
]

export const BLOG_TAB = {
DIGEST: 'digest' as TBlogTab,
AUTHOR: 'author' as TBlogTab,
FEEDS: 'feeds' as TBlogTab,
}
DIGEST: 'digest',
AUTHOR: 'author',
FEEDS: 'feeds',
} as Record<Uppercase<TBlogTab>, TBlogTab>

export const BLOG_TAB_ITEMS = [
{
Expand Down
6 changes: 3 additions & 3 deletionsutils/constant/tag.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
import type { TTagMode } from '@/spec'

const TAG_MODE = {
DEFAULT: 'default' as TTagMode,
LABEL: 'label' as TTagMode,
}
DEFAULT: 'default',
LABEL: 'label',
} as Record<Uppercase<TTagMode>, TTagMode>

export default TAG_MODE

[8]ページ先頭

©2009-2025 Movatter.jp