-
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #172 from arturovt/refactor/tree-shake
refactor: tree-shake injection token names
- Loading branch information
Showing
2 changed files
with
31 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,19 @@ | ||
import { inject } from '@angular/core'; | ||
|
||
import { TIPPY_REF, type TippyInstance } from './tippy.types'; | ||
import { TIPPY_REF, TippyErrorCode, type TippyInstance } from './tippy.types'; | ||
|
||
export function injectTippyRef(): TippyInstance { | ||
const instance = inject(TIPPY_REF, { optional: true }); | ||
|
||
if (instance) { | ||
return instance; | ||
if (!instance) { | ||
if (typeof ngDevMode !== 'undefined' && ngDevMode) { | ||
throw new Error( | ||
'tp is not provided in the current context or on one of its ancestors' | ||
); | ||
} else { | ||
throw new Error(`[tp]: ${TippyErrorCode.TippyNotProvided}`); | ||
} | ||
} | ||
|
||
throw new Error('tp is not provided in the current context or on one of its ancestors'); | ||
return instance; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters