diff --git a/package-lock.json b/package-lock.json
index 9fa9a690..bc036e02 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -9,7 +9,7 @@
"version": "0.0.0-dev",
"license": "MIT",
"dependencies": {
- "@croct/plug": "^0.11.6",
+ "@croct/plug": "^0.12.1",
"@croct/sdk": "^0.12.3"
},
"devDependencies": {
@@ -2035,9 +2035,9 @@
"integrity": "sha512-NmF8UmLow1l9TcS60wAgP8PGzoEylyFKG+hhthmSv43EC3fbDBPZroPwyq890qdvSdVb/5bpJBJVN+HKpn3cOQ=="
},
"node_modules/@croct/plug": {
- "version": "0.11.6",
- "resolved": "https://registry.npmjs.org/@croct/plug/-/plug-0.11.6.tgz",
- "integrity": "sha512-TlfwLo8QPl5eLeWRTLEFbWXsOjTebezngb83wtu9u2n0yBMJ47jczSLwGye20A+uQYrmNNVNgocYNZ9dnhdoGA==",
+ "version": "0.12.1",
+ "resolved": "https://registry.npmjs.org/@croct/plug/-/plug-0.12.1.tgz",
+ "integrity": "sha512-sEyMxQuqs41xjBCeoqPpHqrtzRU25uIAQ1it6Py6yCNxIjL/+lMk5LTZjzMZuhoSYvFcV3aoO/UFMi6Jm4BJ2A==",
"dependencies": {
"@croct/json": "^2.0.1",
"@croct/sdk": "^0.12.3",
diff --git a/package.json b/package.json
index c647f84f..cd7682e7 100644
--- a/package.json
+++ b/package.json
@@ -37,7 +37,7 @@
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"
},
"dependencies": {
- "@croct/plug": "^0.12.0",
+ "@croct/plug": "^0.12.1",
"@croct/sdk": "^0.12.3"
},
"devDependencies": {
diff --git a/src/components/Slot/index.d.test.tsx b/src/components/Slot/index.d.test.tsx
index f98f43f0..b3bf0f5d 100644
--- a/src/components/Slot/index.d.test.tsx
+++ b/src/components/Slot/index.d.test.tsx
@@ -17,14 +17,16 @@ describe(' typing', () => {
`;
const slotMapping = `
- type HomeBannerProps = {
+ type HomeBanner = {
title: string,
subtitle: string,
};
declare module '@croct/plug/slot' {
+ type HomeBannerV1 = HomeBanner & {_component: 'banner@v1' | null};
+
interface SlotMap {
- 'home-banner': HomeBannerProps;
+ 'home-banner': HomeBannerV1;
}
}
`;
@@ -199,7 +201,7 @@ describe(' typing', () => {
expect(() => compileCode(code)).not.toThrow();
- expect(getParameterType(code)).toBe('HomeBannerProps & {_component: string | null;}');
+ expect(getParameterType(code)).toBe('HomeBannerV1');
});
it('should allow a covariant renderer parameter type for mapped slots', () => {
@@ -240,7 +242,7 @@ describe(' typing', () => {
expect(() => compileCode(code)).not.toThrow();
- expect(getParameterType(code)).toBe('boolean | (HomeBannerProps & {_component: string | null;})');
+ expect(getParameterType(code)).toBe('boolean | HomeBannerV1');
});
it('should allow a renderer that accepts the initial value for mapped slots', () => {
@@ -281,7 +283,7 @@ describe(' typing', () => {
expect(() => compileCode(code)).not.toThrow();
- expect(getParameterType(code)).toBe('boolean | (HomeBannerProps & {_component: string | null;})');
+ expect(getParameterType(code)).toBe('boolean | HomeBannerV1');
});
it('should allow a renderer that accepts the fallback value for mapped slots', () => {
@@ -322,7 +324,7 @@ describe(' typing', () => {
expect(() => compileCode(code)).not.toThrow();
- expect(getParameterType(code)).toBe('number | boolean | (HomeBannerProps & {_component: string | null;})');
+ expect(getParameterType(code)).toBe('number | boolean | HomeBannerV1');
});
it('should allow a renderer that accepts both the initial and fallback values for mapped slots', () => {
diff --git a/src/hooks/useContent.d.test.tsx b/src/hooks/useContent.d.test.tsx
index cf8cb49d..294295b6 100644
--- a/src/hooks/useContent.d.test.tsx
+++ b/src/hooks/useContent.d.test.tsx
@@ -30,10 +30,12 @@ describe('useContent typing', () => {
};
declare module '@croct/plug/slot' {
+ type HomeBannerV1 = HomeBanner & {_component: 'banner@v1' | null};
+
interface VersionedSlotMap {
'home-banner': {
- 'latest': HomeBanner,
- '1': HomeBanner,
+ 'latest': HomeBannerV1,
+ '1': HomeBannerV1,
};
}
}
@@ -137,7 +139,7 @@ describe('useContent typing', () => {
);
expect(getReturnType(code)).toBe(
- '(Banner & {_component: "banner@1";}) | (Carousel & {_component: "carousel@1";})',
+ '(Banner & {_component: "banner@1" | null;}) | (Carousel & {...;})',
);
});
@@ -283,7 +285,7 @@ describe('useContent typing', () => {
expect(getTypeName(code)).toBe('useContent<"home-banner">');
- expect(getReturnType(code)).toBe('HomeBanner & {_component: string | null;}');
+ expect(getReturnType(code)).toBe('HomeBannerV1');
});
it('should include the type of the initial value on the return type for mapped slots', () => {
@@ -298,7 +300,7 @@ describe('useContent typing', () => {
expect(getTypeName(code)).toBe('useContent');
- expect(getReturnType(code)).toBe('boolean | (HomeBanner & {_component: string | null;})');
+ expect(getReturnType(code)).toBe('boolean | HomeBannerV1');
});
it('should include the type of the fallback value on the return type for mapped slots', () => {
@@ -313,7 +315,7 @@ describe('useContent typing', () => {
expect(getTypeName(code)).toBe('useContent');
- expect(getReturnType(code)).toBe('number | (HomeBanner & {_component: string | null;})');
+ expect(getReturnType(code)).toBe('number | HomeBannerV1');
});
it('should include the types of both the initial and fallback values on the return type for mapped slots', () => {
@@ -328,7 +330,7 @@ describe('useContent typing', () => {
expect(getTypeName(code)).toBe('useContent');
- expect(getReturnType(code)).toBe('number | boolean | (HomeBanner & {...;})');
+ expect(getReturnType(code)).toBe('number | boolean | HomeBannerV1');
});
it('should not allow overriding the return type for mapped slots', () => {