{"id":17458139,"url":"https://github.com/pocesar/grunt-typescript-project","last_synced_at":"2025-04-02T21:30:03.558Z","repository":{"id":57255869,"uuid":"63170279","full_name":"pocesar/grunt-typescript-project","owner":"pocesar","description":"Make use of tsc --project, no need for extra code!","archived":false,"fork":false,"pushed_at":"2018-10-14T16:51:04.000Z","size":19,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-18T06:28:28.093Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pocesar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-07-12T15:35:51.000Z","updated_at":"2019-08-09T03:56:44.000Z","dependencies_parsed_at":"2022-09-04T23:01:36.297Z","dependency_job_id":null,"html_url":"https://github.com/pocesar/grunt-typescript-project","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pocesar%2Fgrunt-typescript-project","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pocesar%2Fgrunt-typescript-project/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pocesar%2Fgrunt-typescript-project/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pocesar%2Fgrunt-typescript-project/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pocesar","download_url":"https://codeload.github.com/pocesar/grunt-typescript-project/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246895519,"owners_count":20851284,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-18T03:55:16.703Z","updated_at":"2025-04-02T21:30:03.522Z","avatar_url":"https://github.com/pocesar.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/pocesar/grunt-typescript-project.svg?branch=master)](https://travis-ci.org/pocesar/grunt-typescript-project)\n[![npm](https://img.shields.io/npm/v/grunt-typescript-project.svg?maxAge=2592000?style=flat-square)](https://www.npmjs.com/package/grunt-typescript-project)\n[![Dependencies](https://david-dm.org/pocesar/grunt-typescript-project.svg)](https://david-dm.org/pocesar/grunt-typescript-project)\n\n# grunt-typescript-project\n\n\u003e Make use of tsc --project, no need for extra code! Yet another typescript grunt plugin but for simplicity's sake, let's lend the heavy lifting to tsc, shall we?\n\n## Getting Started\n\nThis plugin requires Grunt `^1.0.0`\n\nIf you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:\n\n```shell\nnpm install grunt-typescript-project --save-dev\n```\n\nOnce the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:\n\n```js\ngrunt.loadNpmTasks('grunt-typescript-project');\n```\n\n## Motivation\n\nThe main thing this task does is passing `options` as-is to a temporary .json file, that will call `tsc --project` on it.\nBut why? Instead of having a lot of `tsconfig.json` files inside many folders (when your project is scattered across many folders).\nPlus, you can reuse the same options and overwrite the config per target, either using files or options.\n\nSince it doesn't rely on internal API of Typescript, it should work with current and future versions, plus any future options can\nbe added to the json without having to update this plugin.\n\nAutomated tests are made against `typescript@latest`, `typescript@next`, `typescript@rc` and `typescript@1` (considered legacy now)\n\nSome features won't work with TypeScript \u003c 2 (like include, exclude, rootDirs, etc). For that, use the grunt `files`\nproperty.\n\n## The \"typescript_project\" task\n\n### Overview\n\nIn your project's Gruntfile, add a section named `typescript_project` to the data object passed into `grunt.initConfig()`.\n\n```js\ngrunt.initConfig({\n  typescript_project: {\n    options: {\n      compilerOptions: {\n        noImplicitAny: true,\n        module: \"system\",\n        target: \"es6\"\n      }\n    },\n    your_target: {\n      // ALWAYS use files, instead of src/dest\n      // Note that for EACH dest, will be created a separated TSC project json file, keep that in mind\n      files: {\n        // its a folder == outDir\n        'dest/has/no/extension': ['srcs/**/*.ts'],\n        // its a file == outFile\n        'dest/has/extension.js': ['srcs/**/*.ts']\n      },\n      options: {\n        compilerOptions: {\n          module: \"umd\"\n        },\n        include: [\n          './typings/**/*.d.ts'\n        ],\n        exclude: [\n          \"node_modules\",\n          \"jspm_packages\",\n          \"bower_components\"\n        ]\n      }\n    },\n  },\n});\n```\n\n### Options\n\nEverything that does inside `options` can be defined from this options:\n\nhttps://www.typescriptlang.org/docs/handbook/tsconfig-json.html\n\nThere are no default options, so the minimum required setting is to set [`options.tsconfig` to true (to use your\nexisting tsconfig.json file](#tsconfigjson)\n\nBy default globally installed `tsc` will be used. If you want to change that - specify path to custom compiler in\n`customCompiler` option.\n\nNote: Passing a \"files\" options will **MERGE** the ones specified in `files`. This is mainly useful to include typings\nfor all your compile targets. But don't include non typings!\n\n```js\n  grunt.initConfig({\n    typescript_project: {\n      options: {\n        customCompiler: require.resolve('./somefolder/bin/tsc'),\n        files: [\n          \"./typings/type1.d.ts\",\n          \"./typings/type2.d.ts\",\n          \"./typings/type3.d.ts\"\n        ]\n      },\n      target: {\n        files: {\n          'dest/all.js': ['moar/files/*.ts'] // will include each typings above.\n        }\n      },\n      anotherTarget: {\n        files: {\n          'dist/': ['files/**/*.ts']  // will include each typings above.\n        }\n      }\n    }\n  })\n```\n\nAlso note that tsconfig.json doesn't allow wildcards in `files`. For that, you need to use `include` (available in Typescript 2.0+)\n\nThis hasn't been tested with `compilerOptions.watch` setting.\n\nUsing `grunt typescript_project --verbose` will pass `--listFiles` to tsc internally\n\nAlso having `noEmitOnError` anywhere on your settings will make the grunt task itself fail (otherwise it will continue)\n\n### tsconfig.json\n\nYou can specify existing `tsconfig.json` files to `options.tsconfig`, that is the only option inside `options` object that doesn't\nget passed to the generated tsconfig.json is `options.tsconfig`, which can be a boolean, a string or an array of strings, it will\nmerge the current tsconfig.json specified to the options.\n\n```js\n grunt.initConfig({\n    typescript_project: {\n      target1: {\n        options: {\n          tsconfig: './tsstuff/some-tsconfig.json' // specify your own filename or another location\n        }\n      },\n      target2: {\n        options: {\n          tsconfig: ['tsconfig.json','./subfolder/tsconfig.json'] // the files will be merged from left to right, in this case\n          // subfolder/tsconfig.json will overwrite tsconfig.json configurations\n        }\n      },\n      target3: {\n        options: {\n          tsconfig: true // will use the sibling tsconfig.json from Gruntfile\n        }\n      }\n    }\n })\n```\n\nNB: The `tsconfig.json` working dir (regardless where it's placed) is considered to be the same level of `Gruntfile.js` unless\nyou specify `rootDir`. Because the merge happens with only the file contents, the plugin is unaware of file paths\n(and tampering trying to fix file paths inside the merged options is a foot gun)\n\n## Contributing\n\nIn lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpocesar%2Fgrunt-typescript-project","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpocesar%2Fgrunt-typescript-project","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpocesar%2Fgrunt-typescript-project/lists"}