Skip to content

Commit

Permalink
refactor: align vike-{react,vue,solid}
Browse files Browse the repository at this point in the history
  • Loading branch information
brillout committed Aug 19, 2024
1 parent 1541a5c commit 619f9ca
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 18 deletions.
12 changes: 7 additions & 5 deletions vike-solid/+config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
export { config };

import type { Config } from "vike/types";
import { ssrEffect } from "./renderer/ssrEffect.js";

// This is required to make TypeScript load the global interfaces such as Vike.PageContext so that they're always loaded.
// We can assume that the user always imports this file over `import vikeSolid from 'vike-solid/config'`
import "./types/index.js";

export default {
const config = {
name: "vike-solid",
require: {
vike: ">=0.4.182",
Expand Down Expand Up @@ -74,3 +72,7 @@ export default {
},
},
} satisfies Config;

// This is required to make TypeScript load the global interfaces Vike.Config and Vike.PageContext so that they're always loaded: we can assume that the user always imports this file over `import vikeSolid from 'vike-solid/config'`
import "./types/Config.js";
import "./types/PageContext.js";
19 changes: 8 additions & 11 deletions vike-solid/types/Config.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
// https://vike.dev/meta#typescript
import type { Component, JSX } from "solid-js";

import type {
PageContextServer,
// Rename it to `PageContext_` to be able to reference it from within `namespace Vike`
// - https://stackoverflow.com/questions/46559021/typescript-use-of-global-type-inside-namespace-with-same-type
// - https://github.com/Microsoft/TypeScript/issues/983
PageContext as PageContext_,
PageContextClient,
} from "vike/types";
import type { PageContextServer, PageContext, PageContextClient } from "vike/types";
import type { TagAttributes } from "../utils/getTagAttributesString";
import type { Viewport } from "../renderer/onRenderHtml";
import type { ConfigsCumulative } from "../hooks/useConfig/configsCumulative";
import type { Component, JSX } from "solid-js";

// https://vike.dev/meta#typescript
declare global {
namespace Vike {
interface Config {
Expand Down Expand Up @@ -169,6 +161,11 @@ declare global {
}
}

// Be able to reference it from within `namespace Vike`
// - https://stackoverflow.com/questions/46559021/typescript-use-of-global-type-inside-namespace-with-same-type
// - https://github.com/Microsoft/TypeScript/issues/983
type PageContext_ = PageContext;

export type Head = Component | JSX.Element;

// JSDocs are preserved
Expand Down
2 changes: 0 additions & 2 deletions vike-solid/types/index.ts

This file was deleted.

0 comments on commit 619f9ca

Please sign in to comment.