Skip to content

Commit

Permalink
chore: update TypeScript to v4.7.4 (#1847)
Browse files Browse the repository at this point in the history
  • Loading branch information
ocavue committed Sep 10, 2022
1 parent cf39718 commit 9c1068f
Show file tree
Hide file tree
Showing 41 changed files with 530 additions and 466 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@
"testing": "^0.0.4",
"ts-documenter": "^0.0.4",
"tsx": "^3.4.2",
"typescript": "~4.5.5",
"typescript": "~4.7.4",
"typescript-styled-plugin": "^0.18.1"
},
"engines": {
Expand Down
29 changes: 16 additions & 13 deletions packages/jest-remirror/__tests__/jest-remirror-editor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import {
LinkExtension,
} from 'remirror/extensions';
import { cleanup } from 'testing/react';
import { PlainExtension, prosemirrorNodeToHtml } from '@remirror/core';
import { AnyExtension, PlainExtension, prosemirrorNodeToHtml } from '@remirror/core';
import { NodeSelection } from '@remirror/pm/state';

import { renderEditor } from '../';

beforeEach(cleanup);

test('renders an editor into the dom', () => {
const { view } = renderEditor([]);
const { view } = renderEditor<never>([]);

expect(view.dom).toBeVisible();
});
Expand All @@ -25,7 +25,7 @@ test('add content', () => {
view,
nodes: { doc, p },
add,
} = renderEditor([]);
} = renderEditor<AnyExtension>([]);
add(doc(p(expected)));

expect(view.dom).toHaveTextContent(expected);
Expand All @@ -37,7 +37,7 @@ test('can be configured with plain node extensions', () => {
view: { dom },
nodes: { blockquote, doc, p },
add,
} = renderEditor([new BlockquoteExtension()]);
} = renderEditor<BlockquoteExtension>([new BlockquoteExtension()]);
add(doc(blockquote(p(expected)), p('This is a p')));

expect(dom).toHaveTextContent('A simple blockquote');
Expand All @@ -50,7 +50,7 @@ test('can be configured with attribute node extensions', () => {
nodes: { doc },
attributeNodes: { heading },
add,
} = renderEditor([new HeadingExtension()]);
} = renderEditor<HeadingExtension>([new HeadingExtension()]);

const h3 = heading({ level: 3 });
const h2 = heading({ level: 2 });
Expand All @@ -67,7 +67,7 @@ test('can be configured with plain mark extensions', () => {
nodes: { doc, p },
add,
marks: { bold },
} = renderEditor([new BoldExtension()]);
} = renderEditor<BoldExtension>([new BoldExtension()]);
add(doc(p('Text is ', bold(expected))));

expect(dom.querySelector('strong')!.textContent).toBe(expected);
Expand All @@ -81,7 +81,7 @@ test('can be configured with attribute mark extensions', () => {
nodes: { doc, p },
add,
attributeMarks: { link },
} = renderEditor([new LinkExtension()]);
} = renderEditor<LinkExtension>([new LinkExtension()]);
const googleLinkExtension = link({ href });
add(doc(p('LinkExtension to ', googleLinkExtension(expected))));

Expand All @@ -95,7 +95,7 @@ test('can throw error if received a non top level node', () => {
const {
nodes: { doc, p },
add,
} = renderEditor([]);
} = renderEditor<AnyExtension>([]);

expect(() => add(doc(p('')))).not.toThrow();
expect(() => add(p(''))).toThrow();
Expand All @@ -122,9 +122,12 @@ class CustomExtension extends PlainExtension {
}

function create() {
return renderEditor([new BoldExtension(), new CustomExtension()], {
builtin: { persistentSelectionClass: undefined },
});
return renderEditor<BoldExtension | CustomExtension>(
[new BoldExtension(), new CustomExtension()],
{
builtin: { persistentSelectionClass: undefined },
},
);
}

describe('add', () => {
Expand Down Expand Up @@ -217,14 +220,14 @@ describe('tags', () => {
view,
nodes: { doc, p },
add,
} = renderEditor([]);
} = renderEditor<never>([]);

beforeEach(() => {
({
view,
nodes: { doc, p },
add,
} = renderEditor([]));
} = renderEditor<never>([]));
});

it('supports <cursor>', () => {
Expand Down
22 changes: 11 additions & 11 deletions packages/jest-remirror/__tests__/jest-remirror-matchers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe('toContainRemirrorDocument', () => {
const {
nodes: { doc, p },
add,
} = renderEditor([]);
} = renderEditor<never>([]);
const expected = p('simple');
const { state } = add(doc(expected));

Expand All @@ -19,7 +19,7 @@ describe('toContainRemirrorDocument', () => {
const {
nodes: { doc, p },
add,
} = renderEditor([]);
} = renderEditor<never>([]);
const expected = p('simple');
const { state } = add(doc(expected));

Expand All @@ -31,7 +31,7 @@ describe('toContainRemirrorDocument', () => {
const {
nodes: { doc, p },
add,
} = renderEditor([]);
} = renderEditor<never>([]);
const { state } = add(doc(p('old')));
const { state: newState } = add(doc(p('new')));

Expand All @@ -43,12 +43,12 @@ describe('toContainRemirrorDocument', () => {
const {
nodes: { doc: docOld, p: pOld },
add: addOld,
} = renderEditor([]);
} = renderEditor<never>([]);

const {
nodes: { doc, p },
add,
} = renderEditor([new BoldExtension()]);
} = renderEditor<BoldExtension>([new BoldExtension()]);
const oldNode = pOld('simple');
const newNode = p('simple');
const { state: oldState } = addOld(docOld(oldNode));
Expand All @@ -64,7 +64,7 @@ describe('toEqualRemirrorDocument', () => {
const {
nodes: { doc, p },
add,
} = renderEditor([]);
} = renderEditor<never>([]);
const expected = p('simple');
const { state } = add(doc(expected));

Expand All @@ -75,7 +75,7 @@ describe('toEqualRemirrorDocument', () => {
const {
nodes: { doc, p },
add,
} = renderEditor([]);
} = renderEditor<never>([]);
const expected = p('simple');
const { state } = add(doc(expected));

Expand All @@ -87,7 +87,7 @@ describe('toEqualRemirrorDocument', () => {
const {
nodes: { doc, p },
add,
} = renderEditor([]);
} = renderEditor<never>([]);
const { state } = add(doc(p('old')));
const { state: newState } = add(doc(p('new')));

Expand All @@ -99,12 +99,12 @@ describe('toEqualRemirrorDocument', () => {
const {
nodes: { doc: docOld, p: pOld },
add: addOld,
} = renderEditor([]);
} = renderEditor<never>([]);

const {
nodes: { doc, p },
add,
} = renderEditor([new BoldExtension()]);
} = renderEditor<BoldExtension>([new BoldExtension()]);
const oldNode = pOld('simple');
const newNode = p('simple');
const { state: oldState } = addOld(docOld(oldNode));
Expand All @@ -120,7 +120,7 @@ describe('toEqualRemirrorState', () => {
const {
nodes: { doc, p },
add,
} = renderEditor([]);
} = renderEditor<never>([]);
const { state } = add(doc(p('Foo <start>bar<end>')));
expect(state).toEqualRemirrorState(doc(p('Foo <start>bar<end>')));
expect(state).not.toEqualRemirrorState(doc(p('Foo <cursor>bar')));
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-remirror/src/jest-remirror-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export class RemirrorTestChain<Extension extends AnyExtension> {
* ```ts
* import { HeadingExtension } from 'remirror/extensions';
*
* const editor = renderEditor([new HeadingExtension()])
* const editor = renderEditor<HeadingExtension>([new HeadingExtension()])
* const { heading } = editor.attributeNodes;
*
* heading({ level: 4, id: '1223' })('My custom heading');
Expand Down
2 changes: 1 addition & 1 deletion packages/remirror__core-helpers/src/core-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,7 @@ export function unset(path: Array<string | number>, target: Shape): Shape {
return clonedObject;
}

function makeFunctionForUniqueBy<Item = any>(value: string | string[]) {
function makeFunctionForUniqueBy<Item extends Shape = Shape>(value: string | string[]) {
return (item: Item) => {
return get(item, value as string);
};
Expand Down
26 changes: 13 additions & 13 deletions packages/remirror__core-utils/__tests__/core-utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -778,8 +778,8 @@ describe('isStateEqual', () => {
});

it('returns false with non identical schema', () => {
const a = renderEditor([]);
const b = renderEditor([]);
const a = renderEditor<never>([]);
const b = renderEditor<never>([]);
a.add(a.nodes.doc(a.nodes.p('Hello')));
b.add(b.nodes.doc(b.nodes.p('Hello')));
expect(areStatesEqual(a.state, b.state)).toBeFalse();
Expand All @@ -788,37 +788,37 @@ describe('isStateEqual', () => {

describe('areSchemasCompatible', () => {
it('is true for identical schema', () => {
const { schema } = renderEditor([]);
const { schema } = renderEditor<never>([]);
expect(areSchemasCompatible(schema, schema)).toBe(true);
});

it('is true for similar schema', () => {
const { schema: a } = renderEditor([]);
const { schema: b } = renderEditor([]);
const { schema: a } = renderEditor<never>([]);
const { schema: b } = renderEditor<never>([]);
expect(areSchemasCompatible(a, b)).toBe(true);
});

it('is false for schemas with different mark lengths', () => {
const { schema: a } = renderEditor([new BoldExtension()]);
const { schema: b } = renderEditor([]);
const { schema: a } = renderEditor<BoldExtension>([new BoldExtension()]);
const { schema: b } = renderEditor<never>([]);
expect(areSchemasCompatible(a, b)).toBe(false);
});

it('is false schemas with different marks', () => {
const { schema: a } = renderEditor([new BoldExtension()]);
const { schema: b } = renderEditor([new ItalicExtension()]);
const { schema: a } = renderEditor<BoldExtension>([new BoldExtension()]);
const { schema: b } = renderEditor<ItalicExtension>([new ItalicExtension()]);
expect(areSchemasCompatible(a, b)).toBe(false);
});

it('is false schemas with different node lengths', () => {
const { schema: a } = renderEditor([new BlockquoteExtension()]);
const { schema: b } = renderEditor([]);
const { schema: a } = renderEditor<BlockquoteExtension>([new BlockquoteExtension()]);
const { schema: b } = renderEditor<never>([]);
expect(areSchemasCompatible(a, b)).toBe(false);
});

it('is false schemas with different nodes', () => {
const { schema: a } = renderEditor([new BlockquoteExtension()]);
const { schema: b } = renderEditor([new HeadingExtension()]);
const { schema: a } = renderEditor<BlockquoteExtension>([new BlockquoteExtension()]);
const { schema: b } = renderEditor<HeadingExtension>([new HeadingExtension()]);
expect(areSchemasCompatible(a, b)).toBe(false);
});
});
Expand Down
22 changes: 11 additions & 11 deletions packages/remirror__core/__tests__/commands-extension.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ test('can chain commands', () => {
test('clears range selection', () => {
const text = 'my content';

const editor = renderEditor([]);
const editor = renderEditor<never>([]);
const { doc, p } = editor.nodes;
const { commands } = editor;

Expand All @@ -51,7 +51,7 @@ test('clears range selection', () => {
});

test('rejects clearing range selection if there is none', () => {
const editor = renderEditor([]);
const editor = renderEditor<never>([]);
const { doc, p } = editor.nodes;
const { commands } = editor;

Expand All @@ -61,7 +61,7 @@ test('rejects clearing range selection if there is none', () => {
});

test('it can select text', () => {
const editor = renderEditor([]);
const editor = renderEditor<never>([]);
const { doc, p } = editor.nodes;

editor.add(doc(p('my <cursor>content')));
Expand Down Expand Up @@ -92,7 +92,7 @@ function sleep(msDelay: number) {

describe('commands.clearRangeSelection', () => {
it('clears the selection', () => {
const editor = renderEditor([]);
const editor = renderEditor<never>([]);
const { doc, p } = editor.nodes;

editor.add(doc(p('my <head>content<anchor> is chill')));
Expand All @@ -104,7 +104,7 @@ describe('commands.clearRangeSelection', () => {
});

it('does nothing when the selection is empty', () => {
const editor = renderEditor([]);
const editor = renderEditor<never>([]);
const { doc, p } = editor.nodes;
editor.add(doc(p('my content<head><anchor> is chill')));

Expand All @@ -120,7 +120,7 @@ describe('commands.insertText', () => {
});

it('can insert text with marks', () => {
const editor = renderEditor([new BoldExtension()]);
const editor = renderEditor<BoldExtension>([new BoldExtension()]);
const { doc, p } = editor.nodes;
const { bold } = editor.marks;

Expand All @@ -135,7 +135,7 @@ describe('commands.insertText', () => {
});

it('can insert a range of text', () => {
const editor = renderEditor([]);
const editor = renderEditor<never>([]);
const { doc, p } = editor.nodes;

editor.add(doc(p('my <cursor>content')));
Expand All @@ -149,7 +149,7 @@ describe('commands.insertText', () => {
});

it('can insert text asynchronously', async () => {
const editor = renderEditor([]);
const editor = renderEditor<never>([]);
const { doc, p } = editor.nodes;
editor.add(doc(p('my <cursor>CODE!')));
const promise = sleep(100).then(() => {
Expand All @@ -168,7 +168,7 @@ describe('commands.insertText', () => {
});

it('can recover after a rejected promise', async () => {
const editor = renderEditor([]);
const editor = renderEditor<never>([]);
const { doc, p } = editor.nodes;
editor.add(doc(p('my <cursor>CODE!')));
const promise = Promise.reject();
Expand All @@ -189,7 +189,7 @@ describe('commands.insertText', () => {

describe('setContent', () => {
it('can set the content while preserving history', () => {
const editor = renderEditor([], { stringHandler: 'html' });
const editor = renderEditor<never>([], { stringHandler: 'html' });
const { doc, p } = editor.nodes;
editor.add(doc(p('my content')));

Expand All @@ -201,7 +201,7 @@ describe('setContent', () => {
});

it('can reset the content while preserving history', () => {
const editor = renderEditor([], { stringHandler: 'html' });
const editor = renderEditor<never>([], { stringHandler: 'html' });
const { doc, p } = editor.nodes;
editor.add(doc(p('my content')));

Expand Down

1 comment on commit 9c1068f

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.