Skip to content

Commit

Permalink
E Extract client/server globals into type declaration files
Browse files Browse the repository at this point in the history
E Extract client/server globals into type declaration files
  • Loading branch information
dreamora committed Mar 30, 2023
1 parent 58075d3 commit ca88bf0
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 20 deletions.
6 changes: 1 addition & 5 deletions packages/client/src/transport/configuration-repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ import { NamespaceMapping } from "@quatico/magellan-shared";
import { Configuration } from "./Configuration";
import { getDefaultConfiguration } from "./default-configuration";

declare global {
var __qsMagellanConfig__: Configuration;
}

export const initProjectConfiguration = (projectConfiguration: Partial<Configuration>): Configuration => {
return persistConfig(expandConfig(projectConfiguration));
};
Expand Down Expand Up @@ -45,4 +41,4 @@ const completeNamespaces = (namespaceMapping: Record<string, NamespaceMapping>):

const completeNamespace = (mapping: NamespaceMapping): NamespaceMapping => {
return { transport: "default", ...mapping };
};
};
3 changes: 2 additions & 1 deletion packages/client/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"src/**/*.spec.tsx"
],
"include": [
"src"
"src",
"types"
]
}
7 changes: 7 additions & 0 deletions packages/client/types/global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export {};
import { Configuration } from "../src";

declare global {
// eslint-disable-next-line no-var
var __qsMagellanConfig__: Configuration;
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ import { getDependencyContext, getFunctionService } from "../services";
import { Configuration } from "./Configuration";
import { getDefaultConfiguration } from "./default-configuration";

declare global {
var __qsMagellanServerConfig__: Configuration;
}

export const initProjectConfiguration = (projectConfiguration: Partial<Configuration>): Configuration => {
return setConfiguration(expandConfig(projectConfiguration));
};
Expand Down Expand Up @@ -69,4 +65,4 @@ const completeNamespaces = (namespaceMapping: Record<string, NamespaceMapping>):

const completeNamespace = (mapping: NamespaceMapping): NamespaceMapping => {
return { transport: "default", ...mapping };
};
};
6 changes: 1 addition & 5 deletions packages/server/src/services/DependencyContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ export type DependencyContext = {
defaultTransportHandler: TransportHandler;
};

declare global {
var __qsMagellanDI__: DependencyContext;
}

export const initDependencyContext = (diContext: DependencyContext) => {
global.__qsMagellanDI__ = diContext;
};
Expand All @@ -27,4 +23,4 @@ export const getDependencyContext = (): DependencyContext | never => {
throw new Error("Dependency Context not initialized");
}
return global.__qsMagellanDI__;
};
};
15 changes: 11 additions & 4 deletions packages/server/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "./lib",
"outDir": "./lib"
},
"exclude": ["node_modules", "src/**/*.spec.ts", "src/**/*.test.ts"],
"include": ["src/**/*.ts"]
}
"exclude": [
"node_modules",
"src/**/*.spec.ts",
"src/**/*.test.ts"
],
"include": [
"src/**/*.ts",
"types"
]
}
10 changes: 10 additions & 0 deletions packages/server/types/global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* eslint-disable no-var */
import { DependencyContext } from "../src/services";
import { Configuration } from "../src";

export {};

declare global {
var __qsMagellanServerConfig__: Configuration;
var __qsMagellanDI__: DependencyContext;
}

0 comments on commit ca88bf0

Please sign in to comment.