0

Hi I am beggining a a project with typescript and it uses grunt-ts to compile to javascript.

My configs in a file: tsconfig.json are:

{
  "compileOnSave": true,
  "compilerOptions": {
    "target": "es5",
    "noImplicitAny": true,
    "suppressImplicitAnyIndexErrors": true,
    "removeComments": false,
    "module": "amd",
    "resolveJsonModule": true,
    "strict": true,
    "rootDir": "public_html/",
    "outDir": ".tmp/",
    "sourceMap": true
  },
  "include": [
    "public_html/web/js/**/*.ts"
  ],
  "exclude": [
    "node_modules/"
  ]
}

My gruntfile.js it's huge but here it is my task that calls tsconfig.json

grunt.initConfig({
   ...
   ...
   ...
   ts: {
        dev: {
           tsconfig: "./tsconfig.json"
        }
   },
...
});

I am running typescript: version 2.9.2 and grunt-ts version 5.5.1

I have sourceMap defined as true, but when I compile the .map files are not being generated. What I am doing wrong?

UPDATE

I realize now that my .map files are being generated, altough the code it is in one line. :/

However in Chrome does not show any content in .ts files. In firefox it displays an error message

Error while fetching an original source: request failed with status 404 Source URL: http://localhost:3501/public_html/web/js...

saomi
  • 855
  • 5
  • 16
  • 38
  • You'll probably greater your chance of getting a solution/answer if you edit your question to show how your `grunt-ts` task is configured in your _Gruntfile.js_. – RobC Jul 02 '18 at 15:16
  • I @RobC. I updated my question. – saomi Jul 02 '18 at 16:32
  • 1
    When I installed `grunt-ts` it came bundled with `typescript@1.8.9` and _source maps_ were successfully created using your config. To match your _ts_ version I installed `typescript@2.9.2` as a local dependency. Then added the [compiler option](https://www.npmjs.com/package/grunt-ts#user-content-compiler) to my `grunt-ts` task in _Gruntfile.js_ as follows; `options: { compiler: './node_modules/typescript/bin/tsc' }` to instruct grunt to use the latest _ts_, and again _source maps_ were successfully created. So you may want to try adding the _compiler_ option to see if that resolves the issue. – RobC Jul 03 '18 at 08:20
  • Thanks @RobC. I realized now that my .map files are being generated. I updated the question justo now. The problem could be the path !? – saomi Jul 03 '18 at 09:26
  • Sounds like you've _probably_ moved the generated files (`.js` and `.map`) from the `.tmp/web/js` directory since they were generated. Doing this is likely to result in the relative paths created in your `.map` files being incorrect - hence the error 404 error, they cannot be found. – RobC Jul 03 '18 at 10:22

0 Answers0