question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Attempted import error: <enum> is not exported

See original GitHub issue

Really enjoying Typewriter. Thanks!

I ran in the following error when attempting to import types from analytics/generated/index.d.ts:

Attempted import error: 'SignupType' is not exported from '../../analytics/generated'.

This isn’t likely a bug on Typewriter’s part, but I’m struggling to proceed at this point.

Reproduction

Generated .d.ts file: (analytics/generated/index.d.ts)

export interface NewsletterSignup {
  /**
   * The type of form that was used to sign up for email
   */
  signup_type: SignupType
}

/**
 * The type of form that was used to sign up for email
 */
export enum SignupType {
  Callout = 'callout',
  Footer = 'footer'
}

analytics/index.ts

import Analytics from './generated'

declare global {
  interface Window {
    // eslint-disable-next-line @typescript-eslint/no-explicit-any
    analytics: any
  }
}

export default Analytics

Usage:

import Analytics from '../../analytics'
import { SignupType } from '../../analytics/generated'

fn({ signup_type: SignupType.Footer }) // Attempted import error: 'SignupType' is not exported from '../../analytics/generated'

Any noticeable missteps on my part? Thanks.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
colinkingcommented, Dec 9, 2019

Hey @pruett! We’ve got a pre-release out that includes enum support for the JS clients, if you want to give it a try (v7.0.2-0): https://github.com/segmentio/typewriter/pull/113

1reaction
pruettcommented, Nov 20, 2019

Awesome! Thanks for looking into this and confirming the output! Also thanks for providing links to the pertinent code snippets!!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error referring to enum imported from npm types
Solution is to simply export a const enum in the type declaration file of private-module: export const enum ServerResponseCode ...
Read more >
Attempted import error 'X' is not exported from | bobbyhadz
The React.js "Attempted import error 'X' is not exported from" occurs when we try to import a named import that is not present...
Read more >
TypeScript: Don't Export const enums - ncjamieson
If you are writing a library and you export a const enum , some developers will not be able to compile their applications...
Read more >
TSConfig Option: allowSyntheticDefaultImports - TypeScript
When the module does not explicitly specify a default export. ... This code raises an error because there isn't a default object which...
Read more >
Microsoft/TypeScript - Gitter
Also I tried to have declare module and export enum in the d.ts it didnt work ... so the error you are getting...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found