Skip to content

feature request: expose tsconfig.json types in TypeScript files #59261

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
6 tasks done
hamirmahal opened this issue Jul 13, 2024 · 1 comment
Open
6 tasks done

feature request: expose tsconfig.json types in TypeScript files #59261

hamirmahal opened this issue Jul 13, 2024 · 1 comment
Labels
Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Suggestion An idea for TypeScript

Comments

@hamirmahal
Copy link

πŸ” 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.

@RyanCavanaugh RyanCavanaugh added Suggestion An idea for TypeScript Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature labels Jul 15, 2024
@RyanCavanaugh
Copy link
Member

Someone can write this and put it on DefinitelyTyped; there's not really a reason this needs to be baked in to TS itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

2 participants