Attempted import error: <enum> is not exported
See original GitHub issueReally 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:
- Created 4 years ago
- Comments:10 (4 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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
Awesome! Thanks for looking into this and confirming the output! Also thanks for providing links to the pertinent code snippets!!