-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Closed
Labels
outdatedA closed issue/PR that is archived due to age. Recommended to make a new issueA closed issue/PR that is archived due to age. Recommended to make a new issue
Description
Choose one: is this a bug report or feature request?
Bug report.
Summary
Starting in v7.0.0-beta.36, exporting a TypeScript enum causes Babel to throw an error during transpilation: "We don't know what to do with this node type. We were previously a Statement but we can't fit in here?"
Input Code
export enum A {
RECEIVE_POSTS = 'RECEIVE_POSTS',
REQUEST_POST = 'REQUEST_POST',
REQUEST_POSTS = 'REQUEST_POSTS',
REQUEST_POSTS_FAILED = 'REQUEST_POSTS_FAILED',
}
Babel/Babylon Configuration (.babelrc, package.json, cli command)
{
presets: [
['@babel/env', {
exclude: [
'transform-async-to-generator',
'transform-regenerator',
],
targets: {
browsers: ['last 2 versions'],
},
modules: false,
loose: true,
useBuiltIns: 'usage',
}],
'@babel/react',
'@babel/typescript',
['@babel/stage-0', {
loose: true,
}],
],
plugins: [
'autobind-class-methods',
['module:fast-async', {
compiler: {
lazyThenables: true,
parser: {
sourceType: 'module',
},
promises: true,
wrapAwait: true,
},
useRuntimeModule: false,
}],
'graphql-tag',
'lodash',
['styled-components', {
displayName: true,
ssr: true,
}],
'transform-promise-to-bluebird',
['@babel/transform-regenerator', {
async: false,
asyncGenerators: true,
generators: true,
}],
'@babel/transform-runtime',
],
}
Expected Behavior
Babel should transpile the exported enum.
Current Behavior
Starting in v7.0.0-beta.36, Babel throws the following error:
Error: We don't know what to do with this node type. We were previously a Statement but we can't fit in here?
at NodePath.insertAfter (/Users/daniel/Repos/Ignota/ordo-frontend/node_modules/@babel/traverse/lib/path/modification.js:126:11)
at transpileEnum (/Users/daniel/Repos/Ignota/ordo-frontend/node_modules/@babel/plugin-transform-typescript/lib/enum.js:26:14)
at PluginPass.TSEnumDeclaration (/Users/daniel/Repos/Ignota/ordo-frontend/node_modules/@babel/plugin-transform-typescript/lib/index.js:205:27)
at newFn (/Users/daniel/Repos/Ignota/ordo-frontend/node_modules/@babel/traverse/lib/visitors.js:223:21)
at NodePath._call (/Users/daniel/Repos/Ignota/ordo-frontend/node_modules/@babel/traverse/lib/path/context.js:64:19)
at NodePath.call (/Users/daniel/Repos/Ignota/ordo-frontend/node_modules/@babel/traverse/lib/path/context.js:38:17)
at NodePath.visit (/Users/daniel/Repos/Ignota/ordo-frontend/node_modules/@babel/traverse/lib/path/context.js:99:12)
at TraversalContext.visitQueue (/Users/daniel/Repos/Ignota/ordo-frontend/node_modules/@babel/traverse/lib/context.js:139:18)
at TraversalContext.visitSingle (/Users/daniel/Repos/Ignota/ordo-frontend/node_modules/@babel/traverse/lib/context.js:98:19)
at TraversalContext.visit (/Users/daniel/Repos/Ignota/ordo-frontend/node_modules/@babel/traverse/lib/context.js:180:19)
Possible Solution
¯\_(ツ)_/¯
Context
I've been using TS enums as Redux action types, and usually export them in the style above.
Your Environment
software | version(s) |
---|---|
Babel | v7.0.0-beta.36 |
node | v9.3.0 |
npm | v5.6.0 |
Operating System | macOS 10.13.3 (17D25b) |
Metadata
Metadata
Assignees
Labels
outdatedA closed issue/PR that is archived due to age. Recommended to make a new issueA closed issue/PR that is archived due to age. Recommended to make a new issue