Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build: Fix type checking for 3 unit tests #23932

Merged
merged 8 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions code/addons/links/src/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ 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, {
kind: 'title',
story: 'name',
});
});
Expand Down
10 changes: 8 additions & 2 deletions code/lib/cli/src/js-package-manager/PNPMProxy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
Expand All @@ -228,6 +233,7 @@ describe('PNPM Proxy', () => {
await pnpmProxy.addPackageResolutions(versions);

expect(writePackageSpy).toHaveBeenCalledWith({
...basePackageAttributes,
overrides: {
...versions,
bar: 'x.x.x',
Expand Down
56 changes: 19 additions & 37 deletions code/renderers/react/src/docs/typeScript/handleProp.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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');

Expand All @@ -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]);

Expand All @@ -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' }]);

Expand All @@ -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' }]);

Expand All @@ -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' });

Expand All @@ -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' });

Expand All @@ -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!');

Expand All @@ -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!';
Expand All @@ -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;
Expand All @@ -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 = <ReactComponent />;
// Simulate babel-plugin-add-react-displayname.
Expand All @@ -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 = <ReactComponent className="toto" />;
Expand All @@ -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, <div>HTML element</div>);

Expand All @@ -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,
Expand All @@ -461,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,
Expand All @@ -478,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 <div>Inlined FunctionalComponent!</div>;
Expand All @@ -490,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 <div>{foo}</div>;
Expand All @@ -502,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 <div>Inlined FunctionalComponent!</div>;
Expand All @@ -514,8 +497,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,
Expand Down