Failed typescript build task for npm projects #1625

Closed
opened 2025-08-09 17:20:59 +00:00 by fergalmoran · 0 comments
Owner

Originally created by @dhhoang on 5/14/2016

The current tsconfig.json files are structured to take all *.ts files as inputs (except those from node_modules).

{
  "compilerOptions": {
    "moduleResolution": "node",
    "module": "commonjs",
    "target": "es5",
    "declaration": true,
    "outDir": "."
  },
  "exclude": [
    "node_modules"
  ]
}

This causes errors like this since the output definition file *.d.ts are also taken as inputs so they can't be overwritten.
fail
I think it would be great if we could have a unified packaging model for node projects. tsconfig.json files like this would pass the build

{
  "compilerOptions": {
    "moduleResolution": "node",
    "module": "commonjs",
    "target": "es5",
    "declaration": true,
    "outDir": "./lib/"
  },
  "exclude": [
    "node_modules",
    "lib"
  ]
}

and then in package.json

{
  "name": "redux-typed",
  "version": "1.0.0",
  "description": "Helpers for building React+Redux apps with strong TypeScript type checking everywhere",
  "main": "lib/main.js",
  "typings": "lib/main.d.ts",
  "scripts": {
    "prepublish": "tsd update && tsc && echo 'Finished building NPM package \"redux-typed\"'",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "Microsoft",
  "license": "Apache-2.0",
  "devDependencies": {
    "typescript": "^1.8.10"
  }
}
*Originally created by @dhhoang on 5/14/2016* The current tsconfig.json files are structured to take all *.ts files as inputs (except those from node_modules). ``` javascript { "compilerOptions": { "moduleResolution": "node", "module": "commonjs", "target": "es5", "declaration": true, "outDir": "." }, "exclude": [ "node_modules" ] } ``` This causes errors like this since the output definition file *.d.ts are also taken as inputs so they can't be overwritten. ![fail](https://cloud.githubusercontent.com/assets/11325809/15269163/30301292-1a21-11e6-82e0-444b28acac96.jpg) I think it would be great if we could have a unified packaging model for node projects. tsconfig.json files like this would pass the build ``` javascript { "compilerOptions": { "moduleResolution": "node", "module": "commonjs", "target": "es5", "declaration": true, "outDir": "./lib/" }, "exclude": [ "node_modules", "lib" ] } ``` and then in package.json ``` javascript { "name": "redux-typed", "version": "1.0.0", "description": "Helpers for building React+Redux apps with strong TypeScript type checking everywhere", "main": "lib/main.js", "typings": "lib/main.d.ts", "scripts": { "prepublish": "tsd update && tsc && echo 'Finished building NPM package \"redux-typed\"'", "test": "echo \"Error: no test specified\" && exit 1" }, "author": "Microsoft", "license": "Apache-2.0", "devDependencies": { "typescript": "^1.8.10" } } ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/JavaScriptServices#1625
No description provided.