Skip to content

Commit 025973d

Browse files
committed
Revert "fix: typescript types"
This reverts commit a06469f.
1 parent 41820e7 commit 025973d

File tree

3 files changed

+40
-14
lines changed

3 files changed

+40
-14
lines changed

instrumentation.node.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,9 @@ const sdk = new NodeSDK({
3030
metricReader: new PeriodicExportingMetricReader({
3131
exporter:
3232
process.env.NODE_ENV === 'production' ?
33-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
34-
new OTLPMetricExporter() as any :
35-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
36-
new ConsoleMetricExporter() as any,
37-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
38-
}) as any,
33+
new OTLPMetricExporter() :
34+
new ConsoleMetricExporter(),
35+
}),
3936
instrumentations: [
4037
getNodeAutoInstrumentations({
4138
'@opentelemetry/instrumentation-http': {

nextjs/nextjs-routes.d.ts

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55

66
// prettier-ignore
77
declare module "nextjs-routes" {
8+
import type {
9+
GetServerSidePropsContext as NextGetServerSidePropsContext,
10+
GetServerSidePropsResult as NextGetServerSidePropsResult
11+
} from "nextjs";
12+
813
export type Route =
914
| StaticRoute<"/404">
1015
| StaticRoute<"/account/api-key">
@@ -107,6 +112,33 @@ declare module "nextjs-routes" {
107112
* route({ pathname: "/foos/[foo]", query: { foo: "bar" }}) will produce "/foos/bar".
108113
*/
109114
export declare function route(r: Route): string;
115+
116+
/**
117+
* Nearly identical to GetServerSidePropsContext from next, but further narrows
118+
* types based on nextjs-route's route data.
119+
*/
120+
export type GetServerSidePropsContext<
121+
Pathname extends Route["pathname"] = Route["pathname"],
122+
Preview extends NextGetServerSidePropsContext["previewData"] = NextGetServerSidePropsContext["previewData"]
123+
> = Omit<NextGetServerSidePropsContext, 'params' | 'query' | 'defaultLocale' | 'locale' | 'locales'> & {
124+
params: Extract<Route, { pathname: Pathname }>["query"];
125+
query: Query;
126+
defaultLocale?: undefined;
127+
locale?: Locale;
128+
locales?: undefined;
129+
};
130+
131+
/**
132+
* Nearly identical to GetServerSideProps from next, but further narrows
133+
* types based on nextjs-route's route data.
134+
*/
135+
export type GetServerSideProps<
136+
Props extends { [key: string]: any } = { [key: string]: any },
137+
Pathname extends Route["pathname"] = Route["pathname"],
138+
Preview extends NextGetServerSideProps["previewData"] = NextGetServerSideProps["previewData"]
139+
> = (
140+
context: GetServerSidePropsContext<Pathname, Preview>
141+
) => Promise<NextGetServerSidePropsResult<Props>>
110142
}
111143

112144
// prettier-ignore
@@ -121,13 +153,12 @@ declare module "next/link" {
121153
} from "react";
122154
export * from "next/dist/client/link";
123155

124-
type Query = { query?: { [key: string]: string | string[] | undefined } };
125156
type StaticRoute = Exclude<Route, { query: any }>["pathname"];
126157

127158
export interface LinkProps
128159
extends Omit<NextLinkProps, "href" | "locale">,
129160
AnchorHTMLAttributes<HTMLAnchorElement> {
130-
href: Route | StaticRoute | Query;
161+
href: Route | StaticRoute | Omit<Route, "pathname">
131162
locale?: false;
132163
}
133164

@@ -155,7 +186,6 @@ declare module "next/router" {
155186

156187
type NextTransitionOptions = NonNullable<Parameters<Router["push"]>[2]>;
157188
type StaticRoute = Exclude<Route, { query: any }>["pathname"];
158-
type Query = { query?: { [key: string]: string | string[] | undefined } };
159189

160190
interface TransitionOptions extends Omit<NextTransitionOptions, "locale"> {
161191
locale?: false;
@@ -177,12 +207,12 @@ declare module "next/router" {
177207
locale?: Locale;
178208
locales?: undefined;
179209
push(
180-
url: Route | StaticRoute | Query,
210+
url: Route | StaticRoute | Omit<Route, "pathname">,
181211
as?: string,
182212
options?: TransitionOptions
183213
): Promise<boolean>;
184214
replace(
185-
url: Route | StaticRoute | Query,
215+
url: Route | StaticRoute | Omit<Route, "pathname">,
186216
as?: string,
187217
options?: TransitionOptions
188218
): Promise<boolean>;

tsconfig.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,14 @@
1818
"baseUrl": ".",
1919
"types": ["node", "jest"],
2020
},
21-
"include": ["next-env.d.ts", "**/*.ts", "**/*.node.ts", "**/*.tsx", "decs.d.ts", "global.d.ts"],
21+
"include": ["next-env.d.ts", "**/*.ts", "**/*.node.ts", "**/*.tsx", "**/*.pw.tsx", "decs.d.ts", "global.d.ts"],
2222
"exclude": [
2323
"node_modules",
2424
"node_modules_linux",
2525
"./deploy/tools/envs-validator",
2626
"./deploy/tools/favicon-generator",
2727
"./toolkit/package",
2828
"./toolkit/theme/design-system/build",
29-
"./toolkit/theme/design-system/dist",
30-
"**/*.pw.tsx"
29+
"./toolkit/theme/design-system/dist"
3130
],
3231
}

0 commit comments

Comments
 (0)