File tree Expand file tree Collapse file tree 4 files changed +77
-0
lines changed
Expand file tree Collapse file tree 4 files changed +77
-0
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' @segment/analytics-next ' : minor
3+ ---
4+
5+ Export AnalyticsSnippet type and add directions (for snippet users).
Original file line number Diff line number Diff line change @@ -158,6 +158,41 @@ export default defineComponent({
158158</script>
159159```
160160
161+
162+
163+ ### For snippet users only: How to add typescript support
164+
165+ 1. Install npm package `@segment/analytics-next`
166+
167+ 2. Create `./typings/analytics.d.ts`
168+ ```ts
169+ // ./typings/analytics.d.ts
170+ import type { AnalyticsSnippet } from " @segment/analytics-next" ;
171+
172+ declare global {
173+ interface Window {
174+ analytics: AnalyticsSnippet ;
175+ }
176+ }
177+
178+ ```
179+ 3. Configure typescript to read from the custom `./typings` folder
180+ ```jsonc
181+ // tsconfig.json
182+ {
183+ ...
184+ " compilerOptions" : {
185+ ... .
186+ " typeRoots" : [
187+ " ./node_modules/@types" ,
188+ " ./typings"
189+ ]
190+ }
191+ ... .
192+ }
193+ ```
194+
195+
161196# 🐒 Development
162197
163198First, clone the repo and then startup our local dev environment:
Original file line number Diff line number Diff line change @@ -158,6 +158,41 @@ export default defineComponent({
158158</script>
159159```
160160
161+
162+
163+ ### For snippet users only: How to add typescript support
164+
165+ 1. Install npm package `@segment/analytics-next`
166+
167+ 2. Create `./typings/analytics.d.ts`
168+ ```ts
169+ // ./typings/analytics.d.ts
170+ import type { AnalyticsSnippet } from " @segment/analytics-next" ;
171+
172+ declare global {
173+ interface Window {
174+ analytics: AnalyticsSnippet ;
175+ }
176+ }
177+
178+ ```
179+ 3. Configure typescript to read from the custom `./typings` folder
180+ ```jsonc
181+ // tsconfig.json
182+ {
183+ ...
184+ " compilerOptions" : {
185+ ... .
186+ " typeRoots" : [
187+ " ./node_modules/@types" ,
188+ " ./typings"
189+ ]
190+ }
191+ ... .
192+ }
193+ ```
194+
195+
161196# 🐒 Development
162197
163198First, clone the repo and then startup our local dev environment:
Original file line number Diff line number Diff line change @@ -6,3 +6,5 @@ export * from './core/context'
66export * from './core/events'
77export * from './core/plugin'
88export * from './core/user'
9+
10+ export type { AnalyticsSnippet } from './browser/standalone-analytics'
You can’t perform that action at this time.
0 commit comments