Skip to content

Commit

Permalink
Bundle d.ts file for use-analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
grumpyoldman-io committed Jul 12, 2023
1 parent 799c5a1 commit bb00702
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/use-analytics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@
"url": "git+https://github.com/DavidWells/analytics.git"
},
"main": "dist/index.js",
"types": "dist/index.d.ts",
"module": "dist/index.modern.js",
"source": "src/index.js",
"engines": {
"node": ">=10"
},
"scripts": {
"build": "microbundle --no-compress --format modern,cjs --jsx 'React.createElement' --jsxImportSource react --globals react/jsx-runtime=jsx",
"types": "cp ./src/index.d.ts ./dist/index.d.ts",
"build": "microbundle --no-compress --format modern,cjs --jsx 'React.createElement' --jsxImportSource react --globals react/jsx-runtime=jsx && npm run types",
"watch": "microbundle watch --no-compress --format modern,cjs --jsx 'React.createElement' --jsxImportSource react --globals react/jsx-runtime=jsx",
"release:patch": "npm version patch && npm publish",
"release:minor": "npm version minor && npm publish",
Expand Down
19 changes: 19 additions & 0 deletions packages/use-analytics/src/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
declare module 'use-analytics' {
import type { ComponentType, Context, FC, ReactNode } from 'react';
import type { AnalyticsInstance } from 'analytics';

export function withAnalytics<P extends object>(Component: ComponentType<P>): FC<P>;

export function useAnalytics(): AnalyticsInstance;
export function useTrack(): AnalyticsInstance['track'];
export function usePage(): AnalyticsInstance['page'];
export function useIdentify(): AnalyticsInstance['identify'];

export const AnalyticsConsumer: Context<AnalyticsInstance>['Consumer'];
export const AnalyticsContext: Context<AnalyticsInstance>;

export function AnalyticsProvider(props: {
instance: AnalyticsInstance;
children: ReactNode;
}): JSX.Element;
}

0 comments on commit bb00702

Please sign in to comment.