mirror of
https://github.com/webstudio-is/webstudio.git
synced 2026-11-06 20:13:35 +09:00
fix: types
This commit is contained in:
1 parent
81ee438a81
commit
d8e264d136
3 files changed
+21
-13
No files matched your search
Vendored
+13
-11
@@ -8,14 +8,16 @@ export type Page = {
|
||||
id: string;
|
||||
root: [string, string];
|
||||
};
|
||||
export type Project = {
|
||||
[string]:
|
||||
| {
|
||||
page: Page;
|
||||
tree: BaseInstance;
|
||||
props: Array<UserProp> | [];
|
||||
breakpoints: Array<Breakpoint> | null;
|
||||
css: string;
|
||||
}
|
||||
| string;
|
||||
};
|
||||
export type Project =
|
||||
| {
|
||||
pages: {
|
||||
[string]: {
|
||||
page: Page;
|
||||
tree: BaseInstance;
|
||||
props: Array<UserProp> | [];
|
||||
breakpoints: Array<Breakpoint> | null;
|
||||
css: string;
|
||||
};
|
||||
};
|
||||
}
|
||||
| Error;
|
||||
@@ -13,6 +13,9 @@ describe("getProjectDetails", () => {
|
||||
apiUrl,
|
||||
projectId: morePagesProjectId,
|
||||
});
|
||||
if (response instanceof Error) {
|
||||
throw response;
|
||||
}
|
||||
expect(Object.keys(response.pages).length > 1).toBeTruthy();
|
||||
});
|
||||
test("does not include pages", async () => {
|
||||
@@ -20,6 +23,9 @@ describe("getProjectDetails", () => {
|
||||
apiUrl,
|
||||
projectId: onlyHomeProjectId,
|
||||
});
|
||||
if (response instanceof Error) {
|
||||
throw response;
|
||||
}
|
||||
expect(Object.keys(response.pages).length === 1).toBeTruthy();
|
||||
});
|
||||
test("loads existing project", async () => {
|
||||
|
||||
@@ -7,7 +7,7 @@ export const loadProject = async ({
|
||||
}: {
|
||||
apiUrl: string;
|
||||
projectId: string;
|
||||
}): Promise<Project | string> => {
|
||||
}): Promise<Project> => {
|
||||
try {
|
||||
if (apiUrl === undefined) {
|
||||
throw new Error("Webstudio API URL is required.");
|
||||
@@ -24,6 +24,6 @@ export const loadProject = async ({
|
||||
if (error instanceof Error) {
|
||||
return error;
|
||||
}
|
||||
return "Unknown error";
|
||||
return new Error("Unknown error");
|
||||
}
|
||||
};
|
||||
Reference in new issue
Block a user