Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeError: Cannot call method 'charCodeAt' of undefined

I created a bare project with webpack with only one loader, ts-loader. Webpack is failing due to the following error:

ERROR in ./app.ts
Module build failed: TypeError: Cannot call method 'charCodeAt' of undefined
    at getRootLength (/home/ravioli/IdeaProjects/dummyWebpack/node_modules/ts-loader/node_modules/typescript/bin/typescript.js:997:18)
    at Object.isRootedDiskPath (/home/ravioli/IdeaProjects/dummyWebpack/node_modules/ts-loader/node_modules/typescript/bin/typescript.js:1051:16)
    at rootReferencePath (/home/ravioli/IdeaProjects/dummyWebpack/node_modules/ts-loader/index.js:72:23)
    at /home/ravioli/IdeaProjects/dummyWebpack/node_modules/ts-loader/index.js:87:93
    at Array.map (native)
    at ensureDependencies (/home/ravioli/IdeaProjects/dummyWebpack/node_modules/ts-loader/index.js:87:35)
    at Object.loader (/home/ravioli/IdeaProjects/dummyWebpack/node_modules/ts-loader/index.js:103:5)

When tested on vanilla Javascript files Webpack runs as expected. The error occurs when working with Typescript files and the ts-loader, where the origin of the error is (as you can see in the stack).

Problem solves once removing the following line: ///<reference path="testi.d.ts" /> (The content of the file does not affect the error - I've checked).

Here is a link to the example project, run webpack from the src_ts folder: https://github.com/ravitb/dummyWebpack

What am I missing here?!

like image 969
Ravit Avatar asked Apr 20 '15 12:04

Ravit


1 Answers

This was an issue where ts-loader was pulling in TypeScript 1.5 which had breaking changes instead of sticking with TypeScript 1.4. I've pushed out a new version (0.3.4) that should take care of this. Sorry for the problem.

like image 151
James Brantly Avatar answered Nov 08 '22 12:11

James Brantly