Typescript: Error while building a Typescript 2.1.4 project (React, Webpack, Babel)

Created on 8 Dec 2016  路  8Comments  路  Source: microsoft/TypeScript

TypeScript Version: 2.1.4

ERROR in ./src/index.tsx
Module build failed: SyntaxError: /Users/xxx/src/index.tsx: Unexpected token (11:28)
9 | var store = store_1["default"]();
  10 | function render() {
> 11 |     ReactDOM.render((<Root_1["default"] store={store}/>), document.getElementById('app-container'));
     |                             ^
  12 | }
  13 | render();
  14 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanN4Iiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiaW5kZXgudHN4Il0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSw2QkFBK0I7QUFDL0Isb0NBQXNDO0FBRXRDLDZCQUEy
/Users/xxx/node_modules/typescript/lib/typescript.js:3177
                throw new Error("Debug Failure. False expression: " + (message || "") + verboseDebugString);
                ^

Error: Debug Failure. False expression: File  has unknown extension.

We upgraded to Typescript 2.1.4 and this error happens when building our project with webpack. We are using React 15.4.1 and babel 6.18.0.

After rolling back to the old version we used everything works normally (2.0.3).

Bug Fixed

Most helpful comment

Happened to me also. Downgrading to typescript 2.0.3 fixed the issue. Same config, angular2 instead of react.

All 8 comments

That error is coming from Babel and it looks like you are using --jsx preserve, is that intentional?

you are using --target es3 (or not specifying it at all and failing back to the default). consider using --target ES5 instead.

As for this issue. we should not quote default in ES3 in a JSX element.

I have the same type of error "File has unknown extension". I have a public project here where I did a breaking branch to exemplify this error. Just run npm install and npm start or npm run build

Hope will help in debugging process.

UPD: nvm, the problem was missing @types/tether dependency (not specified in @blueprint/core package.json), I've installed it myself and everything works now

also getting the same error, https://gist.github.com/vyorkin/4e7334a1c7e31f07d7a21d15fd556562
my tsconfig.json:

{
  "compilerOptions": {
    "target": "es6",
    "lib": ["es6", "es2017", "dom"],
    "moduleResolution": "node",
    "sourceMap": true,
    "jsx": "react",
    "listFiles": true,
    "removeComments": true,
    "noImplicitAny": false,
    "noEmitOnError": false,
    "strictNullChecks": true,
    "allowJs": false,
    "outDir": "./tmp",
    "baseUrl": "./src/scripts",
    "rootDirs": [
      "src/scripts",
      "generated/css"
    ]
  },
  "exclude": [
    "tmp",
    "dist",
    "node_modules"
  ],
  "compileOnSave": false,
  "buildOnSave": false
}

package.json:

    ...
    "typescript": "^2.1.4",
    "ts-loader": "^1.2.2",
    "babel-core": "^6.18.2",
    "babel-loader": "^6.2.8",
    ...

debugger

Happened to me also. Downgrading to typescript 2.0.3 fixed the issue. Same config, angular2 instead of react.

@chetanhs that's odd - since you're probably not using JSX, can you file a separate issue and post the output you get the same way that @ottoo did?

@DanielRosenwasser my project linked above is also using angular2 (not using JSX). Should I create a separate issue too ?

{
  "compilerOptions": {
    "module": "commonjs",
    "target": "es5",
    "outDir": "dist",
    "rootDir": ".",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "moduleResolution": "node",
     "types": [
       "core-js",
       "node"
     ]
  },
  "exclude": [
    "node_modules"
  ],
  "awesomeTypescriptLoaderOptions": {
    "useWebpackText": true
  },
  "compileOnSave": false,
  "buildOnSave": false,
  "atom": { "rewriteTsconfig": false }
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

yortus picture yortus  路  157Comments

fdecampredon picture fdecampredon  路  358Comments

rbuckton picture rbuckton  路  139Comments

Gaelan picture Gaelan  路  231Comments

RyanCavanaugh picture RyanCavanaugh  路  205Comments