Kotlin / dukat

Converter of <any kind of declarations> to Kotlin external declarations
553 stars 44 forks source link

TypeError: Cannot read property 'fileName' of undefined when adding `@types/semver` to dependencies #365

Open Vampire opened 4 years ago

Vampire commented 4 years ago

I added @types/semver to my dependencies and now Dukat is failing. Seems to be similar to #207.

  TypeError: Cannot read property 'fileName' of undefined
      at DependencyBuilder.buildDependencies (D:\Sourcecode\other\setup-wsl\build\js\node_modules\dukat\lib\converter.js:25983:42)
      at DependencyBuilder.buildDependencies (D:\Sourcecode\other\setup-wsl\build\js\node_modules\dukat\lib\converter.js:25997:30)
      at D:\Sourcecode\other\setup-wsl\build\js\node_modules\dukat\lib\converter.js:143:35
      at Array.forEach (<anonymous>)
      at new SourceBundleBuilder (D:\Sourcecode\other\setup-wsl\build\js\node_modules\dukat\lib\converter.js:140:23)
      at createSourceSet (D:\Sourcecode\other\setup-wsl\build\js\node_modules\dukat\lib\converter.js:186:12)
      at createBinary (D:\Sourcecode\other\setup-wsl\build\js\node_modules\dukat\bin\dukat-cli.js:126:12)
      at cliMode (D:\Sourcecode\other\setup-wsl\build\js\node_modules\dukat\bin\dukat-cli.js:170:26)
      at main (D:\Sourcecode\other\setup-wsl\build\js\node_modules\dukat\bin\dukat-cli.js:208:24)
      at Object.<anonymous> (D:\Sourcecode\other\setup-wsl\build\js\node_modules\dukat\bin\dukat-cli.js:217:5)
Vampire commented 4 years ago

The second line in the stack trace is

this.buildDependencies(this.program.getSourceFile(TsInternals_1.tsInternals.normalizePath(referenceDirective.resolvedFileName)));

I added before three outputs

console.log(referenceDirective.resolvedFileName)
console.log(TsInternals_1.tsInternals.normalizePath(referenceDirective.resolvedFileName))
console.log(this.program.getSourceFile(TsInternals_1.tsInternals.normalizePath(referenceDirective.resolvedFileName)))

Result is

D:/Sourcecode/other/setup-wsl/build/js/node_modules/@types/semver/node_modules/@types/node/ts3.7/index.d.ts
D:/Sourcecode/other/setup-wsl/build/js/node_modules/@types/semver/node_modules/@types/node/ts3.7/index.d.ts
undefined
Vampire commented 4 years ago

The file printed in the first two lines actually exists

Vampire commented 4 years ago

~And~

console.log(JSON.stringify(this.program.getFilesByNameMap()))

~outputs~

{}

~:-(~

Vampire commented 4 years ago

Forget the last comment, that seems to be irrelevant, when I directly call Dukat on it using node ../build/js/node_modules/dukat/bin/dukat-cli.js ../build/js/node_modules/@types/semver/index.d.t, it runs through, while the filesByName still shows as empty.

Vampire commented 4 years ago

Interesting, now that I switched to Kotlin/JS 1.4.0, the error vanished, using the exact same Dukat version.