Skip to content

Commit

Permalink
Merge pull request #26524 from storybookjs/fix-ts-expect-errors
Browse files Browse the repository at this point in the history
Angular: Fix Angular sandbox startup errors
(cherry picked from commit a105385)
  • Loading branch information
valentinpalkovic authored and storybook-bot committed Mar 17, 2024
1 parent 42fae67 commit 687073b
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 13 deletions.
3 changes: 1 addition & 2 deletions code/addons/actions/src/runtime/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@ const isReactSyntheticEvent = (e: unknown): e is SyntheticEvent =>
findProto(e, (proto) => /^Synthetic(?:Base)?Event$/.test(proto.constructor.name)) &&
typeof (e as SyntheticEvent).persist === 'function'
);
const serializeArg = <T>(a: T) => {
const serializeArg = <T extends object>(a: T) => {
if (isReactSyntheticEvent(a)) {
const e: SyntheticEvent = Object.create(
// @ts-expect-error (Converted from ts-ignore)
a.constructor.prototype,
Object.getOwnPropertyDescriptors(a)
);
Expand Down
4 changes: 1 addition & 3 deletions code/addons/links/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ export const hrefTo = (title: ComponentTitle, name: StoryName): Promise<string>
return new Promise((resolve) => {
const { location } = document;
const query = parseQuery(location.search);
// @ts-expect-error (Converted from ts-ignore)
const existingId = [].concat(query.id)[0];
// @ts-expect-error (Converted from ts-ignore)
const existingId = query.id;
const titleToLink = title || existingId.split('--', 2)[0];
const id = toId(titleToLink, name);
const path = `/story/${id}`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ const logger = console;

export type PackageManagerName = 'npm' | 'yarn1' | 'yarn2' | 'pnpm';

type StorybookPackage = keyof typeof storybookPackagesVersions;

/**
* Extract package name and version from input
*
Expand Down Expand Up @@ -381,9 +383,8 @@ export abstract class JsPackageManager {
public async getVersion(packageName: string, constraint?: string): Promise<string> {
let current: string | undefined;

if (/(@storybook|^sb$|^storybook$)/.test(packageName)) {
// @ts-expect-error (Converted from ts-ignore)
current = storybookPackagesVersions[packageName];
if (packageName in storybookPackagesVersions) {
current = storybookPackagesVersions[packageName as StorybookPackage];
}

let latest;
Expand Down
4 changes: 1 addition & 3 deletions code/lib/preview-api/src/modules/preview-web/Preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,7 @@ export class Preview<TRenderer extends Renderer> {
get: (_, method) => {
if (this.storyStoreValue) {
deprecate('Accessing the Story Store is deprecated and will be removed in 9.0');

// @ts-expect-error I'm not sure if there's a way to keep TS happy here
return this.storyStoreValue[method];
return this.storyStoreValue[method as keyof StoryStore<TRenderer>];
}

throw new StoryStoreAccessedBeforeInitializationError();
Expand Down
4 changes: 2 additions & 2 deletions code/lib/test/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ const resetAllMocksLoader: LoaderFunction = ({ parameters }) => {
}
};

// @ts-expect-error We are using this as a default Storybook loader, when the test package is used. This avoids the need for optional peer dependency workarounds.
// We are using this as a default Storybook loader, when the test package is used. This avoids the need for optional peer dependency workarounds.
// eslint-disable-next-line no-underscore-dangle
global.__STORYBOOK_TEST_LOADERS__ = [resetAllMocksLoader];
(global as any).__STORYBOOK_TEST_LOADERS__ = [resetAllMocksLoader];

0 comments on commit 687073b

Please sign in to comment.