microsoft / TypeScript

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
https://www.typescriptlang.org
Apache License 2.0
100.75k stars 12.46k forks source link

Add JSON schema to the `typescript` package for `tsconfig.json` and `jsconfig.json` #54192

Open scottwillmoore opened 1 year ago

scottwillmoore commented 1 year ago

Suggestion

🔍 Search Terms

✅ Viability Checklist

N/A

📃 Why

I noticed that Rome doesn't use a traditional hosted JSON schema and instead they publish their JSON schema in their package so that it can then be referenced with a local path:

{
  "$schema": "./node_modules/rome/configuration_schema.json",
}

I see three advantages to this approach...

  1. The JSON schema will match the installed version of the package.
  2. The JSON schema will work without internet access, provided that node_modules has been installed.
  3. Any changes to the JSON schema in the development can be used straight away in examples, etc.

⭐ Suggestion

Maintain the JSON schema in this repository, instead of the the SchemaStore repository. It will be kept in sync with new TypeScript releases. Finally, publish the JSON schemas in the typescript package.

You can still leave the hosted JSON schema as an option, which will always resolve to the JSON schemas for the latest version of TypeScript. This will still be needed for editor autocomplete, whereby the schema is not specified in the JSON, but detected from the name of the file.

terenc3 commented 11 months ago

I agree. A local schema file is better. compodoc is doing it also this way, see [FEATURE] Provide a JSON Schema for JSON Configuration File. #577