Skip to content
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

TypeError: Cannot read property 'text' of undefined #13

Closed
alexgorbatchev opened this issue Oct 24, 2015 · 7 comments
Closed

TypeError: Cannot read property 'text' of undefined #13

alexgorbatchev opened this issue Oct 24, 2015 · 7 comments
Labels

Comments

@alexgorbatchev
Copy link

I'm getting an error

[10:28:53] Requiring external module ts-node/register

    project/node_modules/ts-node/dist/ts-node.js:68
            var result = output.outputFiles[1].text;
                                              ^
    TypeError: Cannot read property 'text' of undefined
        at getOutput (project/node_modules/ts-node/dist/ts-node.js:68:43)
        at compile (project/node_modules/ts-node/dist/ts-node.js:91:16)
        at Object.loader (project/node_modules/ts-node/dist/ts-node.js:94:27)
        at Module.load (module.js:355:32)
        at Function.Module._load (module.js:310:12)
        at Module.require (module.js:365:17)
        at require (module.js:384:17)
        at Liftoff.handleArguments (project/node_modules/gulp/bin/gulp.js:116:3)
        at Liftoff.<anonymous> (project/node_modules/gulp/node_modules/liftoff/index.js:192:16)
        at module.exports (project/node_modules/gulp/node_modules/liftoff/node_modules/flagged-respawn/index.js:17:3)

I've made a snapshot of the project here alexgorbatchev/gulp-typescript-webpack-react-hotreload@d6fc57f . Try running gulp dev.

@blakeembrey
Copy link
Member

Hmm, weird. I just checked out the same commit and get:

➜  gulp-typescript-webpack-react-hotreload git:(master) ✗ gulp dev
[10:59:07] Requiring external module ts-node/register
----------------------------------
⨯ Unable to compile TypeScript

gulpfile.ts (3,23): Cannot find module 'path'. (2307)
gulpfile.ts (5,14): Cannot find name 'require'. (2304)
gulpfile.ts (6,13): Cannot find name 'require'. (2304)
gulpfile.ts (7,23): Cannot find name 'require'. (2304)
gulpfile.ts (10,12): Cannot find name 'require'. (2304)
gulpfile.ts (11,14): Cannot find name 'require'. (2304)
gulpfile.ts (12,15): Cannot find name 'require'. (2304)
gulpfile.ts (13,11): Cannot find name 'require'. (2304)
gulpfile.ts (14,11): Cannot find name 'require'. (2304)
gulpfile.ts (15,12): Cannot find name 'require'. (2304)
gulpfile.ts (16,10): Cannot find name 'require'. (2304)
gulpfile.ts (17,10): Cannot find name 'require'. (2304)
gulpfile.ts (18,15): Cannot find name 'require'. (2304)
gulpfile.ts (22,85): Cannot find name 'require'. (2304)
gulpfile.ts (24,33): Cannot find name 'require'. (2304)
gulpfile.ts (64,19): Cannot find name 'require'. (2304)
gulpfile.ts (66,11): Cannot find name 'require'. (2304)
gulpfile.ts (69,14): Cannot find name 'process'. (2304)
gulpfile.ts (1,1): File '/Users/blakeembrey/Projects/tmp/gulp-typescript-webpack-react-hotreload/typings/tsd.d.ts' not found. (6053)
----------------------------------

What version of ts-node is installed?

@blakeembrey
Copy link
Member

Actually, I didn't install the typings. I have the same issue now, I'll have it fixed right away 😄

@alexgorbatchev
Copy link
Author

I've been trying to diagnose this, and I got I have a feeling that this error might be caused by issues in .tsx files.

Here's a minimum breaking/working case:

  1. delete src/client/index.tsx
  2. change src/client/app.tsx to
import * as React from 'react';

interface HelloWorldProps extends React.Props<any> {
  name: string;
  kind: string;
}

export default class App extends React.Component<HelloWorldProps, any> {
}

module.exports = App;

The above will still cause the error... Deleting kind: string; line will make the error go away... Which makes me believe it has something to do with not properly handling TypeScript compilation errors... maybe?

@blakeembrey
Copy link
Member

There's a declaration issue that I'm not collecting from TypeScript program (it's not in the language services layer). I'm refactoring it to handle it now and properly output the error.

@alexgorbatchev
Copy link
Author

giphy

@blakeembrey
Copy link
Member

@alexgorbatchev I released a patch with 0.3.0, though I'll have to do a further check later (I'm busy this weekend) to make sure the compilation speed isn't being impacted.

@alexgorbatchev
Copy link
Author

Fantastic, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants