microsoft / microsoft/TypeScript

Provide way to configure default compiler options for TS Server Inferred Project

Aperta
#39,689 3 commenti 8 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

In Discussion Suggestion
Lingua principale
Go
Stelle
111k
Fork
14.3k
Merge medio
2g 4h
PR unite (30g)
132

Descrizione

Search Terms

Inferred Project
TS Server

Suggestion

Add an option to configure the default compilerOptions for inferred projects outside of the host.

Related to: https://docs.google.com/document/d/1eB6cGCG_2ircfS5GzpDC9dBgikeYYcMxghVH5sDESHw/edit#heading=h.telvo0tzo7t0 and https://github.com/microsoft/TypeScript/issues/39632

Checklist

Use Cases

Currently, there is no way to configure the default compilerOptions for inferred projects outside of the server host. Being able to configure should options would be give a better DX when not using the default compiler options such as experimentalDecorators, strictNullChecks etc... together with stricter file inclusions, ie favoring explicitly listing the entry-point files using files instead of include with globbing.

Previously when not using TypeScript solution style tsconfig this could be achieved by adding a tsconfig.json in the root of the project which will include all files and set these options example.

{
   "compilerOptions":  {
     "experimentalDecorators": true,
     "strictNullChecks": true,
     ...
   }
}

This trickery cannot be used when using a solution style tsconfig, because the root tsconfig will not contain any files due to files: [] setting.

Examples

Ideally, compiler options for inferred projects are configured in a TypeScript configuration file. When using solution style tsconfig, such configuration can be set here.

{
 "files": [],
 "compilerOptions":  {
   "experimentalDecorators": true,
   "strictNullChecks": true,
   ...
 },
 "references": [
   {
     "path": "./tsconfig.app.json"
   },
   {
     "path": "./tsconfig.spec.json"
   }
 ]
}

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.

//cc @kyliau

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia dal comportamento di TS Server per gli inferred projects e dall’issue collegata 39632, quindi esamina come vengono gestiti i file tsconfig di tipo solution-style con files: []. Determina la posizione e la precedenza della configurazione necessarie per valori predefiniti di compilerOptions come experimentalDecorators e strictNullChecks. Il lavoro è completato quando gli inferred projects possono ricevere questi valori predefiniti senza modificare il comportamento dei progetti esistenti.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
typescript
Ambito
tooling
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.