TypeStrong / dts-bundle

Export TypeScript .d.ts files as an external module definition
MIT License
308 stars 57 forks source link

Cannot read property 'file' of undefined #15

Closed pgrm closed 9 years ago

pgrm commented 9 years ago

Getting the following exception, when I'm trying to bundle my precompiled d.ts files:

[19:33:57] TypeError: Cannot read property 'file' of undefined
    at C:\project\node_modules\dts-bundle\lib\index.js:489:42
    at Array.forEach (native)
    at Object.bundle (C:\project\node_modules\dts-bundle\lib\index.js:487:25)
    at Gulp.<anonymous> (C:\project\gulp\build.js:39:9)
    at module.exports (C:\project\node_modules\gulp\node_modules\orchestrator\lib\runTask.js:34:7)
    at Gulp.Orchestrator._runTask (C:\project\node_modules\gulp\node_modules\orchestrator\index.js:273:3)
    at Gulp.Orchestrator._runStep (C:\project\node_modules\gulp\node_modules\orchestrator\index.js:214:10)
    at C:\project\node_modules\gulp\node_modules\orchestrator\index.js:279:18
    at finish (C:\project\node_modules\gulp\node_modules\orchestrator\lib\runTask.js:21:8)
    at C:\project\node_modules\gulp\node_modules\orchestrator\lib\runTask.js:52:4

Not sure if this is relevant, but I've noticed that in map exports express is missing - here the map exports dts-bundle is reporting:

### map exports ###
- buffer -> C:\project\typings\node\node.d.ts
- querystring -> C:\project\typings\node\node.d.ts
- events -> C:\project\typings\node\node.d.ts
- http -> C:\project\typings\node\node.d.ts
- cluster -> C:\project\typings\node\node.d.ts
- zlib -> C:\project\typings\node\node.d.ts
- os -> C:\project\typings\node\node.d.ts
- https -> C:\project\typings\node\node.d.ts
- punycode -> C:\project\typings\node\node.d.ts
- repl -> C:\project\typings\node\node.d.ts
- readline -> C:\project\typings\node\node.d.ts
- vm -> C:\project\typings\node\node.d.ts
- child_process -> C:\project\typings\node\node.d.ts
- url -> C:\project\typings\node\node.d.ts
- dns -> C:\project\typings\node\node.d.ts
- net -> C:\project\typings\node\node.d.ts
- dgram -> C:\project\typings\node\node.d.ts
- fs -> C:\project\typings\node\node.d.ts
- path -> C:\project\typings\node\node.d.ts
- string_decoder -> C:\project\typings\node\node.d.ts
- tls -> C:\project\typings\node\node.d.ts
- crypto -> C:\project\typings\node\node.d.ts
- stream -> C:\project\typings\node\node.d.ts
- util -> C:\project\typings\node\node.d.ts
- assert -> C:\project\typings\node\node.d.ts
- tty -> C:\project\typings\node\node.d.ts
- domain -> C:\project\typings\node\node.d.ts
- mysql -> C:\project\typings\mysql\mysql.d.ts
- bluebird -> C:\project\typings\bluebird\bluebird.d.ts
- chai -> C:\project\typings\chai\chai.d.ts
- chai-http -> C:\project\typings\chai-http\chai-http.d.ts
- mocha -> C:\project\typings\mocha\mocha.d.ts
- morgan -> C:\project\typings\morgan\morgan.d.ts
- body-parser -> C:\project\typings\body-parser\body-parser.d.ts

but I'm using also express, can that be the problem? any more information I can provide you with which would help?

pgrm commented 9 years ago

I've added a simple console.log at the file in question and yes it's failing when express is used. But when compiling it, everything worked. I'm using tsd for all my usings so everything should be the same. Any clues?

pgrm commented 9 years ago

The problem was that the whole files seemed to have been commented out for dts-bundle - see https://github.com/TypeStrong/dts-bundle/issues/16 for more details

rdingwall commented 9 years ago

I had this error too, took a while to diagnose but discovered it was due to a missing /// <reference path="...d.ts" statement. Could possibly have some better error handling here.