microsoft / microsoft/TypeScript

Migrate `String` to `StringPrototype`, `Number` to `NumberPrototype`, etc

Aperta
#55,175 5 commenti 6 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

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

Descrizione

Suggestion

🔍 Search Terms

string prototype object number stringprototype

✅ Viability 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, new syntax sugar for JS, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.

⭐ Suggestion

We're always seeing people writing String, Number, Object, and so on, in places where they should be writing their primitive equivalents.

We should mark these as @deprecated so that they show up with strikethroughs in the editor, and make new global interfaces named e.g. StringPrototype so it's more clear what they're for.

/**
 * @deprecated Use `string` when working with strings, or use `StringPrototype` to declare new string methods
 */
interface String {

For back compat, possibly forever, we'll need to declare these as

interface StringPrototype extends String { }

so that existing references to String["charAt"] continue to work and so that other merges continue to function.

📃 Motivating Example

image

image

💻 Use Cases

  • New users coming to TS

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

La issue non indica file, test o punti di ingresso. Inizia esaminando le modifiche proposte alle interfacce globali e gli obiettivi di progettazione TypeScript collegati; il lavoro sarà completato quando saranno presenti interfacce wrapper deprecate e dichiarazioni compatibili per StringPrototype, NumberPrototype e quelle correlate, senza interrompere i riferimenti esistenti.

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.