Skip to content

Commit

Permalink
🔀 ✨ move global methods to a separate export
Browse files Browse the repository at this point in the history
  • Loading branch information
astoilkov committed Dec 19, 2024
1 parent f74cdbd commit 9f5fbcc
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ yarn.lock

*.js
*.d.ts
!typings.d.ts
3 changes: 3 additions & 0 deletions global.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import './src/global/typings'
export { default as addToGlobalScope } from "./src/global/addToGlobalScope";
export { default as addNoopToGlobalScope } from "./src/global/addNoopToGlobalScope";
4 changes: 0 additions & 4 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ export type { InspectInspect } from "./src/inspect/ii";
export { default as tt } from "./src/inspect/tt";
export type { TableTable } from "./src/inspect/tt";

// global
export { default as addToGlobalScope } from "./src/global/addToGlobalScope";
export { default as addNoopToGlobalScope } from "./src/global/addNoopToGlobalScope";

// inspect
export { default as consoleInspect } from "./src/inspect/consoleInspect";
export type { ConsoleInspectOptions } from "./src/inspect/consoleInspect";
Expand Down
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@
"type": "module",
"exports": {
"types": "./index.d.ts",
"default": "./index.js"
"default": "./index.js",
"global": {
"types": "./global.d.ts",
"default": "./global.js"
}
},
"sideEffects": false,
"engines": {
Expand Down
8 changes: 1 addition & 7 deletions src/global/addToGlobalScope.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
import iiFn from "../inspect/ii";
import ttFn, { type TableTable } from "../inspect/tt";
import type { InspectInspect } from "../inspect/ii";

declare global {
const ii: InspectInspect;
const tt: TableTable;
}
import ttFn from "../inspect/tt";

export default function addToGlobalScope(): void {
(global as any).ii = iiFn;
Expand Down
7 changes: 7 additions & 0 deletions src/global/typings.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type { InspectInspect } from "../inspect/ii";
import type { TableTable } from "../inspect/tt";

declare global {
const ii: InspectInspect;
const tt: TableTable;
}
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@
"exactOptionalPropertyTypes": true,
"forceConsistentCasingInFileNames": true
},
"include": ["index.ts", "./src/**/*.ts"],
"include": ["index.ts", "global.ts", "./src/**/*.ts"],
}

0 comments on commit 9f5fbcc

Please sign in to comment.