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

Convert @ts-ignore to @ts-expect-error #19122

Merged
merged 2 commits into from
Sep 7, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion code/addons/actions/src/preview/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const isReactSyntheticEvent = (e: unknown): e is SyntheticEvent =>
const serializeArg = <T>(a: T) => {
if (isReactSyntheticEvent(a)) {
const e: SyntheticEvent = Object.create(
// @ts-ignore
// @ts-expect-error (Converted from ts-ignore)
a.constructor.prototype,
Object.getOwnPropertyDescriptors(a)
);
Expand Down
2 changes: 1 addition & 1 deletion code/addons/docs/angular/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
/* global window */

export const setCompodocJson = (compodocJson) => {
// @ts-ignore
// @ts-expect-error (Converted from ts-ignore)
window.__STORYBOOK_COMPODOC_JSON__ = compodocJson;
};
2 changes: 1 addition & 1 deletion code/addons/docs/src/preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export async function webpack(
export const storyIndexers = async (indexers: StoryIndexer[] | null) => {
const mdxIndexer = async (fileName: string, opts: IndexerOptions) => {
let code = (await fs.readFile(fileName, 'utf-8')).toString();
// @ts-ignore
// @ts-expect-error (Converted from ts-ignore)
const { compile } = global.FEATURES?.previewMdx2
? await import('@storybook/mdx2-csf')
: await import('@storybook/mdx1-csf');
Expand Down
2 changes: 1 addition & 1 deletion code/addons/jest/src/shared.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('defineJestParameter', () => {
});

test('returns null if filename is a module ID that cannot be inferred from', () => {
// @ts-ignore
// @ts-expect-error (Converted from ts-ignore)
expect(defineJestParameter({ fileName: 1234 })).toBeNull();
});
});
2 changes: 1 addition & 1 deletion code/addons/links/src/react/components/link.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jest.mock('global', () => ({
search: 'search',
},
},
// @ts-ignore
// @ts-expect-error (Converted from ts-ignore)
window: global,
__STORYBOOK_STORY_STORE__: {
getSelection: jest.fn(() => ({ id: 1 })),
Expand Down
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 @@ -5,9 +5,9 @@ import { linkTo, hrefTo } from './utils';

jest.mock('@storybook/addons');
jest.mock('global', () => ({
// @ts-ignore
// @ts-expect-error (Converted from ts-ignore)
document: global.document,
// @ts-ignore
// @ts-expect-error (Converted from ts-ignore)
window: global,
}));

Expand Down
4 changes: 2 additions & 2 deletions code/addons/links/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ export const hrefTo = (title: ComponentTitle, name: StoryName): Promise<string>
return new Promise((resolve) => {
const { location } = document;
const query = parseQuery(location.search);
// @ts-ignore
// @ts-expect-error (Converted from ts-ignore)
const existingId = [].concat(query.id)[0];
// @ts-ignore
// @ts-expect-error (Converted from ts-ignore)
const titleToLink = title || existingId.split('--', 2)[0];
const id = toId(titleToLink, name);
const url = `${location.origin + location.pathname}?${Object.entries({ ...query, id })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ function getIntegrityOptions({ integrityOptions }: StoryshotsOptions) {
};
}

// @ts-ignore
function ensureOptionsDefaults(options: StoryshotsOptions) {
const {
suite = 'Storyshots',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function integrityTest(integrityOptions: any, stories2snapsConverter: any) {
const snapshotExtension = stories2snapsConverter.getSnapshotExtension();
const storyshots = glob.sync(`**/*${snapshotExtension}`, integrityOptions);

// @ts-ignore
// @ts-expect-error (Converted from ts-ignore)
expect(storyshots).notToBeAbandoned(stories2snapsConverter);
});
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* eslint-disable camelcase */
import global from 'global';
// @ts-ignore
import { set_current_component } from 'svelte/internal';

const { document } = global;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @ts-ignore
import Vue from 'vue';

// this is defined in @storybook/vue but not exported,
Expand All @@ -14,7 +13,7 @@ function getRenderedTree(story: any) {
},
});

// @ts-ignore
// @ts-expect-error (Converted from ts-ignore)
vm[VALUES] = story.initialArgs;

return vm.$mount().$el;
Expand Down
1 change: 0 additions & 1 deletion code/examples/angular-cli/.storybook/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import { setCompodocJson } from '@storybook/addon-docs/angular';
import addCssWarning from '../src/cssWarning';

// @ts-ignore
import docJson from '../documentation.json';
// remove ButtonComponent to test #12009
const filtered = !docJson?.components
Expand Down
2 changes: 1 addition & 1 deletion code/examples/cra-kitchen-sink/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const mainConfig: StorybookConfig = {
const resolvePlugins = config.resolve?.plugins;
if (Array.isArray(resolvePlugins)) {
resolvePlugins.forEach((p) => {
// @ts-ignore
// @ts-expect-error (Converted from ts-ignore)
const appSrcs = p.appSrcs as unknown as string[];
if (Array.isArray(appSrcs)) {
appSrcs.push(path.join(__dirname, '..', '..', '..'));
Expand Down
2 changes: 1 addition & 1 deletion code/examples/cra-ts-essentials/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const mainConfig: StorybookConfig = {
const resolvePlugins = config.resolve?.plugins;
if (Array.isArray(resolvePlugins)) {
resolvePlugins.forEach((p) => {
// @ts-ignore
// @ts-expect-error (Converted from ts-ignore)
const appSrcs = p.appSrcs as unknown as string[];
if (Array.isArray(appSrcs)) {
appSrcs.push(path.join(__dirname, '..', '..', '..'));
Expand Down
2 changes: 1 addition & 1 deletion code/examples/cra-ts-kitchen-sink/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const mainConfig: StorybookConfig = {
const resolvePlugins = config.resolve?.plugins;
if (Array.isArray(resolvePlugins)) {
resolvePlugins.forEach((p) => {
// @ts-ignore
// @ts-expect-error (Converted from ts-ignore)
const appSrcs = p.appSrcs as unknown as string[];
if (Array.isArray(appSrcs)) {
appSrcs.push(path.join(__dirname, '..', '..', '..'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export const ButtonReactFC: React.FC<ButtonProps> = ({ onClick, children }) => (
<button onClick={onClick}>{children}</button>
);
ButtonReactFC.defaultProps = {
// @ts-ignore
onClick: null,
};

Expand All @@ -26,7 +25,6 @@ export const ButtonFC: FC<ButtonProps> = ({ onClick, children }) => (
<button onClick={onClick}>{children}</button>
);
ButtonFC.defaultProps = {
// @ts-ignore
onClick: null,
};

Expand All @@ -37,6 +35,5 @@ export const ButtonFunctionComponent: FC<ButtonProps> = ({ onClick, children })
<button onClick={onClick}>{children}</button>
);
ButtonFunctionComponent.defaultProps = {
// @ts-ignore
onClick: null,
};
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @ts-ignore
// @ts-expect-error (Converted from ts-ignore)
import PropTypes from 'prop-types';

export const PRESET_SHAPE = {
Expand Down
2 changes: 1 addition & 1 deletion code/examples/vue-3-cli/.storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Parameters, setup } from '@storybook/vue3';
// @ts-ignore
// @ts-expect-error (Converted from ts-ignore)
import Button from '../src/stories/Button.vue';

// TODO: I'd like to be able to export rather than imperatively calling an imported function
Expand Down
2 changes: 1 addition & 1 deletion code/examples/vue-3-cli/src/stories/Button.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default defineComponent({

emits: ['click'],

// @ts-ignore
// @ts-expect-error (Converted from ts-ignore)
setup(props, { emit }) {
props = reactive(props);
return {
Expand Down
2 changes: 0 additions & 2 deletions code/examples/vue-3-cli/src/stories/DynamicHeading.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export default {
const story = storyFn();
// Vue 3 "Functional" component as decorator
return () => {
// @ts-ignore // this is an unfortunate side-effect of having vue & vue3 in 1 repo
return h('div', { style: 'border: 2px solid red' }, h(story));
};
},
Expand All @@ -27,7 +26,6 @@ export default {

Make sure to pass the `args` the component expects to receive as the props!
*/
// @ts-ignore // this is an unfortunate side-effect of having vue & vue3 in 1 repo
const Template: StoryFn<Props> = (args, { argTypes }) => {
const component: FunctionalComponent<Props> = () => h(DynamicHeading, args, 'Hello World!');
component.props = Object.keys(argTypes);
Expand Down
2 changes: 1 addition & 1 deletion code/examples/vue-3-cli/src/stories/OverrideArgs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default {
},
},

// @ts-ignore
// @ts-expect-error (Converted from ts-ignore)
setup(props, { emit }) {
const classes = {
'storybook-button': true,
Expand Down
1 change: 0 additions & 1 deletion code/frameworks/angular/src/client/angular/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @ts-ignore
import global from 'global';
import { enableProdMode, NgModule, Component, NgModuleRef, Type, NgZone } from '@angular/core';
import { FormsModule } from '@angular/forms';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { sync as spawnSync } from 'cross-spawn';

import { findComponentByName, extractArgTypesFromData } from './compodoc';

// @ts-ignore
// @ts-expect-error (Converted from ts-ignore)
const { SNAPSHOT_OS } = global;

// File hierarchy: __testfixtures__ / some-test-case / input.*
Expand Down
5 changes: 2 additions & 3 deletions code/frameworks/angular/src/client/docs/compodoc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ export const isMethod = (methodOrProp: Method | Property): methodOrProp is Metho
};

export const setCompodocJson = (compodocJson: CompodocJson) => {
// @ts-ignore
// @ts-expect-error (Converted from ts-ignore)
window.__STORYBOOK_COMPODOC_JSON__ = compodocJson;
};

// @ts-ignore
// @ts-expect-error (Converted from ts-ignore)
export const getCompodocJson = (): CompodocJson => window.__STORYBOOK_COMPODOC_JSON__;

export const checkValidComponentOrDirective = (component: Component | Directive) => {
Expand Down Expand Up @@ -191,7 +191,6 @@ const extractDefaultValueFromComments = (property: Property, value: any) => {
let commentValue = value;
property.jsdoctags.forEach((tag: JsDocTag) => {
if (['default', 'defaultvalue'].includes(tag.tagName.escapedText)) {
// @ts-ignore
const dom = new window.DOMParser().parseFromString(tag.comment, 'text/html');
commentValue = dom.body.textContent;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ function mergeAngularCliWebpackConfig(
// styleWebpackConfig.entry adds global style files to the webpack context
const entry = [
...(baseConfig.entry as string[]),
// @ts-ignore
...Object.values(cliStyleWebpackConfig.entry).reduce((acc, item) => acc.concat(item), []),
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,6 @@ const buildWebpackConfigOptions = async (
sourceMap: {},
styles: [],
// Deleted in angular 12. Keep for compatibility with versions lower than angular 12
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
lazyModules: [],

// Project Options
Expand All @@ -139,8 +137,7 @@ const buildWebpackConfigOptions = async (
statsJson: false,

// Deleted in angular 12. Keep for compatibility with versions lower than angular 12
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
// @ts-expect-error (Converted from ts-ignore)
forkTypeChecker: false,
};

Expand Down
2 changes: 1 addition & 1 deletion code/frameworks/ember/src/client/preview/render.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import global from 'global';
import { dedent } from 'ts-dedent';
import type { RenderContext } from '@storybook/store';
// @ts-ignore
// @ts-expect-error (Converted from ts-ignore)
import Component from '@ember/component'; // eslint-disable-line import/no-unresolved
import { OptionsArgs, EmberFramework } from './types';

Expand Down
9 changes: 4 additions & 5 deletions code/jest.init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ import '@testing-library/jest-dom';

// setup file
import { configure } from 'enzyme';
// @ts-ignore
// @ts-expect-error (Converted from ts-ignore)
import Adapter from 'enzyme-adapter-react-16';
// @ts-ignore
// @ts-expect-error (Converted from ts-ignore)
import regeneratorRuntime from 'regenerator-runtime';
// @ts-ignore
import registerRequireContextHook from '@storybook/babel-plugin-require-context-hook/register';
import EventEmitter from 'events';

Expand All @@ -25,9 +24,9 @@ const localStorageMock = {
setItem: jest.fn().mockName('setItem'),
clear: jest.fn().mockName('clear'),
};
// @ts-ignore
// @ts-expect-error (Converted from ts-ignore)
global.localStorage = localStorageMock;
// @ts-ignore
// @ts-expect-error (Converted from ts-ignore)
global.regeneratorRuntime = regeneratorRuntime;

configure({ adapter: new Adapter() });
Expand Down
4 changes: 2 additions & 2 deletions code/lib/addons/src/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,11 +329,11 @@ function useStateLike<S>(
): [S, (update: ((prevState: S) => S) | S) => void] {
const stateRef = useRefLike(
name,
// @ts-ignore S type should never be function, but there's no way to tell that to TypeScript
// @ts-expect-error S type should never be function, but there's no way to tell that to TypeScript
typeof initialState === 'function' ? initialState() : initialState
);
const setState = (update: ((prevState: S) => S) | S) => {
// @ts-ignore S type should never be function, but there's no way to tell that to TypeScript
// @ts-expect-error S type should never be function, but there's no way to tell that to TypeScript
stateRef.current = typeof update === 'function' ? update(stateRef.current) : update;
triggerUpdate();
};
Expand Down
2 changes: 1 addition & 1 deletion code/lib/api/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ interface ManagerConsumerProps<P = unknown> {
const defaultFilter = (c: Combo) => c;

function ManagerConsumer<P = Combo>({
// @ts-ignore
// @ts-expect-error (Converted from ts-ignore)
filter = defaultFilter,
children,
}: ManagerConsumerProps<P>): ReactElement {
Expand Down
2 changes: 1 addition & 1 deletion code/lib/api/src/modules/versions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import global from 'global';
// @ts-ignore
// @ts-expect-error no typedefs
import semver from '@storybook/semver';
import memoize from 'memoizerific';

Expand Down
1 change: 0 additions & 1 deletion code/lib/api/src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import storeSetup from './lib/store-setup';
import type { State } from './index';

// setting up the store, overriding set and get to use telejson
// @ts-ignore
storeSetup(store._);

export const STORAGE_KEY = '@storybook/ui/store';
Expand Down
2 changes: 1 addition & 1 deletion code/lib/blocks/src/blocks/Props.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const Props = deprecate(
`
);

// @ts-ignore
// @ts-expect-error (Converted from ts-ignore)
Props.defaultProps = {
of: PRIMARY_STORY,
};
9 changes: 4 additions & 5 deletions code/lib/blocks/src/blocks/mdx.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ function navigate(context: DocsContextProps, url: string) {
context.channel.emit(NAVIGATE_URL, url);
}

// @ts-ignore
const A = components.a;

interface AnchorInPageProps {
Expand Down Expand Up @@ -124,7 +123,7 @@ const SUPPORTED_MDX_HEADERS = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
const OcticonHeaders = SUPPORTED_MDX_HEADERS.reduce(
(acc, headerType) => ({
...acc,
// @ts-ignore
// @ts-expect-error (Converted from ts-ignore)
[headerType]: styled(components[headerType])({
'& svg': {
visibility: 'hidden',
Expand Down Expand Up @@ -159,7 +158,7 @@ const HeaderWithOcticonAnchor: FC<HeaderWithOcticonAnchorProps> = ({
}) => {
const context = useContext(DocsContext);

// @ts-ignore
// @ts-expect-error (Converted from ts-ignore)
const OcticonHeader = OcticonHeaders[as];
const hash = `#${id}`;

Expand Down Expand Up @@ -213,7 +212,7 @@ export const HeaderMdx: FC<HeaderMdxProps> = (props) => {
);
}

// @ts-ignore
// @ts-expect-error (Converted from ts-ignore)
const Header = components[as];

// Make sure it still work if "remark-slug" plugin is not present.
Expand All @@ -223,7 +222,7 @@ export const HeaderMdx: FC<HeaderMdxProps> = (props) => {
export const HeadersMdx = SUPPORTED_MDX_HEADERS.reduce(
(acc, headerType) => ({
...acc,
// @ts-ignore
// @ts-expect-error (Converted from ts-ignore)
[headerType]: (props: object) => <HeaderMdx as={headerType} {...props} />,
}),
{}
Expand Down
Loading