Skip to content

Commit da86162

Browse files
authored
Bump Plug JS to 0.12.1 (#377)
1 parent 7f7b08d commit da86162

File tree

4 files changed

+22
-18
lines changed

4 files changed

+22
-18
lines changed

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"
3838
},
3939
"dependencies": {
40-
"@croct/plug": "^0.12.0",
40+
"@croct/plug": "^0.12.1",
4141
"@croct/sdk": "^0.12.3"
4242
},
4343
"devDependencies": {

src/components/Slot/index.d.test.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,16 @@ describe('<Slot /> typing', () => {
1717
`;
1818

1919
const slotMapping = `
20-
type HomeBannerProps = {
20+
type HomeBanner = {
2121
title: string,
2222
subtitle: string,
2323
};
2424
2525
declare module '@croct/plug/slot' {
26+
type HomeBannerV1 = HomeBanner & {_component: 'banner@v1' | null};
27+
2628
interface SlotMap {
27-
'home-banner': HomeBannerProps;
29+
'home-banner': HomeBannerV1;
2830
}
2931
}
3032
`;
@@ -199,7 +201,7 @@ describe('<Slot /> typing', () => {
199201

200202
expect(() => compileCode(code)).not.toThrow();
201203

202-
expect(getParameterType(code)).toBe('HomeBannerProps & {_component: string | null;}');
204+
expect(getParameterType(code)).toBe('HomeBannerV1');
203205
});
204206

205207
it('should allow a covariant renderer parameter type for mapped slots', () => {
@@ -240,7 +242,7 @@ describe('<Slot /> typing', () => {
240242

241243
expect(() => compileCode(code)).not.toThrow();
242244

243-
expect(getParameterType(code)).toBe('boolean | (HomeBannerProps & {_component: string | null;})');
245+
expect(getParameterType(code)).toBe('boolean | HomeBannerV1');
244246
});
245247

246248
it('should allow a renderer that accepts the initial value for mapped slots', () => {
@@ -281,7 +283,7 @@ describe('<Slot /> typing', () => {
281283

282284
expect(() => compileCode(code)).not.toThrow();
283285

284-
expect(getParameterType(code)).toBe('boolean | (HomeBannerProps & {_component: string | null;})');
286+
expect(getParameterType(code)).toBe('boolean | HomeBannerV1');
285287
});
286288

287289
it('should allow a renderer that accepts the fallback value for mapped slots', () => {
@@ -322,7 +324,7 @@ describe('<Slot /> typing', () => {
322324

323325
expect(() => compileCode(code)).not.toThrow();
324326

325-
expect(getParameterType(code)).toBe('number | boolean | (HomeBannerProps & {_component: string | null;})');
327+
expect(getParameterType(code)).toBe('number | boolean | HomeBannerV1');
326328
});
327329

328330
it('should allow a renderer that accepts both the initial and fallback values for mapped slots', () => {

src/hooks/useContent.d.test.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,12 @@ describe('useContent typing', () => {
3030
};
3131
3232
declare module '@croct/plug/slot' {
33+
type HomeBannerV1 = HomeBanner & {_component: 'banner@v1' | null};
34+
3335
interface VersionedSlotMap {
3436
'home-banner': {
35-
'latest': HomeBanner,
36-
'1': HomeBanner,
37+
'latest': HomeBannerV1,
38+
'1': HomeBannerV1,
3739
};
3840
}
3941
}
@@ -137,7 +139,7 @@ describe('useContent typing', () => {
137139
);
138140

139141
expect(getReturnType(code)).toBe(
140-
'(Banner & {_component: "banner@1";}) | (Carousel & {_component: "carousel@1";})',
142+
'(Banner & {_component: "banner@1" | null;}) | (Carousel & {...;})',
141143
);
142144
});
143145

@@ -283,7 +285,7 @@ describe('useContent typing', () => {
283285

284286
expect(getTypeName(code)).toBe('useContent<"home-banner">');
285287

286-
expect(getReturnType(code)).toBe('HomeBanner & {_component: string | null;}');
288+
expect(getReturnType(code)).toBe('HomeBannerV1');
287289
});
288290

289291
it('should include the type of the initial value on the return type for mapped slots', () => {
@@ -298,7 +300,7 @@ describe('useContent typing', () => {
298300

299301
expect(getTypeName(code)).toBe('useContent<boolean, "home-banner">');
300302

301-
expect(getReturnType(code)).toBe('boolean | (HomeBanner & {_component: string | null;})');
303+
expect(getReturnType(code)).toBe('boolean | HomeBannerV1');
302304
});
303305

304306
it('should include the type of the fallback value on the return type for mapped slots', () => {
@@ -313,7 +315,7 @@ describe('useContent typing', () => {
313315

314316
expect(getTypeName(code)).toBe('useContent<number, "home-banner">');
315317

316-
expect(getReturnType(code)).toBe('number | (HomeBanner & {_component: string | null;})');
318+
expect(getReturnType(code)).toBe('number | HomeBannerV1');
317319
});
318320

319321
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', () => {
328330

329331
expect(getTypeName(code)).toBe('useContent<boolean, number, "home-banner">');
330332

331-
expect(getReturnType(code)).toBe('number | boolean | (HomeBanner & {...;})');
333+
expect(getReturnType(code)).toBe('number | boolean | HomeBannerV1');
332334
});
333335

334336
it('should not allow overriding the return type for mapped slots', () => {

0 commit comments

Comments
 (0)