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

@ -48,7 +48,6 @@
"properties-parser": "^0.3.1", "properties-parser": "^0.3.1",
"react": "^17.0.1", "react": "^17.0.1",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"ts-toolbelt": "^9.6.0",
"typescript": "^4.2.3" "typescript": "^4.2.3"
}, },
"dependencies": { "dependencies": {
@ -60,7 +59,7 @@
"powerhooks": "^0.9.3", "powerhooks": "^0.9.3",
"react-markdown": "^5.0.3", "react-markdown": "^5.0.3",
"scripting-tools": "^0.19.13", "scripting-tools": "^0.19.13",
"tsafe": "^0.4.1", "tsafe": "^0.8.1",
"tss-react": "^0.9.1" "tss-react": "^1.0.0"
} }
} }

View File

@ -1,6 +1,6 @@
import { allPropertiesValuesToUndefined } from "../tools/allPropertiesValuesToUndefined"; 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 */ /** 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; }; export type KcPropsGeneric<CssClasses extends string> = { [key in CssClasses]: readonly string[] | string | undefined; };
@ -67,14 +67,14 @@ export const defaultKcTemplateProps = {
"kcInfoAreaWrapperClass": [] "kcInfoAreaWrapperClass": []
} as const; } as const;
assert<typeof defaultKcTemplateProps extends KcTemplateProps ? true : false>();
doExtends<typeof defaultKcTemplateProps, KcTemplateProps>();
/** Tu use if you don't want any default */ /** Tu use if you don't want any default */
export const allClearKcTemplateProps = export const allClearKcTemplateProps =
allPropertiesValuesToUndefined(defaultKcTemplateProps); allPropertiesValuesToUndefined(defaultKcTemplateProps);
doExtends<typeof allClearKcTemplateProps, KcTemplateProps>(); assert<typeof allClearKcTemplateProps extends KcTemplateProps ? true: false>();
export type KcProps = KcPropsGeneric< export type KcProps = KcPropsGeneric<
KcTemplateClassKey | KcTemplateClassKey |
@ -201,11 +201,11 @@ export const defaultKcProps = {
"kcFormOptionsWrapperClass": [] "kcFormOptionsWrapperClass": []
} as const; } as const;
doExtends<typeof defaultKcProps, KcProps>(); assert<typeof defaultKcProps extends KcProps ? true : false>();
/** Tu use if you don't want any default */ /** Tu use if you don't want any default */
export const allClearKcProps = export const allClearKcProps =
allPropertiesValuesToUndefined(defaultKcProps); 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 { PageId } from "../../bin/build-keycloak-theme/generateFtl";
import type { KcLanguageTag } from "../i18n/KcLanguageTag"; 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 { MessageKey } from "../i18n/useKcMessage";
import type { LanguageLabel } from "../i18n/KcLanguageTag"; import type { LanguageLabel } from "../i18n/KcLanguageTag";
@ -212,8 +213,7 @@ export declare namespace KcContextBase {
} }
doExtends<KcContextBase["pageId"], PageId>(); assert<Equals<KcContextBase["pageId"], PageId>>();
doExtends<PageId, KcContextBase["pageId"]>();

View File

