microsoft / microsoft/TypeScript

Error in module-plugin.d.ts template

Aperta
#31,305 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Docs
Lingua principale
Go
Stelle
111k
Fork
14.3k
Merge medio
1g 19h
PR unite (30g)
117

Descrizione

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:

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

Parti dal modello module-plugin.d.ts collegato nell’issue e riproduci l’esempio mostrato con TypeScript 3.4.5 e jquery. Controlla il codice sorgente del manuale che contiene quel modello, quindi verifica che l’esempio corretto non produca alcun errore di estensione del modulo e continui a fornire suggerimenti per il codice dei plugin.

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

Valutazione

Stack tecnologico
jquery, typescript
Ambito
documentation
Tipo di issue
Documentazione
Difficoltà
2/5
Tempo stimato
1-3 ore
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
42/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.