microsoft / microsoft/TypeScript

In JS, reassignment of a constructor function should work.

Offen
#22,485 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bug checkJs Domain: JavaScript
Vorherrschende Sprache
Go
Sterne
111k
Forks
14.3k
Ø Merge
1 T. 19 Std.
Gemergte PRs (30 T.)
117

Beschreibung

graceful-fs allows the user to provide a constructor function for the ReadStream class. It then modifies the function’s prototype (including modifying its base class). If no function is provided, then it provides one. This pattern should be supported as long as the provided function is assignable to the default one.

// @noEmit: true
// @allowJs: true
// @checkJs: true
// @Filename: a.js

var fs = require('fs')
/** @type {{ a: () => void }} */
var legStreams
// from graceful-fs
function patch(process) {
    if (process) {
        ReadStream = legStreams.a
    }
    ReadStream.prototype = Object.create(fs.ReadStream)
    ReadStream.prototype.open = fs$open

    function ReadStream (path, options) {
        if (this instanceof ReadStream) {
            return fs.ReadStream.apply(this, arguments), this
        }
        else {
            return ReadStream.apply(Object.create(ReadStream.prototype), arguments)
        }
    }
    function fs$open() {
    }

    // ReadStream should still be newable too!
    function createReadStream(path, options) {
        return new ReadStream(path, options)
    }

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit der a.js-Reproduktion im Issue und führe sie mit aktiviertem allowJs und checkJs aus. Verfolge, wie JavaScript-Konstruktorfunktionen typisiert werden, wenn ReadStream neu zugewiesen wird, einschließlich des späteren new ReadStream-Aufrufs. Als abgeschlossen gilt die Arbeit, wenn die Reproduktion einen zuweisbaren neu zugewiesenen Konstruktor akzeptiert und dabei seine Fähigkeit zur Instanziierung mit new beibehält.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
javascript, typescript
Bereich
compilers
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.