-
Notifications
You must be signed in to change notification settings - Fork 48
TypeError: Cannot read property 'tokens' of undefined #62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi Dariusz! 👋The transformer is now async, and returns a promise. So you
need to update your preprocessor to wait for the promise to resolve. Let me
know how you get on!
…On Thu, 24 May 2018, 08:56 Dariusz Łuksza, ***@***.***> wrote:
I'm using jest-ts-preprocessor.js from #39 (comment)
<#39 (comment)>
and after upgrading to version 1.2.6 I'm getting this error:
TypeError: Cannot read property 'tokens' of undefined
18 | src
19 | }).ast;
> 20 | return generate.default(
21 | ast,
22 | {
23 | filename: file,
at new Generator (node_modules/babel-generator/lib/index.js:51:22)
at Object.exports.default (node_modules/babel-generator/lib/index.js:19:13)
at Object.process (tools/jest-ts-preprocessor.js:20:28)
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#62>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABL1qRfPH4To_CE4jI2ith1OU1A9u2yQks5t1meggaJpZM4ULvUR>
.
|
Now I do wait for the transformer to resolve, but the
|
Yes. As mentioned here you need to use babel-generator to render the ast as a string. Adapting the code in that comment to be async: var tsTransformer = require('react-native-typescript-transformer')
var rnTransformer = require('react-native/jest/preprocessor')
var generate = require('babel-generator')
var preprocessor = Object.assign({}, rnTransformer, {
async process (src, file) {
const {ast} = await tsTransformer.transform({
filename: file,
localPath: file,
options: {
dev: true,
platform: '',
projectRoot: '',
},
src,
})
return generate.default(ast, {
filename: file,
retainLines: true
}, src)
},
})
module.exports = preprocessor (I haven't tested this) |
Argh, it might not be possible: jestjs/jest#2711 In which case you'll need to revert to [email protected] |
Actually I'm going to revert to that myself. Updating source-map has raised quite a few issues and I don't believe the alleged perf wins are worth the extra work it has caused for me and other people whose builds it broke. |
This looks same as my solution, and it produces the same error. |
OK, will revert to |
Alright 1.2.9 is the same as 1.2.5. |
I'm using
jest-ts-preprocessor.js
from #39 (comment) and after upgrading to version1.2.6
I'm getting this error:The text was updated successfully, but these errors were encountered: