From 8fd8bcacbd9c498a78c7533b78e76238353b5cb8 Mon Sep 17 00:00:00 2001 From: Marcin Date: Wed, 23 Aug 2023 10:06:23 -0700 Subject: [PATCH 1/5] Fix type checking. --- .../src/js-package-manager/PNPMProxy.test.ts | 10 ++++- .../src/docs/typeScript/handleProp.test.tsx | 44 +++++++------------ 2 files changed, 23 insertions(+), 31 deletions(-) diff --git a/code/lib/cli/src/js-package-manager/PNPMProxy.test.ts b/code/lib/cli/src/js-package-manager/PNPMProxy.test.ts index e59bd7354bcc..fc89fd2b32f6 100644 --- a/code/lib/cli/src/js-package-manager/PNPMProxy.test.ts +++ b/code/lib/cli/src/js-package-manager/PNPMProxy.test.ts @@ -213,9 +213,14 @@ describe('PNPM Proxy', () => { .spyOn(pnpmProxy, 'writePackageJson') .mockImplementation(jest.fn()); + const basePackageAttributes = { + dependencies: {}, + devDependencies: {}, + }; + jest.spyOn(pnpmProxy, 'retrievePackageJson').mockImplementation( - // @ts-expect-error (not strict) - jest.fn(() => ({ + jest.fn(async () => ({ + ...basePackageAttributes, overrides: { bar: 'x.x.x', }, @@ -228,6 +233,7 @@ describe('PNPM Proxy', () => { await pnpmProxy.addPackageResolutions(versions); expect(writePackageSpy).toHaveBeenCalledWith({ + ...basePackageAttributes, overrides: { ...versions, bar: 'x.x.x', diff --git a/code/renderers/react/src/docs/typeScript/handleProp.test.tsx b/code/renderers/react/src/docs/typeScript/handleProp.test.tsx index 37527fd501df..ce74acf8be7c 100644 --- a/code/renderers/react/src/docs/typeScript/handleProp.test.tsx +++ b/code/renderers/react/src/docs/typeScript/handleProp.test.tsx @@ -64,7 +64,7 @@ function extractPropDef(component: Component, rawDefaultProp?: any): PropDef { describe('enhanceTypeScriptProp', () => { describe('defaultValue', () => { function createTestComponent( - defaultValue: DocgenPropDefaultValue, + defaultValue: DocgenPropDefaultValue | undefined, typeName = 'anything-is-fine' ): Component { return createComponent({ @@ -295,8 +295,7 @@ describe('enhanceTypeScriptProp', () => { }); it('should support strings', () => { - // @ts-expect-error (not strict) - const component = createTestComponent(null); + const component = createTestComponent(undefined); const { defaultValue } = extractPropDef(component, 'foo'); @@ -305,8 +304,7 @@ describe('enhanceTypeScriptProp', () => { }); it('should support array of primitives', () => { - // @ts-expect-error (not strict) - const component = createTestComponent(null); + const component = createTestComponent(undefined); const { defaultValue } = extractPropDef(component, [1, 2, 3]); @@ -315,8 +313,7 @@ describe('enhanceTypeScriptProp', () => { }); it('should support array of short object', () => { - // @ts-expect-error (not strict) - const component = createTestComponent(null); + const component = createTestComponent(undefined); const { defaultValue } = extractPropDef(component, [{ foo: 'bar' }]); @@ -325,8 +322,7 @@ describe('enhanceTypeScriptProp', () => { }); it('should support array of long object', () => { - // @ts-expect-error (not strict) - const component = createTestComponent(null); + const component = createTestComponent(undefined); const { defaultValue } = extractPropDef(component, [{ foo: 'bar', bar: 'foo', hey: 'ho' }]); @@ -342,8 +338,7 @@ describe('enhanceTypeScriptProp', () => { }); it('should support short object', () => { - // @ts-expect-error (not strict) - const component = createTestComponent(null); + const component = createTestComponent(undefined); const { defaultValue } = extractPropDef(component, { foo: 'bar' }); @@ -352,8 +347,7 @@ describe('enhanceTypeScriptProp', () => { }); it('should support long object', () => { - // @ts-expect-error (not strict) - const component = createTestComponent(null); + const component = createTestComponent(undefined); const { defaultValue } = extractPropDef(component, { foo: 'bar', bar: 'foo', hey: 'ho' }); @@ -369,8 +363,7 @@ describe('enhanceTypeScriptProp', () => { }); it('should support anonymous function', () => { - // @ts-expect-error (not strict) - const component = createTestComponent(null); + const component = createTestComponent(undefined); const { defaultValue } = extractPropDef(component, () => 'hey!'); @@ -379,8 +372,7 @@ describe('enhanceTypeScriptProp', () => { }); it('should support named function', () => { - // @ts-expect-error (not strict) - const component = createTestComponent(null); + const component = createTestComponent(undefined); const { defaultValue } = extractPropDef(component, function hello() { return 'world!'; @@ -391,8 +383,7 @@ describe('enhanceTypeScriptProp', () => { }); it('should support named function with params', () => { - // @ts-expect-error (not strict) - const component = createTestComponent(null); + const component = createTestComponent(undefined); const { defaultValue } = extractPropDef(component, function add(a: number, b: number) { return a + b; @@ -403,8 +394,7 @@ describe('enhanceTypeScriptProp', () => { }); it('should support React element', () => { - // @ts-expect-error (not strict) - const component = createTestComponent(null); + const component = createTestComponent(undefined); const defaultProp = ; // Simulate babel-plugin-add-react-displayname. @@ -417,8 +407,7 @@ describe('enhanceTypeScriptProp', () => { }); it('should support React element with props', () => { - // @ts-expect-error (not strict) - const component = createTestComponent(null); + const component = createTestComponent(undefined); // @ts-expect-error (Converted from ts-ignore) const defaultProp = ; @@ -432,8 +421,7 @@ describe('enhanceTypeScriptProp', () => { }); it('should support short HTML element', () => { - // @ts-expect-error (not strict) - const component = createTestComponent(null); + const component = createTestComponent(undefined); const { defaultValue } = extractPropDef(component,
HTML element
); @@ -442,8 +430,7 @@ describe('enhanceTypeScriptProp', () => { }); it('should support long HTML element', () => { - // @ts-expect-error (not strict) - const component = createTestComponent(null); + const component = createTestComponent(undefined); const { defaultValue } = extractPropDef( component, @@ -514,8 +501,7 @@ describe('enhanceTypeScriptProp', () => { }); it(`should support inlined named React functional component with props for ${x}`, () => { - // @ts-expect-error (not strict) - const component = createTestComponent(null, x); + const component = createTestComponent(undefined, x); const { defaultValue } = extractPropDef( component, From f7c77b073f8c997aec9d31b6a60152bf4a081e03 Mon Sep 17 00:00:00 2001 From: Marcin Date: Wed, 23 Aug 2023 10:13:02 -0700 Subject: [PATCH 2/5] fix error for title --- code/addons/links/src/utils.test.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/code/addons/links/src/utils.test.ts b/code/addons/links/src/utils.test.ts index f2dd2871501c..47a477b4104f 100644 --- a/code/addons/links/src/utils.test.ts +++ b/code/addons/links/src/utils.test.ts @@ -41,8 +41,7 @@ describe('preview', () => { it('should select the story (only) provided', () => { // simulate a currently selected, but not found as ID - // @ts-expect-error (not strict) - const handler = linkTo(undefined, 'name'); + const handler = linkTo('title', 'name'); handler(); expect(channel.emit).toHaveBeenCalledWith(SELECT_STORY, { From d1526a3c946548e0a6e7539da3b4b2b0c89801df Mon Sep 17 00:00:00 2001 From: Marcin Date: Wed, 23 Aug 2023 10:26:24 -0700 Subject: [PATCH 3/5] more fixes. --- .../react/src/docs/typeScript/handleProp.test.tsx | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/code/renderers/react/src/docs/typeScript/handleProp.test.tsx b/code/renderers/react/src/docs/typeScript/handleProp.test.tsx index ce74acf8be7c..a230f0229b5a 100644 --- a/code/renderers/react/src/docs/typeScript/handleProp.test.tsx +++ b/code/renderers/react/src/docs/typeScript/handleProp.test.tsx @@ -448,8 +448,7 @@ describe('enhanceTypeScriptProp', () => { ['element', 'elementType'].forEach((x) => { it(`should support inlined React class component for ${x}`, () => { - // @ts-expect-error (not strict) - const component = createTestComponent(null, x); + const component = createTestComponent(undefined, x); const { defaultValue } = extractPropDef( component, @@ -465,8 +464,7 @@ describe('enhanceTypeScriptProp', () => { }); it(`should support inlined anonymous React functional component for ${x}`, () => { - // @ts-expect-error (not strict) - const component = createTestComponent(null, x); + const component = createTestComponent(undefined, x); const { defaultValue } = extractPropDef(component, () => { return
Inlined FunctionalComponent!
; @@ -477,8 +475,7 @@ describe('enhanceTypeScriptProp', () => { }); it(`should support inlined anonymous React functional component with props for ${x}`, () => { - // @ts-expect-error (not strict) - const component = createTestComponent(null, x); + const component = createTestComponent(undefined, x); const { defaultValue } = extractPropDef(component, ({ foo }: { foo: string }) => { return
{foo}
; @@ -489,8 +486,7 @@ describe('enhanceTypeScriptProp', () => { }); it(`should support inlined named React functional component for ${x}`, () => { - // @ts-expect-error (not strict) - const component = createTestComponent(null, x); + const component = createTestComponent(undefined, x); const { defaultValue } = extractPropDef(component, function InlinedFunctionalComponent() { return
Inlined FunctionalComponent!
; From 643eec1e14a5179d97c436afb99d04910e562373 Mon Sep 17 00:00:00 2001 From: Marcin Date: Mon, 28 Aug 2023 07:21:31 -0700 Subject: [PATCH 4/5] updated. --- code/addons/links/src/utils.test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/code/addons/links/src/utils.test.ts b/code/addons/links/src/utils.test.ts index 47a477b4104f..25499e4958d7 100644 --- a/code/addons/links/src/utils.test.ts +++ b/code/addons/links/src/utils.test.ts @@ -45,6 +45,7 @@ describe('preview', () => { handler(); expect(channel.emit).toHaveBeenCalledWith(SELECT_STORY, { + kind: 'title', story: 'name', }); }); From 01717a64519e9bfb1692d6c675452a062ea66c54 Mon Sep 17 00:00:00 2001 From: Marcin Date: Mon, 28 Aug 2023 08:41:55 -0700 Subject: [PATCH 5/5] reverted --- code/addons/links/src/utils.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/addons/links/src/utils.test.ts b/code/addons/links/src/utils.test.ts index 25499e4958d7..f2dd2871501c 100644 --- a/code/addons/links/src/utils.test.ts +++ b/code/addons/links/src/utils.test.ts @@ -41,11 +41,11 @@ describe('preview', () => { it('should select the story (only) provided', () => { // simulate a currently selected, but not found as ID - const handler = linkTo('title', 'name'); + // @ts-expect-error (not strict) + const handler = linkTo(undefined, 'name'); handler(); expect(channel.emit).toHaveBeenCalledWith(SELECT_STORY, { - kind: 'title', story: 'name', }); });