microsoft / microsoft/TypeScript
Error in module-plugin.d.ts template
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
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:
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start from the module-plugin.d.ts template linked in the issue and reproduce the shown example with TypeScript 3.4.5 and jquery. Check the handbook source containing that template, then verify that the corrected example produces no module-augmentation error and still provides plugin code hints.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- jquery, typescript
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100