Skip to content

Suggestion: Add support for jsdoc-based templates with constrains #24283

Closed
@jantimon

Description

@jantimon

Search Terms

jsdoc template

Suggestion

This feature request is based on issue #1178.
#1178 led to the implementation of @template and was closed afterwards.

The current implementation does not allow to add constrains for a generic:

add_support_for__template_jsdoc_ issue__1178 _microsoft_typescript

The latest statement from google in 2015 was that they might add it also to the closure-compiler some day:

generic_types_ _google_closure-compiler_wiki

Use Cases

For //ts-check projects it would be possible to use the full power of generics.

Examples

playground_ _typescript

Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript / JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. new expression-level syntax)

Stackoverflow: Is it possible to constrain a generic type defined in a jsDoc @template declaration? (May 2017)

Metadata

Metadata

Assignees

Labels

Domain: JSDocRelates to JSDoc parsing and type generationFixedA PR has been merged for this issueSuggestionAn idea for TypeScript

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions