Skip to content

Unable to add generic function overload for module default export #31307

Open
@saschanaz

Description

@saschanaz

TypeScript Version: 3.5.0-dev.20190508

Search Terms: module add overload

Code

// nanohtml.d.ts
export default function<T extends HTMLElement = HTMLElement>(strings: TemplateStringsArray, ...keys: any[]): T;
// @ts-check
// index.js
// install [email protected]
const nanohtml = require("nanohtml");

/** @type {HTMLAnchorElement} */
const a = nanohtml`<a href="example.com">Example</a>`;

Expected behavior:

a should be HTMLAnchorElement.

Actual behavior:

Error: Type 'HTMLElement' is missing the following properties from type 'HTMLAnchorElement': ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: JSDocRelates to JSDoc parsing and type generationDomain: Type InferenceRelated to type inference performed during signature resolution or `infer` type resolutioncheckJsRelates to checking JavaScript using TypeScript

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions