microsoft / microsoft/TypeScript

[Feature request] keyword `final` type for output full final type in .d.ts

Aperta
#31,154 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Awaiting More Feedback Domain: Declaration Emit Suggestion
Lingua principale
Go
Stelle
111k
Fork
14.4k
Merge medio
1g 19h
PR unite (30g)
117

Descrizione

Search Terms

Suggestion

with keyword final, output a final type typescript know in .d.ts

Use Cases

this help when we import a.ts will didn't need import other file for get type info

Examples

b.ts

export type A2 = {
	a: number,
}

export type B2 = {
	b: number,
}
origin

a.ts

import { A2, B2 } from './b'

type A1 = {
	a: number,
}

type B1 = {
	b: number,
}

export type C1 = A1 & B1
export type C2 = A2 & B2

=>

.d.ts

import { A2, B2 } from './b';
declare type A1 = {
    a: number;
};
declare type B1 = {
    b: number;
};
export declare type C1 = A1 & B1;
export declare type C2 = A2 & B2;
with keyword final

a.ts

import { A2, B2 } from './b'

export type A1 = {
	a: number,
}

export type B1 = {
	b: number,
}

export final type C1 = A1 & B1
export final type C2 = A2 & B2

=>

will no need to know what is A1 B1

and also will not import b.ts for know what is A2, B2 when import a.ts

export declare type C1 = {
	a: number,
	b: number,
}
export declare type C2 = {
	a: number,
	b: number,
}

or

export declare type C1 = {
	a: number,
} & {
	b: number,
}
export declare type C2 = {
	a: number,
} & {
	b: number,
}

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.

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 confrontando gli esempi a.ts e b.ts con l’output .d.ts richiesto e chiarendo la semantica prevista del tipo finale proposto. Nell’issue non sono indicati file del repository né test; per considerarla completata sarebbero necessari un design concordato e un comportamento corrispondente del compilatore per i casi mostrati.

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

Valutazione

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

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.