microsoft / microsoft/TypeScript

Error in module-plugin.d.ts template

Offen
#31,305 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Docs
Vorherrschende Sprache
Go
Sterne
111k
Forks
14.4k
Ø Merge
1 T. 19 Std.
Gemergte PRs (30 T.)
117

Beschreibung

TypeScript Version: 3.4.5

Search Terms: module-plugin.d.ts template Module Plugin or UMD Plugin Cannot augment module 'jquery' because it resolves to a non-module entity.

Code

// This is a copy from https://www.typescriptlang.org/docs/handbook/declaration-files/templates/module-plugin-d-ts.html
// Put this file in node_modules/@types/jquery-plugin/index.d.ts
// will get an error:
// Cannot augment module 'jquery' because it resolves to a non-module entity.



// Type definitions for [~THE LIBRARY NAME~] [~OPTIONAL VERSION NUMBER~]
// Project: [~THE PROJECT NAME~]
// Definitions by: [~YOUR NAME~] <[~A URL FOR YOU~]>

/*~ This is the module plugin template file. You should rename it to index.d.ts
 *~ and place it in a folder with the same name as the module.
 *~ For example, if you were writing a file for "super-greeter", this
 *~ file should be 'super-greeter/index.d.ts'
 */

/*~ On this line, import the module which this module adds to */
import * as m from 'jquery';

/*~ Here, declare the same module as the one you imported above */
declare module 'jquery' {
    /*~ Inside, add new function, classes, or variables. You can use
     *~ unexported types from the original module if needed. */
    export function theNewMethod(): string;

    /*~ You can also add new properties to existing interfaces from
     *~ the original module by writing interface augmentations */
    export interface SomeModuleOptions {
        someModuleSetting?: string;
    }

    /*~ New types can also be declared and will appear as if they
     *~ are in the original module */
    export interface MyModulePluginOptions {
        size: number;
    }
}

Expected behavior: No errors and have code hint for this plugin

Actual behavior: Have errors

Playground Link:

Related Issues:

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 im Issue verlinkten Vorlage module-plugin.d.ts und reproduziere das gezeigte Beispiel mit TypeScript 3.4.5 und jquery. Überprüfe den Quelltext des Handbuchs, der diese Vorlage enthält, und verifiziere anschließend, dass das korrigierte Beispiel keinen Fehler bei der Modul-Erweiterung erzeugt und weiterhin Hinweise für Plugin-Code bereitstellt.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
jquery, typescript
Bereich
documentation
Issue-Typ
Dokumentation
Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
42/100

Neue Issues direkt in Ihr Postfach

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