Update tsafe (changelog ignore)

This commit is contained in:
garronej
2021-10-11 03:41:05 +02:00
parent 4ca2bc59b6
commit 20f528a167
8 changed files with 36 additions and 37 deletions

View File

@ -1,6 +1,6 @@
import { allPropertiesValuesToUndefined } from "../tools/allPropertiesValuesToUndefined";
import { doExtends } from "tsafe/doExtends";
import { assert } from "tsafe/assert";
/** Class names can be provided as an array or separated by whitespace */
export type KcPropsGeneric<CssClasses extends string> = { [key in CssClasses]: readonly string[] | string | undefined; };
@ -67,14 +67,14 @@ export const defaultKcTemplateProps = {
"kcInfoAreaWrapperClass": []
} as const;
assert<typeof defaultKcTemplateProps extends KcTemplateProps ? true : false>();
doExtends<typeof defaultKcTemplateProps, KcTemplateProps>();
/** Tu use if you don't want any default */
export const allClearKcTemplateProps =
allPropertiesValuesToUndefined(defaultKcTemplateProps);
doExtends<typeof allClearKcTemplateProps, KcTemplateProps>();
assert<typeof allClearKcTemplateProps extends KcTemplateProps ? true: false>();
export type KcProps = KcPropsGeneric<
KcTemplateClassKey |
@ -201,11 +201,11 @@ export const defaultKcProps = {
"kcFormOptionsWrapperClass": []
} as const;
doExtends<typeof defaultKcProps, KcProps>();
assert<typeof defaultKcProps extends KcProps ? true : false>();
/** Tu use if you don't want any default */
export const allClearKcProps =
allPropertiesValuesToUndefined(defaultKcProps);
doExtends<typeof allClearKcProps, KcProps>();
assert<typeof allClearKcProps extends KcProps ? true : false>();

View File

@ -1,7 +1,8 @@
import type { PageId } from "../../bin/build-keycloak-theme/generateFtl";
import type { KcLanguageTag } from "../i18n/KcLanguageTag";
import { doExtends } from "tsafe/doExtends";
import { assert } from "tsafe/assert";
import type { Equals } from "tsafe";
import type { MessageKey } from "../i18n/useKcMessage";
import type { LanguageLabel } from "../i18n/KcLanguageTag";
@ -212,8 +213,7 @@ export declare namespace KcContextBase {
}
doExtends<KcContextBase["pageId"], PageId>();
doExtends<PageId, KcContextBase["pageId"]>();
assert<Equals<KcContextBase["pageId"], PageId>>();

View File

@ -23,6 +23,12 @@ export const kcContextCommonMock: KcContextBase.Common = {
"internationalizationEnabled": true,
"registrationEmailAsUsername": true,
},
"messagesPerField": {
"printIfExists": (...[, x]) => x,
"existsError": ()=> true,
"get": key=> `Fake error for ${key}`,
"exists": ()=> true
},
"locale": {
"supported": [
{
@ -164,11 +170,6 @@ export const kcContextMocks: KcContextBase[] = [
...loginUrl,
"registrationAction": "http://localhost:8080/auth/realms/myrealm/login-actions/registration?session_code=gwZdUeO7pbYpFTRxiIxRg_QtzMbtFTKrNu6XW_f8asM&execution=12146ce0-b139-4bbd-b25b-0eccfee6577e&client_id=account&tab_id=uS8lYfebLa0"
},
"messagesPerField": {
"printIfExists": (...[, x]) => x,
"existsError": ()=> true,
"get": key=> `Fake error for ${key}`
},
"scripts": [],
"isAppInitiatedAction": false,
"register": {
@ -250,9 +251,6 @@ export const kcContextMocks: KcContextBase[] = [
"email": "foo@example.com",
"firstName": "aFirstName",
"lastName": "aLastName"
},
"messagesPerField": {
"printIfExists": () => undefined
}
}),
id<KcContextBase.LoginIdpLinkConfirm>({

View File

@ -6,8 +6,6 @@ import { useEvt } from "evt/hooks";
//NOTE for later: https://github.com/remarkjs/react-markdown/blob/236182ecf30bd89c1e5a7652acaf8d0bf81e6170/src/renderers.js#L7-L35
import ReactMarkdown from "react-markdown";
import { id } from "tsafe/id";
import { assert } from "tsafe/assert";
import { is } from "tsafe/is";
export type MessageKey = keyof typeof kcMessages["en"];