Skip to content

Commit

Permalink
fix: expose terminal type (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
Papooch authored Sep 21, 2022
1 parent e85a876 commit 6688b02
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ export * from './lib/cls.module';
export * from './lib/cls.service';
export * from './lib/cls.decorators';
export * from './lib/cls.interfaces';
export { Terminal } from './types/terminal.type';
2 changes: 1 addition & 1 deletion src/lib/cls.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Test, TestingModule } from '@nestjs/testing';
import { Terminal } from '../types/recursive-key-of.type';
import { Terminal } from '../types/terminal.type';
import { ClsServiceManager } from './cls-service-manager';
import { CLS_DEFAULT_NAMESPACE, CLS_ID } from './cls.constants';
import { ClsStore } from './cls.interfaces';
Expand Down
8 changes: 2 additions & 6 deletions src/types/recursive-key-of.type.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { BrandedTerminal } from './terminal.type';

type TerminalType =
| string
| number
Expand All @@ -13,12 +15,6 @@ type TerminalType =
| BrandedTerminal
| ((...args: any) => any);

const TERMINAL_BRAND = Symbol();
class BrandedTerminal {
private [TERMINAL_BRAND]?: void;
}
export type Terminal<T> = T & BrandedTerminal;

/**
* Deep nested keys of an interface with dot syntax
*
Expand Down
10 changes: 10 additions & 0 deletions src/types/terminal.type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const TERMINAL_BRAND = Symbol();
export class BrandedTerminal {
private [TERMINAL_BRAND]?: void;
}

/**
* Use the terminal type to prevent generation of property
* paths to nested properties of the type within the ClsStore
*/
export type Terminal<T> = T & BrandedTerminal;

0 comments on commit 6688b02

Please sign in to comment.