@ -23,6 +23,12 @@ export const kcContextCommonMock: KcContextBase.Common = {
"internationalizationEnabled": true, "internationalizationEnabled": true,
"registrationEmailAsUsername": true, "registrationEmailAsUsername": true,
}, },
"messagesPerField": {
"printIfExists": (...[, x]) => x,
"existsError": ()=> true,
"get": key=> `Fake error for ${key}`,
"exists": ()=> true
},
"locale": { "locale": {
"supported": [ "supported": [
{ {
@ -164,11 +170,6 @@ export const kcContextMocks: KcContextBase[] = [
...loginUrl, ...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" "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": [], "scripts": [],
"isAppInitiatedAction": false, "isAppInitiatedAction": false,
"register": { "register": {
@ -250,9 +251,6 @@ export const kcContextMocks: KcContextBase[] = [
"email": "foo@example.com", "email": "foo@example.com",
"firstName": "aFirstName", "firstName": "aFirstName",
"lastName": "aLastName" "lastName": "aLastName"
},
"messagesPerField": {
"printIfExists": () => undefined
} }
}), }),
id<KcContextBase.LoginIdpLinkConfirm>({ 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 //NOTE for later: https://github.com/remarkjs/react-markdown/blob/236182ecf30bd89c1e5a7652acaf8d0bf81e6170/src/renderers.js#L7-L35
import ReactMarkdown from "react-markdown"; import ReactMarkdown from "react-markdown";
import { id } from "tsafe/id"; import { id } from "tsafe/id";
import { assert } from "tsafe/assert";
import { is } from "tsafe/is";
export type MessageKey = keyof typeof kcMessages["en"]; export type MessageKey = keyof typeof kcMessages["en"];

View File

@ -3,11 +3,10 @@ import { getKcContext } from "../../lib/getKcContext";
import type { KcContextBase } from "../../lib/getKcContext"; import type { KcContextBase } from "../../lib/getKcContext";
import type { ExtendsKcContextBase } from "../../lib/getKcContext/getKcContext"; import type { ExtendsKcContextBase } from "../../lib/getKcContext/getKcContext";
import { same } from "evt/tools/inDepth"; import { same } from "evt/tools/inDepth";
import { doExtends } from "tsafe/doExtends";
import { assert } from "tsafe/assert"; import { assert } from "tsafe/assert";
import type { Equals } from "tsafe";
import { kcContextMocks, kcContextCommonMock } from "../../lib/getKcContext/kcContextMocks"; import { kcContextMocks, kcContextCommonMock } from "../../lib/getKcContext/kcContextMocks";
import { deepClone } from "../../lib/tools/deepClone"; import { deepClone } from "../../lib/tools/deepClone";
import type { Any } from "ts-toolbelt";
{ {
@ -79,7 +78,7 @@ import type { Any } from "ts-toolbelt";
assert(kcContext?.pageId === pageId); assert(kcContext?.pageId === pageId);
doExtends<Any.Equals<typeof kcContext, KcContextBase.Login>, 1>(); assert<Equals<typeof kcContext, KcContextBase.Login>>();
assert(same( assert(same(
//NOTE: deepClone for printIfExists or other functions... //NOTE: deepClone for printIfExists or other functions...
@ -107,7 +106,7 @@ import type { Any } from "ts-toolbelt";
assert(kcContext?.pageId === pageId); assert(kcContext?.pageId === pageId);
//NOTE: I don't understand the need to add: pageId: typeof pageId; ... //NOTE: I don't understand the need to add: pageId: typeof pageId; ...
doExtends<Any.Equals<typeof kcContext, KcContextBase.Info & { pageId: typeof pageId; aNonStandardValue1: string; }>, 1>(); assert<Equals<typeof kcContext, KcContextBase.Info & { pageId: typeof pageId; aNonStandardValue1: string; }>>();
assert(same( assert(same(
deepClone(kcContext), deepClone(kcContext),
@ -134,7 +133,7 @@ import type { Any } from "ts-toolbelt";
assert(kcContext?.pageId === pageId); assert(kcContext?.pageId === pageId);
//NOTE: I don't understand the need to add: pageId: typeof pageId; ... //NOTE: I don't understand the need to add: pageId: typeof pageId; ...
doExtends<Any.Equals<typeof kcContext, KcContextBase.Register & { pageId: typeof pageId; authorizedMailDomains: string[]; }>, 1>(); assert<Equals<typeof kcContext, KcContextBase.Register & { pageId: typeof pageId; authorizedMailDomains: string[]; }>>();
assert(same( assert(same(
deepClone(kcContext), deepClone(kcContext),
@ -161,7 +160,7 @@ import type { Any } from "ts-toolbelt";
assert(kcContext?.pageId === pageId); assert(kcContext?.pageId === pageId);
doExtends<Any.Equals<typeof kcContext, KcContextBase.Common & { pageId: typeof pageId; aNonStandardValue2: string; }>, 1>(); assert<Equals<typeof kcContext, KcContextBase.Common & { pageId: typeof pageId; aNonStandardValue2: string; }>>();
kcContext.aNonStandardValue2; kcContext.aNonStandardValue2;
@ -193,7 +192,7 @@ import type { Any } from "ts-toolbelt";
assert(kcContext?.pageId === pageId); assert(kcContext?.pageId === pageId);
doExtends<Any.Equals<typeof kcContext, KcContextBase.Common & { pageId: typeof pageId; }>, 1>(); assert<Equals<typeof kcContext, KcContextBase.Common & { pageId: typeof pageId; }>>();
assert(same( assert(same(
deepClone(kcContext), deepClone(kcContext),
@ -222,7 +221,7 @@ import type { Any } from "ts-toolbelt";
"mockPageId": pageId "mockPageId": pageId
}); });
doExtends<Any.Equals<typeof kcContext, KcContextBase | undefined>, 1>(); assert<Equals<typeof kcContext, KcContextBase | undefined>>();
assert(same( assert(same(
deepClone(kcContext), deepClone(kcContext),
@ -238,7 +237,7 @@ import type { Any } from "ts-toolbelt";
const { kcContext } = getKcContext(); const { kcContext } = getKcContext();
doExtends<Any.Equals<typeof kcContext, KcContextBase | undefined>, 1>(); assert<Equals<typeof kcContext, KcContextBase | undefined>>();
assert(kcContext === undefined); assert(kcContext === undefined);

View File

@ -1,6 +1,7 @@
import { AndByDiscriminatingKey } from "../../../lib/tools/AndByDiscriminatingKey"; import { AndByDiscriminatingKey } from "../../../lib/tools/AndByDiscriminatingKey";
import { doExtends } from "tsafe/doExtends"; import { assert } from "tsafe/assert";
import type { Equals } from "tsafe";
type Base = type Base =
{ pageId: "a"; onlyA: string; } | { pageId: "a"; onlyA: string; } |
@ -20,8 +21,7 @@ type Expected =
{ pageId: "only base"; onlyBase: string; } | { pageId: "only base"; onlyBase: string; } |
{ pageId: "only ext"; onlyExt: string; }; { pageId: "only ext"; onlyExt: string; };
doExtends<Got, Expected>(); assert<Equals<Got, Expected>>();
doExtends<Expected, Got>();
const x: Got = null as any; const x: Got = null as any;

View File

@ -990,15 +990,20 @@ tsafe@^0.4.1:
resolved "https://registry.yarnpkg.com/tsafe/-/tsafe-0.4.1.tgz#00af1be2db82abb4be531209b90232d7954e1a03" resolved "https://registry.yarnpkg.com/tsafe/-/tsafe-0.4.1.tgz#00af1be2db82abb4be531209b90232d7954e1a03"
integrity sha512-+OZ0gdgmwcru+MOSheCx+ymAvQz+1/ui+KFJRuaq0t2m8RNrlf7eSzEieptoPQXPY67Mdkqgkdjknn8azoD5sw== integrity sha512-+OZ0gdgmwcru+MOSheCx+ymAvQz+1/ui+KFJRuaq0t2m8RNrlf7eSzEieptoPQXPY67Mdkqgkdjknn8azoD5sw==
tsafe@^0.8.1:
version "0.8.1"
resolved "https://registry.yarnpkg.com/tsafe/-/tsafe-0.8.1.tgz#9af7e1540bc04313a82d60c98056a5017c8b086b"
integrity sha512-EfPjxQHzndQAV/uh0SMGP26Wg3dCuaw8dRv2VPEuGHen5qzg2oqsMvZw2wkQFkiMisZq2fm95m5lheimW2Fpvg==
tslib@^2.2.0: tslib@^2.2.0:
version "2.3.1" version "2.3.1"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.3.1.tgz#e8a335add5ceae51aa261d32a490158ef042ef01" resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.3.1.tgz#e8a335add5ceae51aa261d32a490158ef042ef01"
integrity sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw== integrity sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==
tss-react@^0.9.1: tss-react@^1.0.0:
version "0.9.1" version "1.0.0"
resolved "https://registry.yarnpkg.com/tss-react/-/tss-react-0.9.1.tgz#5d0b5d4bf608dd049032c3f179dba56b5716ff9f" resolved "https://registry.yarnpkg.com/tss-react/-/tss-react-1.0.0.tgz#8bb8b7e358dddf0bc0db8de2713245273dd62682"
integrity sha512-FxHyTq5b3YcAE7QAd10CuDBQA2X//amAzWO+2QYO/5Hygv8jb80TQKXvKgpekzO5JR5Ry8jMpc0ZkHcjgfzs3Q== integrity sha512-pDFr3afWtmAVNFO3G/PX5fmmE/KuJDf0V8XiYitau2VkbxUPU929Hsms6u7VHnxacoCrvOJKLC6HH1NEapfOfA==
dependencies: dependencies:
"@emotion/cache" "^11.4.0" "@emotion/cache" "^11.4.0"
"@emotion/serialize" "^1.0.2" "@emotion/serialize" "^1.0.2"