Skip to content

Commit

Permalink
fix: Fixed some mistaken merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
NicholasBoll committed May 6, 2024
1 parent de342fa commit c1e68fd
Show file tree
Hide file tree
Showing 26 changed files with 504 additions and 166 deletions.
4 changes: 2 additions & 2 deletions modules/docs/docgen/spec/createProgramFromSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ export function createProgramFromSource(...args: any[]) {
(name.startsWith('lib')
? ts.createSourceFile(
name,
ts.sys.readFile(`node_modules/typescript/lib/${name}`),
ts.sys.readFile(`node_modules/typescript/lib/${name}`)!,
languageVersion
)
: name === 'node_modules/react.ts'
? ts.createSourceFile(
name,
ts.sys.readFile(`node_modules/@types/react/index.d.ts`),
ts.sys.readFile(`node_modules/@types/react/index.d.ts`)!,
languageVersion
)
: defaultCompilerHost.getSourceFile(name, languageVersion))
Expand Down
2 changes: 1 addition & 1 deletion modules/labs-react/combobox/lib/Combobox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ export const Combobox = ({
const autoCompleteItemCount = interactiveAutocompleteItems.length;
const firstItem = 0;
const lastItem = autoCompleteItemCount - 1;
let nextIndex = null;
let nextIndex: number | null = null;

setIsOpened(true);

Expand Down
2 changes: 1 addition & 1 deletion modules/preview-react/text-input/spec/TextInput.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ describe('Text Input', () => {
<TextInput.Field />
</TextInput>
);
const uniqueId = container.querySelector('input').getAttribute('id');
const uniqueId = container.querySelector('input')!.getAttribute('id');
expect(container.querySelector('input')).toHaveAttribute('id', uniqueId);
});
});
Expand Down
22 changes: 12 additions & 10 deletions modules/react/button/spec/Button.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,17 @@ import {
import {render, fireEvent} from '@testing-library/react';
import {ElementComponent} from '@workday/canvas-kit-react/common';

([
PrimaryButton,
SecondaryButton,
TertiaryButton,
DeleteButton,
DeprecatedButton,
// We need to cast as `any` and cast as a specific button because TS will complain about no call signatures...
] as any[]).forEach((ButtonComponent: ElementComponent<'button', ButtonProps>) => {
describe(ButtonComponent.displayName, () => {
(
[
PrimaryButton,
SecondaryButton,
TertiaryButton,
DeleteButton,
DeprecatedButton,
// We need to cast as `any` and cast as a specific button because TS will complain about no call signatures...
] as any[]
).forEach((ButtonComponent: ElementComponent<'button', ButtonProps>) => {
describe(ButtonComponent.displayName!, () => {
const cb = jest.fn();
afterEach(() => {
cb.mockReset();
Expand Down Expand Up @@ -66,7 +68,7 @@ import {ElementComponent} from '@workday/canvas-kit-react/common';

describe('when rendered with a button ref', () => {
it('should set the ref to the checkbox input element', () => {
const ref = {current: null};
const ref = {current: null as null | HTMLButtonElement};

render(<ButtonComponent ref={ref} />);

Expand Down
4 changes: 2 additions & 2 deletions modules/react/collection/spec/useCursorModel.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ type CursorListState = ReturnType<typeof useCursorListModel>['state'];
const createState = (input: Partial<CursorListState>): CursorListState => {
return {
nonInteractiveIds: [],
...(input as CursorListState),
};
...input,
} as CursorListState;
};

const createItem = (id, index) => ({id, index, value: id, textValue: id});
Expand Down
17 changes: 10 additions & 7 deletions modules/react/common/spec/components.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,9 @@ describe('createHook', () => {

const props = hook(emptyModel, {bar: 'baz'}, {current: divElement});

expectTypeOf(props).toEqualTypeOf<{foo: string} & {bar: string} & {ref: React.Ref<unknown>}>();
expectTypeOf(props).toEqualTypeOf<
{foo: string} & {bar: string} & {ref: React.Ref<unknown> | undefined}
>();
expect(props).toEqual({foo: 'bar', bar: 'baz', ref: {current: divElement}});
});

Expand Down Expand Up @@ -289,7 +291,7 @@ describe('createHook', () => {
describe('useForkRef', () => {
it('should set the current value of the second ref if the first ref is undefined', () => {
const ref1 = undefined;
const ref2 = {current: null};
const ref2 = {current: 'foo'};

const ref = useForkRef(ref1, ref2);

Expand All @@ -299,7 +301,7 @@ describe('useForkRef', () => {
});

it('should set the current value of the first ref if the second ref is undefined', () => {
const ref1 = {current: null};
const ref1 = {current: 'foo'};
const ref2 = undefined;

const ref = useForkRef(ref1, ref2);
Expand All @@ -310,8 +312,8 @@ describe('useForkRef', () => {
});

it('should set the current value of both refs if both refs are RefObjects', () => {
const ref1 = {current: null};
const ref2 = {current: null};
const ref1 = {current: 'ref1'};
const ref2 = {current: 'ref2'};

const ref = useForkRef(ref1, ref2);

Expand Down Expand Up @@ -449,8 +451,9 @@ describe('composeHooks', () => {
// This test is covering all previous tests, but with more hooks.
// This test should only fail if the implementation doesn't handle more than 2 hooks
const model = {state: {foo: 'bar'}, events: {}};
const hooks = [1, 2, 3, 4, 5, 6, 7, 8, 9].map(number => (myModel, props) =>
mergeProps({id: number, foo: number, [`hook${number}`]: model.state.foo}, props)
const hooks = [1, 2, 3, 4, 5, 6, 7, 8, 9].map(
number => (myModel, props) =>
mergeProps({id: number, foo: number, [`hook${number}`]: model.state.foo}, props)
);

const props = (composeHooks as any).apply(null, hooks as any)(myModel, {foo: 'baz'}, null);
Expand Down
4 changes: 1 addition & 3 deletions modules/react/common/spec/mergeProps.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,7 @@ describe('mergeProps', () => {
const target = {
onClick: targetSpy,
};
const source = {
onClick: undefined,
};
const source = {};

const mergedProps = mergeProps(target, source);
mergedProps.onClick({event: 'foo'});
Expand Down
2 changes: 1 addition & 1 deletion modules/react/form-field/spec/FormField.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ describe('FormField', () => {
<input type="text" />
</FormField>
);
const uniqueId = container.querySelector('input').getAttribute('id');
const uniqueId = container.querySelector('input')!.getAttribute('id');
expect(container.querySelector('input')).toHaveAttribute('id', uniqueId);
});
});
Expand Down
2 changes: 1 addition & 1 deletion modules/styling-transform/spec/createProgramFromSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export function createProgramFromSource(...args: any[]) {
if (name.startsWith('lib')) {
return ts.createSourceFile(
name,
ts.sys.readFile(`node_modules/typescript/lib/${name}`),
ts.sys.readFile(`node_modules/typescript/lib/${name}`)!,
languageVersion
);
}
Expand Down
5 changes: 4 additions & 1 deletion modules/styling-transform/spec/findNodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ export function findNodes<N extends (node: ts.Node) => boolean>(
node.forEachChild(child => {
// The AST doesn't have parent nodes, but they are required for testing purposes.
(child as any).parent = node;
nodes.push(...findNodes(child, name, predicate));
const childNodes = findNodes(child, name, predicate);
if (childNodes) {
nodes.push(...childNodes);
}
});

return nodes as any;
Expand Down
4 changes: 2 additions & 2 deletions modules/styling-transform/spec/utils/getErrorMessage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ describe('getErrorMessage', () => {
};
`);

const sourceFile = program.getSourceFile('test.ts');
const node = findNodes(sourceFile, 'baz', ts.isIdentifier)[0];
const sourceFile = program.getSourceFile('test.ts')!;
const node = findNodes(sourceFile, 'baz', ts.isIdentifier)![0];

const ctx = withDefaultContext(program.getTypeChecker(), {});

Expand Down
16 changes: 8 additions & 8 deletions modules/styling-transform/spec/utils/getVarName.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ describe('getVarName', () => {
const foo = 'bar';
`);

const sourceFile = program.getSourceFile('test.ts');
const sourceFile = program.getSourceFile('test.ts')!;

const node = findNodes(sourceFile, 'foo', ts.isVariableDeclaration)[0];
const node = findNodes(sourceFile, 'foo', ts.isVariableDeclaration)![0];

expect(getVarName(node)).toEqual('foo');
});
Expand All @@ -28,9 +28,9 @@ describe('getVarName', () => {
};
`);

const sourceFile = program.getSourceFile('test.ts');
const sourceFile = program.getSourceFile('test.ts')!;

const node = findNodes(sourceFile, 'baz', ts.isPropertyAssignment)[0];
const node = findNodes(sourceFile, 'baz', ts.isPropertyAssignment)![0];

expect(getVarName(node)).toEqual('foo-bar-baz');
});
Expand All @@ -45,9 +45,9 @@ describe('getVarName', () => {
});
`);

const sourceFile = program.getSourceFile('test.ts');
const sourceFile = program.getSourceFile('test.ts')!;

const node = findNodes(sourceFile, 'baz', ts.isPropertyAssignment)[0];
const node = findNodes(sourceFile, 'baz', ts.isPropertyAssignment)![0];

expect(getVarName(node)).toEqual('foo-bar-baz');
});
Expand All @@ -62,9 +62,9 @@ describe('getVarName', () => {
};
`);

const sourceFile = program.getSourceFile('test.ts');
const sourceFile = program.getSourceFile('test.ts')!;

const node = findNodes(sourceFile, 'baz', ts.isPropertyAssignment)[0];
const node = findNodes(sourceFile, 'baz', ts.isPropertyAssignment)![0];

expect(getVarName(node.name)).toEqual('foo-bar-baz');
});
Expand Down
60 changes: 30 additions & 30 deletions modules/styling-transform/spec/utils/handleCalc.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ describe('handleCalc', () => {
calc.add('20px', '2rem')
`);

const sourceFile = program.getSourceFile('test.ts');
const node = findNodes(sourceFile, '', ts.isCallExpression)[0];
const sourceFile = program.getSourceFile('test.ts')!;
const node = findNodes(sourceFile, '', ts.isCallExpression)![0];

const result = handleCalc(node, withDefaultContext(program.getTypeChecker()));

Expand All @@ -30,8 +30,8 @@ describe('handleCalc', () => {
calc.add(foo, '2rem')
`);

const sourceFile = program.getSourceFile('test.ts');
const node = findNodes(sourceFile, '', ts.isCallExpression)[0];
const sourceFile = program.getSourceFile('test.ts')!;
const node = findNodes(sourceFile, '', ts.isCallExpression)![0];

const result = handleCalc(node, withDefaultContext(program.getTypeChecker()));

Expand All @@ -43,8 +43,8 @@ describe('handleCalc', () => {
calc.add(myVars.foo, '2rem')
`);

const sourceFile = program.getSourceFile('test.ts');
const node = findNodes(sourceFile, '', ts.isCallExpression)[0];
const sourceFile = program.getSourceFile('test.ts')!;
const node = findNodes(sourceFile, '', ts.isCallExpression)![0];

const result = handleCalc(
node,
Expand All @@ -61,8 +61,8 @@ describe('handleCalc', () => {
calc.subtract('20px', '2rem')
`);

const sourceFile = program.getSourceFile('test.ts');
const node = findNodes(sourceFile, '', ts.isCallExpression)[0];
const sourceFile = program.getSourceFile('test.ts')!;
const node = findNodes(sourceFile, '', ts.isCallExpression)![0];

const result = handleCalc(node, withDefaultContext(program.getTypeChecker()));

Expand All @@ -76,8 +76,8 @@ describe('handleCalc', () => {
calc.subtract(foo, '2rem')
`);

const sourceFile = program.getSourceFile('test.ts');
const node = findNodes(sourceFile, '', ts.isCallExpression)[0];
const sourceFile = program.getSourceFile('test.ts')!;
const node = findNodes(sourceFile, '', ts.isCallExpression)![0];

const result = handleCalc(node, withDefaultContext(program.getTypeChecker()));

Expand All @@ -89,8 +89,8 @@ describe('handleCalc', () => {
calc.subtract(myVars.foo, '2rem')
`);

const sourceFile = program.getSourceFile('test.ts');
const node = findNodes(sourceFile, '', ts.isCallExpression)[0];
const sourceFile = program.getSourceFile('test.ts')!;
const node = findNodes(sourceFile, '', ts.isCallExpression)![0];

const result = handleCalc(
node,
Expand All @@ -107,8 +107,8 @@ describe('handleCalc', () => {
calc.multiply('20px', '2')
`);

const sourceFile = program.getSourceFile('test.ts');
const node = findNodes(sourceFile, '', ts.isCallExpression)[0];
const sourceFile = program.getSourceFile('test.ts')!;
const node = findNodes(sourceFile, '', ts.isCallExpression)![0];

const result = handleCalc(node, withDefaultContext(program.getTypeChecker()));

Expand All @@ -122,8 +122,8 @@ describe('handleCalc', () => {
calc.multiply(foo, '2')
`);

const sourceFile = program.getSourceFile('test.ts');
const node = findNodes(sourceFile, '', ts.isCallExpression)[0];
const sourceFile = program.getSourceFile('test.ts')!;
const node = findNodes(sourceFile, '', ts.isCallExpression)![0];

const result = handleCalc(node, withDefaultContext(program.getTypeChecker()));

Expand All @@ -135,8 +135,8 @@ describe('handleCalc', () => {
calc.multiply(myVars.foo, '2')
`);

const sourceFile = program.getSourceFile('test.ts');
const node = findNodes(sourceFile, '', ts.isCallExpression)[0];
const sourceFile = program.getSourceFile('test.ts')!;
const node = findNodes(sourceFile, '', ts.isCallExpression)![0];

const result = handleCalc(
node,
Expand All @@ -153,8 +153,8 @@ describe('handleCalc', () => {
calc.divide('20px', '2')
`);

const sourceFile = program.getSourceFile('test.ts');
const node = findNodes(sourceFile, '', ts.isCallExpression)[0];
const sourceFile = program.getSourceFile('test.ts')!;
const node = findNodes(sourceFile, '', ts.isCallExpression)![0];

const result = handleCalc(node, withDefaultContext(program.getTypeChecker()));

Expand All @@ -168,8 +168,8 @@ describe('handleCalc', () => {
calc.divide(foo, '2')
`);

const sourceFile = program.getSourceFile('test.ts');
const node = findNodes(sourceFile, '', ts.isCallExpression)[0];
const sourceFile = program.getSourceFile('test.ts')!;
const node = findNodes(sourceFile, '', ts.isCallExpression)![0];

const result = handleCalc(node, withDefaultContext(program.getTypeChecker()));

Expand All @@ -181,8 +181,8 @@ describe('handleCalc', () => {
calc.divide(myVars.foo, '2')
`);

const sourceFile = program.getSourceFile('test.ts');
const node = findNodes(sourceFile, '', ts.isCallExpression)[0];
const sourceFile = program.getSourceFile('test.ts')!;
const node = findNodes(sourceFile, '', ts.isCallExpression)![0];

const result = handleCalc(
node,
Expand All @@ -199,8 +199,8 @@ describe('handleCalc', () => {
calc.negate('20px')
`);

const sourceFile = program.getSourceFile('test.ts');
const node = findNodes(sourceFile, '', ts.isCallExpression)[0];
const sourceFile = program.getSourceFile('test.ts')!;
const node = findNodes(sourceFile, '', ts.isCallExpression)![0];

const result = handleCalc(node, withDefaultContext(program.getTypeChecker()));

Expand All @@ -214,8 +214,8 @@ describe('handleCalc', () => {
calc.negate(foo)
`);

const sourceFile = program.getSourceFile('test.ts');
const node = findNodes(sourceFile, '', ts.isCallExpression)[0];
const sourceFile = program.getSourceFile('test.ts')!;
const node = findNodes(sourceFile, '', ts.isCallExpression)![0];

const result = handleCalc(node, withDefaultContext(program.getTypeChecker()));

Expand All @@ -227,8 +227,8 @@ describe('handleCalc', () => {
calc.negate(myVars.foo)
`);

const sourceFile = program.getSourceFile('test.ts');
const node = findNodes(sourceFile, '', ts.isCallExpression)[0];
const sourceFile = program.getSourceFile('test.ts')!;
const node = findNodes(sourceFile, '', ts.isCallExpression)![0];

const result = handleCalc(
node,
Expand Down
Loading

0 comments on commit c1e68fd

Please sign in to comment.