Typescript: ...but allowJs is not set...

Created on 6 Mar 2017  路  8Comments  路  Source: microsoft/TypeScript



TypeScript Version: 2.1.5.0

I needed to include a javascript file into my project, it is the only js file in the typescript project.

linqts

Code

// The compiler options in tsconfig.json with allowJs = true;
"compilerOptions": {    
    "allowJs": true,
    "module": "amd",
    "moduleResolution": "node",
    "target": "es2016",

    "lib": [
      "es2016",
      "dom"
    ],

//The build portion of pacakge.json
 "scripts": {
    "build": "tsc -p .",
    "postbuild": "npm run package",
    "package": "node_modules\\.bin\\tfx extension publish --output-path bin --token %VSTSMarketplaceToken% --manifest-globs vss-extension.json --rev-version --publisher %VSTSMarketplacePublisher%",
    "clean": "rimraf ./dist && rimraf ./*.vsix"
  },

The compiler error at build time in VS2015 Project:
compile

Expected behavior:
Should be able to include a js file in typescript project using the tsconfig.json compiler option of allowjs to be true.

Actual behavior:
Even though the compiler option is set to allowJs = true, the error indicates it's not set.
...but allowJs is not set...

Needs More Info

Most helpful comment

I didn't mean that compile on save relates to a transpile-in-the-browser. I meant that Visual Studio not seeming to recognize that tsconfig.json exists could be causing the "...but allowJs is not set..." and the fact that typescript files won't compile on save.

All 8 comments

Do you have a tsconfig.json included in your project? does it have "Content" content type when you look at its properties in your property explorer? can you share a project? can you share a build log?

I also have this problem too, and I include tsconfig.json in to my project.

@Ratimon can you share your project and/or your tsconfig.json

Many thanks for response ,but I tried fixing and error changes to
[at-loader] TS5053: Option 'allowJs' cannot be specified with option 'declaration'. but if I remove "declaration": true, It will throw this message
"TS5052: Option 'declarationDir' cannot be specified without specifying option 'declaration'."

This is my project repository at branch 'errorWithAllowjs' https://github.com/Ratimon/MyDWallet/tree/errorWithAllowjs

I have the same issue. I have a sample project here. It uses system.js and plugin-typescript to transpile TypeScript on the fly in the browser, doing so allows the project to run which is great for development. Unfortunately this won't be suitable in a production app. If you run the app, the typescript module just uses jQuery append text to the footer.

I use npm for all client side dependencies(as opposed to bower) and then use gulp to copy them to the wwwroot directory.

The file with the issue here is wwwroot/js/app/ts/exporter.ts.

Another issue I have which I believe is related, is that typescript files won't compile on save. It seems like Visual Studio isn't picking up tsconfig.json.

I'm curious how compile on save relates to a transpile-in-the-browser during development (which I prefer by the way) and bundle for production setup. I usually set "noEmit": true so I can run tsc on demand to ensure there are no type errors without compiling files.

I didn't mean that compile on save relates to a transpile-in-the-browser. I meant that Visual Studio not seeming to recognize that tsconfig.json exists could be causing the "...but allowJs is not set..." and the fact that typescript files won't compile on save.

I figured it out, at least for myself. Visual Studio expects tsconfig.json to be in wwwroot/scripts, as I found here.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

siddjain picture siddjain  路  3Comments

CyrusNajmabadi picture CyrusNajmabadi  路  3Comments

blendsdk picture blendsdk  路  3Comments

bgrieder picture bgrieder  路  3Comments

DanielRosenwasser picture DanielRosenwasser  路  3Comments