typewriter
typewriter copied to clipboard
Cannot find namespace 'SegmentAnalytics'.
Repro:
- Create a new create-react-app with the TypeScript template
- Change version down to 16. (see: https://github.com/segmentio/typewriter/issues/209)
- Add typewriter
yarn add -D typewriter
- Init typewriter
npx typewriter init
Initialise the typewriter boilerplate insrc/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)
Installing @types/segment-analytics
solves this problem.
It should be included as a dependency, or put in the installation instructions?