generated from arvinxx/npm-template
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐛 fix: 修正 createStyles 的类型定义,避免无法正常跳转
- Loading branch information
Showing
6 changed files
with
169 additions
and
27 deletions.
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
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,22 @@ | ||
import { CSSObject } from '@emotion/css'; | ||
|
||
/** | ||
* 给用户提供类型定义的返回签名 | ||
* 用户可以使用 key: css` color:red `,或者 key :{ color : 'red' },都能正常提供类型定义 | ||
*/ | ||
export type StyleDefinition<StyleObj> = StyleObj extends string | ||
? string | ||
: Record<keyof StyleObj, CSSObject | string>; | ||
|
||
// type IsString<T> = T extends string ? true : false; | ||
// export type ReturnStyleToUse<T> = IsString<T> extends true | ||
// ? string | ||
// : T extends Record<infer R, any> | ||
// ? Record<R, string> | ||
// : never; | ||
/** | ||
* 根据用户返回的样式对象,返回一个可以给用户使用的 | ||
* 譬如用户输入为 { a: css`color: red;`, b: { color: 'red' } | ||
* 输出的类型泛型为 { a:string; b:string } | ||
*/ | ||
export type ReturnStyleToUse<T> = T extends Record<infer R, any> ? Record<R, string> : string; |
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,4 +1,5 @@ | ||
export * from './appearance'; | ||
export * from './css'; | ||
export * from './genericUtils'; | ||
export * from './styled'; | ||
export * from './theme'; |
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