generated from react-component/trigger
-
Notifications
You must be signed in to change notification settings - Fork 7
Fix: fixed some typescript error #8
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ba4f578
fix: fixed `AliasToken` instead of `CompTokenMap` for `GetResetStyles`
YumoImer f1b541c
fix: fixed `Partial<AliasToken & CompTokenMap>` instead of `CompToken…
YumoImer 271ee2a
fix: `GlobalToken` instead of `Partial<AliasToken & CompTokenMap>` fo…
YumoImer b912ba3
fix: fixed some TS issues during antd integration
YumoImer 5e52f71
docs: update genStyleUtils use docs
YumoImer 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 hidden or 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 |
---|---|---|
|
@@ -16,8 +16,8 @@ nav: | |
- `usePrefix`: 使用样式前缀的钩子函数 | ||
- `useToken`: 使用 token 的钩子函数 | ||
- `CompTokenMap`: 范型参数,表示组件 token 映射 | ||
- `DesignTokenn`: 范型参数,表示设计 token | ||
- `AliasToken`: 范型参数,表示别名 token | ||
- `DesignTokenn`: 范型参数,表示设计 token | ||
> 使用建议:为了更好的获得 TS 类型支持,建议您在使用 `genStyleUtils` 的时候传入范型参数 `CompTokenMap` `DesignTokenn` `AliasToken` | ||
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. DesignTokenn |
||
|
||
## 如何使用 | ||
|
This file contains hidden or 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 hidden or 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,25 @@ | ||
export { default as genStyleUtils } from './util/genStyleUtils'; | ||
|
||
export { default as genCalc } from './util/calc'; | ||
export type { default as AbstractCalculator } from './util/calc/calculator'; | ||
export { | ||
default as statisticToken, | ||
merge as mergeToken, | ||
} from './util/statistic'; | ||
|
||
export type { | ||
OverrideTokenMap, | ||
TokenMap, | ||
TokenMapKey, | ||
GlobalTokenWithComponent, | ||
ComponentToken, | ||
ComponentTokenKey, | ||
GlobalToken, | ||
} from './interface'; | ||
export type { default as AbstractCalculator } from './util/calc/calculator'; | ||
export type { | ||
FullToken, | ||
GetDefaultToken, | ||
GetDefaultTokenFn, | ||
GenStyleFn, | ||
TokenWithCommonCls, | ||
CSSUtil, | ||
} from './util/genStyleUtils'; |
This file contains hidden or 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,14 +1,35 @@ | ||
import type { TokenType } from '@ant-design/cssinjs'; | ||
|
||
export type TokenMap = Record<string, TokenType>; | ||
export type TokenMap = object; | ||
|
||
export type TokenMapKey<CompTokenMap extends TokenMap> = Extract<keyof CompTokenMap, string>; | ||
|
||
export type OverrideTokenMap<CompTokenMap extends TokenMap> = Partial<CompTokenMap>; | ||
export type GlobalToken< | ||
CompTokenMap extends TokenMap, | ||
AliasToken extends TokenType, | ||
> = AliasToken & CompTokenMap; | ||
|
||
export type GlobalTokenWithComponent<CompTokenMap extends TokenMap, C extends TokenMapKey<CompTokenMap>> = CompTokenMap & | ||
CompTokenMap[C]; | ||
export type OverrideTokenMap< | ||
CompTokenMap extends TokenMap, | ||
AliasToken extends TokenType, | ||
> = { | ||
[key in keyof CompTokenMap]: Partial<CompTokenMap[key]> & Partial<AliasToken>; | ||
}; | ||
|
||
export type ComponentToken<CompTokenMap extends TokenMap, C extends TokenMapKey<CompTokenMap>> = Exclude<OverrideTokenMap<CompTokenMap>[C], undefined>; | ||
export type GlobalTokenWithComponent< | ||
CompTokenMap extends TokenMap, | ||
AliasToken extends TokenType, | ||
C extends TokenMapKey<CompTokenMap> | ||
> = GlobalToken<CompTokenMap, AliasToken> & CompTokenMap[C]; | ||
|
||
export type ComponentTokenKey<CompTokenMap extends TokenMap, C extends TokenMapKey<CompTokenMap>> = keyof ComponentToken<CompTokenMap, C>; | ||
export type ComponentToken< | ||
CompTokenMap extends TokenMap, | ||
AliasToken extends TokenType, | ||
C extends TokenMapKey<CompTokenMap> | ||
> = Exclude<OverrideTokenMap<CompTokenMap, AliasToken>[C], undefined>; | ||
|
||
export type ComponentTokenKey< | ||
CompTokenMap extends TokenMap, | ||
AliasToken extends TokenType, | ||
C extends TokenMapKey<CompTokenMap>, | ||
> = keyof ComponentToken<CompTokenMap, AliasToken, C>; |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,14 +1,19 @@ | ||
import type { TokenType } from '@ant-design/cssinjs'; | ||
import { merge as mergeToken } from './statistic'; | ||
import type { GetDefaultToken, GetDefaultTokenFn } from './genStyleUtils'; | ||
import type { OverrideTokenMap, TokenMap, TokenMapKey } from '../interface'; | ||
import type { GlobalToken, TokenMap, TokenMapKey } from '../interface'; | ||
|
||
export default function getDefaultComponentToken<CompTokenMap extends TokenMap, C extends TokenMapKey<CompTokenMap>>( | ||
export default function getDefaultComponentToken< | ||
CompTokenMap extends TokenMap, | ||
AliasToken extends TokenType, | ||
C extends TokenMapKey<CompTokenMap> | ||
>( | ||
component: C, | ||
token: OverrideTokenMap<CompTokenMap>, | ||
getDefaultToken: GetDefaultToken<CompTokenMap, C>, | ||
token: GlobalToken<CompTokenMap, AliasToken>, | ||
getDefaultToken: GetDefaultToken<CompTokenMap, AliasToken, C>, | ||
): any { | ||
if (typeof getDefaultToken === 'function') { | ||
return (getDefaultToken as GetDefaultTokenFn<CompTokenMap, C>)(mergeToken<any>(token, token[component] ?? {})); | ||
return (getDefaultToken as GetDefaultTokenFn<CompTokenMap, AliasToken, C>)(mergeToken<any>(token, token[component] ?? {})); | ||
} | ||
return getDefaultToken ?? {}; | ||
}; |
Oops, something went wrong.
Oops, something went wrong.
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.
DesignTokenn => DesignToken
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.
好眼力😂