Skip to content

In JS, type parameter from @type JSDoc tag doesn't get instantiated #25618

Closed
@ajafff

Description

@ajafff

TypeScript Version: 3.0.0-dev.20180712

Search Terms:

Code

// @checkJs: true
// @allowJs: true

// @filename: test.js

/** @type {<T>(param?: T) => T | undefined} */
function typed(param) {
    return param;
}
typed(1);

Expected behavior:

Either param doesn't get it's type from the @type tag or the type parameter T applies to the function.

Actual behavior:

Argument of type '1' is not assignable to parameter of type 'T | undefined'.

Playground Link: not possible

Related Issues: #25525

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issuecheckJsRelates to checking JavaScript using TypeScript

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions