Skip to content

Commit

Permalink
fix: error TS2578: Unused "@ts-expect-error" directive
Browse files Browse the repository at this point in the history
  • Loading branch information
harryzcy committed Sep 25, 2023
1 parent 5f7abda commit 7b603e6
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ describe('<BrowserOnly>', () => {
.create(
<Context.Provider value>
<BrowserOnly>
{/* @ts-expect-error test */}
<span>{window.location.href}</span>
</BrowserOnly>
</Context.Provider>,
Expand All @@ -50,7 +49,6 @@ describe('<BrowserOnly>', () => {
expect(() => {
renderer.create(
<Context.Provider value>
{/* @ts-expect-error test */}
<BrowserOnly> </BrowserOnly>
</Context.Provider>,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ describe('interpolate', () => {
object: {hello: 'world'},
array: ['Hello'],
};
// @ts-expect-error: test
expect(interpolate(text, values)).toMatchInlineSnapshot(
`"42 Hello [object Object] Hello"`,
);
Expand All @@ -52,7 +51,6 @@ describe('interpolate', () => {
// Should we emit warnings in such case?
const text = 'Hello {name} how are you {unprovidedValue}?';
const values = {name: 'Sébastien', extraValue: 'today'};
// @ts-expect-error: test
expect(interpolate(text, values)).toMatchInlineSnapshot(
`"Hello Sébastien how are you {unprovidedValue}?"`,
);
Expand All @@ -62,7 +60,6 @@ describe('interpolate', () => {
// Should we emit warnings in such case?
const text = 'Hello {name} how are you {day}?';
expect(interpolate(text)).toEqual(text);
// @ts-expect-error: test
expect(interpolate(text, {})).toEqual(text);
});

Expand All @@ -86,7 +83,6 @@ describe('interpolate', () => {
extraUselessValue1: <div>test</div>,
extraUselessValue2: 'hi',
};
// @ts-expect-error: test
expect(interpolate(text, values)).toMatchSnapshot();
});
});
Expand Down Expand Up @@ -128,15 +124,13 @@ describe('<Interpolate>', () => {
expect(() =>
renderer.create(
<Interpolate>
{/* @ts-expect-error: for test */}
<span>aaa</span>
</Interpolate>,
),
).toThrowErrorMatchingInlineSnapshot(
`"The Docusaurus <Interpolate> component only accept simple string values. Received: React element"`,
);
expect(() =>
// @ts-expect-error: test
renderer.create(<Interpolate>{null}</Interpolate>),
).toThrowErrorMatchingInlineSnapshot(
`"The Docusaurus <Interpolate> component only accept simple string values. Received: object"`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ describe('translate', () => {
it('rejects when no id or message', () => {
// TODO tests are not resolving type defs correctly. We need to include test
// files in a tsconfig file
// @ts-expect-error: TS should protect when both id/message are missing
expect(() => translate({})).toThrowErrorMatchingInlineSnapshot(
`"Docusaurus translation declarations must have at least a translation id or a default translation message"`,
);
Expand Down Expand Up @@ -57,7 +56,6 @@ describe('<Translate>', () => {

it('rejects when no id or message', () => {
expect(() =>
// @ts-expect-error: TS should protect when both id/message are missing
renderer.create(<Translate />),
).toThrowErrorMatchingInlineSnapshot(
`"Docusaurus translation declarations must have at least a translation id or a default translation message"`,
Expand All @@ -69,7 +67,6 @@ describe('<Translate>', () => {
renderer.create(
// eslint-disable-next-line @docusaurus/string-literal-i18n-messages
<Translate id="foo">
{/* @ts-expect-error: for test */}
<span>aaa</span>
</Translate>,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ describe('config warning and error', () => {
url: 'https://mysite.com/someSubpath',
});
expect(error).toBeDefined();
expect(error.message).toBe(
expect(error?.message).toBe(
'The url is not supposed to contain a sub-path like "/someSubpath". Please use the baseUrl field for sub-paths.',
);
});
Expand Down

0 comments on commit 7b603e6

Please sign in to comment.