Skip to content

API: expose getEffectiveTypeParameterDeclarations #24248

Closed

Description

TypeScript Version: 2.9.0-dev.20180518

Search Terms:

Code

import * as ts from 'typescript';
function getTypeParameters(node: ts.DeclarationWithTypeParameters) {
    return node.typeParameters;
}

Expected behavior:

No compile error. This used to work in 2.9.0-rc

Actual behavior:

Property 'typeParameters' does not exist on type 'DeclarationWithTypeParameters'.
  Property 'typeParameters' does not exist on type 'JSDocTypedefTag'.

Playground Link: not possible

Related Issues:

caused by #23947 Nathan Shively-Sanders (@sandersn)

Activity

  1. mhegazy commented on May 18, 2018

    @mhegazy
    Contributor

    It does have type parameters, it is just not on typeParameters, it is somewhere in the same JSDoc comment..

    Can you filter out JSDocTypedefTag in your usage?

  2. ajafff commented on May 18, 2018

    @ajafff
    ContributorAuthor

    I initially reported it because it seemed unintuitive and maybe unintentional.

    Filtering out the JSDoc stuff would fix the compile error, but I'm actually interested in those type parameters.

    So this is now more a suggestion to expose getEffectiveTypeParameterDeclarations

  3. mhegazy commented on May 19, 2018

    @mhegazy
    Contributor

    So this is now more a suggestion to expose getEffectiveTypeParameterDeclarations

    that makes sense. a PR would be appreciated.. Nathan Shively-Sanders (@sandersn) any concerns?

  4. sandersn commented on May 21, 2018

    @sandersn
    Member
    1. It's a pitfall to expose both the typeParameters property and getEffectiveTypeParameterDeclarations.
    2. The name is clunky.

    Ideally we would have either

    1. A single function named getTypeParameters so Klaus Meinhardt (@ajafff) doesn't even have to write it.
    2. The parser or some other component would produce a facade for js type aliases that actually has a type parameters property, plus a pointer back to the original.

    Non-ideally, we would
    3. Expose getEffecitveTypeParmaeterDeclarations.

    (1) would break existing users of the typeParameters property. (2) might or might not be feasible. I lean toward (3) but I'm not sure how bad the break of (1) is.

  5. changed the title [-]API: Property 'typeParameters' does not exist on type 'DeclarationWithTypeParameters'.[/-] [+]API: expose getEffectiveTypeParameterDeclarations[/+] on Jun 4, 2018
  6. ajafff commented on Jun 4, 2018

    @ajafff
    ContributorAuthor

    Now that #24600 added more logic to getEffectiveTypeParameterDeclarations, I'm even more in the need of a public API for that purpose. I don't want to duplicate all that code.

  7. ajafff commented on Jun 13, 2018

    @ajafff
    ContributorAuthor

    Nathan Shively-Sanders (@sandersn) any chance this will make it into the 3.0.0 release? Otherwise I will probably rebuild that logic as part of my library tsutils.

  8. sandersn commented on Jun 13, 2018

    @sandersn
    Member

    Very high chance. However, the public API is temporarily broken because of the new build system, but that should be resolved in a day or two.

    In the meantime, I assigned myself so I don't forget and also added the help wanted tag in case somebody will have time to fix it before I do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Domain: APIRelates to the public API for TypeScriptFixedA PR has been merged for this issue

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions