Closed bitspook closed 8 years ago
@channikhabra paste your babelrc please, also see the notes in the readme regarding passPerPreset
Hey,
Here's me .babelrc
:
{
"presets": [
"es2015",
"stage-0",
"react"
],
"plugins": [
["typecheck", {
"disable": {
"production": true
}
}]
],
"env": {
"development": {
"presets": ["react-hmre"]
}
}
}
Settings "passPerPreset": true
make it fail with this error:
ERROR in ./src/app/index.js
Module build failed: TypeError: /Users/channi/Documents/Work/Dear-Diary/src/app/index.js: Property name of JSXOpeningElement expected node to be of a type ["JSXIdentifier","JSXMemberExpression"] but instead got "MemberExpression"
at Object.validate (/Users/channi/Documents/Work/Dear-Diary/node_modules/babel-types/lib/definitions/index.js:101:13)
at Object.validate (/Users/channi/Documents/Work/Dear-Diary/node_modules/babel-types/lib/index.js:269:9)
at NodePath._replaceWith (/Users/channi/Documents/Work/Dear-Diary/node_modules/babel-traverse/lib/path/replacement.js:201:7)
at NodePath.replaceWith (/Users/channi/Documents/Work/Dear-Diary/node_modules/babel-traverse/lib/path/replacement.js:179:8)
at Object.ReferencedIdentifier (/Users/channi/Documents/Work/Dear-Diary/node_modules/babel-plugin-transform-es2015-modules-commonjs/lib/index.js:56:14)
at Object.newFn (/Users/channi/Documents/Work/Dear-Diary/node_modules/babel-traverse/lib/visitors.js:326:17)
at NodePath._call (/Users/channi/Documents/Work/Dear-Diary/node_modules/babel-traverse/lib/path/context.js:74:18)
at NodePath.call (/Users/channi/Documents/Work/Dear-Diary/node_modules/babel-traverse/lib/path/context.js:46:17)
at NodePath.visit (/Users/channi/Documents/Work/Dear-Diary/node_modules/babel-traverse/lib/path/context.js:104:12)
at TraversalContext.visitQueue (/Users/channi/Documents/Work/Dear-Diary/node_modules/babel-traverse/lib/context.js:156:16)
@ multi app
Reordering presets to put react
at top make the above error go away, but the issue with importing types still stands.
{
"presets": [
"react",
"es2015",
"stage-0"
],
"passPerPreset": true,
"plugins": [
["typecheck", {
"disable": {
"production": true
}
}]
],
"env": {
"development": {
"presets": ["react-hmre"]
}
}
}
No luck re-ordering presets in any way (that passes compilation)
@channikhabra very odd, I'll investigate this over the next day or two
@phpnode can this be assigned a label to track the importance?
Isn't this because you are using import {AppProps}
instead of import type {AppProps}
?
Thanks @ntkoopman for pointing it out. This was the reason apparently. It was silly of me to not pay proper attention there.
@phpnode Sorry for the inconvenience.
I have types defined in a module
AppProps.js
:On importing it in another module:
It fails with runtime error:
I am using babel v6.5.2 and babel-plugin-typecheck v3.7.0
Edit: It works fine if I keep the type definition in same module where it's used.