Skip to content

API: expose getEffectiveTypeParameterDeclarations #24248

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ajafff opened this issue May 18, 2018 · 7 comments
Closed

API: expose getEffectiveTypeParameterDeclarations #24248

ajafff opened this issue May 18, 2018 · 7 comments
Assignees
Labels
API Relates to the public API for TypeScript Fixed A PR has been merged for this issue

Comments

@ajafff
Copy link
Contributor

ajafff commented May 18, 2018

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 @sandersn

@mhegazy
Copy link
Contributor

mhegazy commented May 18, 2018

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?

@mhegazy mhegazy added the API Relates to the public API for TypeScript label May 18, 2018
@ajafff
Copy link
Contributor Author

ajafff commented May 18, 2018

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

@mhegazy
Copy link
Contributor

mhegazy commented May 19, 2018

So this is now more a suggestion to expose getEffectiveTypeParameterDeclarations

that makes sense. a PR would be appreciated.. @sandersn any concerns?

@sandersn
Copy link
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 @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.

@ajafff ajafff changed the title API: Property 'typeParameters' does not exist on type 'DeclarationWithTypeParameters'. API: expose getEffectiveTypeParameterDeclarations Jun 4, 2018
@ajafff
Copy link
Contributor Author

ajafff commented Jun 4, 2018

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.

@ajafff
Copy link
Contributor Author

ajafff commented Jun 13, 2018

@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.

@sandersn sandersn self-assigned this Jun 13, 2018
@sandersn sandersn added the Help Wanted You can do this label Jun 13, 2018
@sandersn
Copy link
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.

@sandersn sandersn added this to the TypeScript 3.0 milestone Jun 13, 2018
@mhegazy mhegazy modified the milestones: TypeScript 3.0, Future Jul 2, 2018
@sandersn sandersn added Fixed A PR has been merged for this issue and removed Help Wanted You can do this labels Jul 5, 2018
@mhegazy mhegazy modified the milestones: Future, TypeScript 3.0.1 Jul 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Relates to the public API for TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

3 participants