microsoft / microsoft/TypeScript

feature request: expose `tsconfig.json` types in TypeScript files

Open
#59,261 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Awaiting More Feedback Suggestion
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
1d 19h
Merged PRs (30d)
117

Description

🔍 Search Terms

expose tsconfig.json types to developers

✅ Viability Checklist
⭐ Suggestion

It'd be nice if TypeScript developers could enforce that an object is consistent with tsconfig.json.

📃 Motivating Example

If you're creating a tool that initializes a project that uses TypeScript, you can ensure the tsconfig.json you're composing in your source code is valid.

const tsConfig: TSConfig = {
  "compilerOptions": {
    "forceConsistentCasingInFileNames": true,
    "strict": true,
    "module": "NodeNext"
  }
};

fs.writeFileSync(
  path.join(root, "tsconfig.json"),
  JSON.stringify(tsConfig, null, 2)
);
💻 Use Cases
  1. What do you want to use this for?

I'm building a tool that initializes a TypeScript project with other dependencies.

It'd be kind of nice if I could be 100% certain the tsconfig.json I'm composing in my source code is valid.

  fs.writeFileSync(
    path.join(root, "tsconfig.json"),
    JSON.stringify(
      {
        compilerOptions: {
          target: "ESNext",
          module: "CommonJS",
          jsx: "react-jsx",
        },
        include: ["src"],
        exclude: ["node_modules"],
      },
      null,
      2
    )
  );
  1. What shortcomings exist with current approaches?

In .ts source code, TypeScript doesn't verify if a tsconfig.json file being written to disk is valid or not.

  1. What workarounds are you using in the meantime?

I'm copying over an existing tsconfig.json file from a template/ subdirectory.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the tsconfig.json examples in the issue and review how TypeScript currently represents and validates compiler options. No repository files, tests, or entry points are named, so the implementation location and scope need investigation first. Done would mean TypeScript source can validate the shown configuration shape without changing emitted JavaScript.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
compilers, developer-experience
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.