Skip to content

Commit

Permalink
feat: 类型更新
Browse files Browse the repository at this point in the history
  • Loading branch information
fjc0k committed Dec 1, 2021
1 parent 76e0ccd commit 8c2f6f6
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@
"standard-version": "9.3.1",
"tree-tool": "1.1.8",
"ts-essentials": "7.0.3",
"type-fest": "2.0.0",
"type-fest": "2.7.0",
"typescript": "4.4.2",
"typescript-snapshots-plugin": "1.7.0",
"vscode-generate-index-standalone": "1.5.3",
Expand Down
9 changes: 9 additions & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,18 @@ export type {
KebabCase,
PascalCase,
DelimiterCase,
ScreamingSnakeCase as ConstantCase,
Class,
Asyncify,
UnionToIntersection,
Integer,
NegativeInteger,
NonNegativeInteger,
Negative,
NonNegative,
Finite,
PositiveInfinity,
NegativeInfinity,
} from 'type-fest'

export type {
Expand Down
5 changes: 3 additions & 2 deletions src/utils/constantCase.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ConstantCase } from '../types'
import { snakeCase } from 'lodash-uni'

/**
Expand All @@ -11,6 +12,6 @@ import { snakeCase } from 'lodash-uni'
* // => TEST_STRING
* ```
*/
export function constantCase(text: string): string {
return snakeCase(text).toUpperCase()
export function constantCase<T extends string>(text: T): ConstantCase<T> {
return snakeCase(text).toUpperCase() as any
}
5 changes: 3 additions & 2 deletions src/utils/pascalCase.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { camelCase, upperFirst } from 'lodash-uni'
import { PascalCase } from '../types'

/**
* 转换文本为没有分隔符的大写单词字符串。
Expand All @@ -11,6 +12,6 @@ import { camelCase, upperFirst } from 'lodash-uni'
* // => TestString
* ```
*/
export function pascalCase(text: string): string {
return upperFirst(camelCase(text))
export function pascalCase<T extends string>(text: T): PascalCase<T> {
return upperFirst(camelCase(text)) as any
}
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9083,10 +9083,10 @@ [email protected]:
resolved "https://registry.nlark.com/type-detect/download/type-detect-4.0.8.tgz#7646fb5f18871cfbb7749e69bd39a6388eb7450c"
integrity sha1-dkb7XxiHHPu3dJ5pvTmmOI63RQw=

type-fest@2.0.0:
version "2.0.0"
resolved "https://registry.nlark.com/type-fest/download/type-fest-2.0.0.tgz?cache=0&sync_timestamp=1629724529996&other_urls=https%3A%2F%2Fregistry.nlark.com%2Ftype-fest%2Fdownload%2Ftype-fest-2.0.0.tgz#e9daf5615e89f6d430f34117f88f4ee2cd5a2725"
integrity sha1-6dr1YV6J9tQw80EX+I9O4s1aJyU=
type-fest@2.7.0:
version "2.7.0"
resolved "https://registry.npmmirror.com/type-fest/download/type-fest-2.7.0.tgz#6d58aa78d48f0968110a4ab1f75f563ae6cde572"
integrity sha512-gmfzrsfDuoQUpqteXPE1X8D2GdtEAhP+X9pdXj3xBbg86OO8ZtSTtJ9BVopDyWtdNuwbOXAYdluX4o/O65qebA==

type-fest@^0.13.1:
version "0.13.1"
Expand Down

0 comments on commit 8c2f6f6

Please sign in to comment.