typewriter icon indicating copy to clipboard operation
typewriter copied to clipboard

Cannot find namespace 'SegmentAnalytics'.

Open dwjohnston opened this issue 2 years ago • 1 comments

Repro:

  1. Create a new create-react-app with the TypeScript template
  2. Change version down to 16. (see: https://github.com/segmentio/typewriter/issues/209)
  3. Add typewriter yarn add -D typewriter
  4. Init typewriter npx typewriter init Initialise the typewriter boilerplate in src/analytics

Open src/analytics/index.ts - You will see:

let analytics: () => SegmentAnalytics.AnalyticsJS | undefined = () => {
	return window.analytics
}

With the error:

Cannot find namespace 'SegmentAnalytics'.ts(2503)

dwjohnston avatar Sep 01 '21 05:09 dwjohnston

Installing @types/segment-analytics solves this problem.

It should be included as a dependency, or put in the installation instructions?

dwjohnston avatar Sep 01 '21 05:09 dwjohnston