question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Configure from package.json

See original GitHub issue

Search Terms

package.json, config, configuration, tsconfig

Suggestion

Allow package.json as an alternate source for tsconfig.json options. To be clear, I am requesting that you please re-evaluate #6590 - it has been 2 years since that issue was posted, so interests may have changed and I believe this feature holds good value.

UPDATE: 2022-04-28

Please vote how you would like to see this feature implemented here: https://github.com/microsoft/TypeScript/issues/32830#issuecomment-1112372061

Use Cases

What do you want to use this for?

Provide a broader configuration support and decluttering the project root of configuration files that can easily be moved to package.json.

What shortcomings exist with current approaches?

Some users prefer to store their all their configuration files in 1 larger file. Right now, that is not an option.

Examples

Example of what the package.json would look like.

{
	"name": "example",
	"version": "1.0.0",
	"description": "This is an example",
	"license": "MIT",
	"tsconfig": {
		"compilerOptions": {
			"module": "commonjs",
			"moduleResolution": "node",
			"outDir": ".build",
			"pretty": true,
			"rootDir": "./",
			"sourceMap": true,
			"target": "ES5",
			"strict": true
		},
		"exclude": [
			"node_modules"
		],
		"include": [
			"index.ts",
			"src/**/*"
		]
	}
}

Checklist

My suggestion meets these guidelines:

  • ✅ This wouldn’t be a breaking change in existing TypeScript/JavaScript code
  • ✅ This wouldn’t change the runtime behavior of existing JavaScript code
  • ✅ This could be implemented without emitting different JS based on the types of the expressions
  • ✅ This isn’t a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
  • ✅ This feature would agree with the rest of TypeScript’s Design Goals.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:178
  • Comments:49 (13 by maintainers)

github_iconTop GitHub Comments

65reactions
ProjectCleverWebcommented, Apr 28, 2022

To get the consensus of those who are interested in this feature, please use the emojis on this comment to vote on which scenario you think the TS team should implement as the resolution to this feature request:

  • 😄 = Original Scope: The TS team should only worry about adding support for configuring TS via the package.json file, and anything more would be awesome but not required.
  • 🚀 = Extended Scope: The TS team really needs to replicate a handful of cosmiconfig’s features (discussed below where the comments mention “!CosmicFeatures” in their comment to see what features they really want)
  • 👀 = Exception Scope: The TS team needs to either make an exception to integrate cosmiconfig or at least replicate most of its features as they are all very useful and would be worth the time to integerate.
  • 👍 = Any Scope: I’ll be happy if the TS team does any of these, I just really want/need this feature.
29reactions
jakeblaxoncommented, May 3, 2021

@RyanCavanaugh Any update on this? It doesn’t seem too hard to implement, and it would be a great feature! Many of us are willing to contribute as well.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Creating a package.json file - npm Docs
To create a default package.json using information extracted from the current directory, use the npm init command with the --yes or -y flag....
Read more >
Create a package.json File | heynode.com
Enter the root folder of your project; Run npm init; Fill out the prompts to create your package.json. The easiest way to create...
Read more >
package.json configuration - Visual Studio - Microsoft Learn
Specify npm package versions using package.json.
Read more >
Configuring npm and creating a package.json | egghead.io
We have the author name, email, url, and license. One other property that I recommend setting is the save-exact property. Save-exact tells npm...
Read more >
The Basics of Package.json explained - Mario Kandut
Let's start with initiating a project to create a basic package.json . Create Folder mkdir super-mario and run npm init (option with the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found