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

Angular: Fix Angular sandbox startup errors #26524

Merged
merged 6 commits into from
Mar 16, 2024
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
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];
Loading