Skip to content
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

Expose more functions of compiler api to public (from TypeChecker and Program) #17680

Closed
Busyrev opened this issue Aug 8, 2017 · 7 comments
Closed
Labels
Duplicate An existing issue was already created

Comments

@Busyrev
Copy link
Contributor

Busyrev commented Aug 8, 2017

I'm using compiler api for many code transformations, using Transformation Api (#13762) and Printing api(#13761). I can't find many functions of TypeChecker in public. They exist, they do exactly what I need, but I can't use them because they are not public. e.g function isArrayLikeType(type: Type): boolean in checker.ts. Many very useful functions are internal functions of createTypeChecker. And nobody can use them. What should I do to check if a Type is ArrayLike or not?
This question is not only about isArrayLikeType function. There are many useful functions that nobody can use except TypeChecker itself. Same issue in program.ts.
Code is splitted to many small functions and you can't just copy-paste some code, because many of this functions uses other private functions.

@deamme
Copy link

deamme commented Aug 10, 2017

Can't agree more on this. As an example I'm in need of https://github.com/Microsoft/TypeScript/blob/37b20ee670e9a89307b0e69960a2cbce104f93e5/src/compiler/utilities.ts#L322

@Busyrev
Copy link
Contributor Author

Busyrev commented Aug 10, 2017

Same pattern in https://github.com/Microsoft/TypeScript/blob/ceae613e4c0ba36829a2381687883ecdc6b169c3/src/services/services.ts#L1056
Why this pattern used? Many enclosured functions and object with this functions in the end. Why do not use usual classes for this purpose?

@mhegazy
Copy link
Contributor

mhegazy commented Aug 21, 2017

Why this pattern used? Many enclosured functions and object with this functions in the end. Why do not use usual classes for this purpose?

it is a style the TS team has picked to stay true to JS development experience. classes are becoming more mainstream now, but I do not think we will be breaking the API any time soon.

@mhegazy
Copy link
Contributor

mhegazy commented Aug 21, 2017

OP seems to be covered by #9879

@mhegazy mhegazy added the Duplicate An existing issue was already created label Aug 21, 2017
@mhegazy
Copy link
Contributor

mhegazy commented Aug 21, 2017

@deamme node.getText() is not sufficient?

@deamme
Copy link

deamme commented Aug 23, 2017

@mhegazy It is! Thank you 😄

@mhegazy
Copy link
Contributor

mhegazy commented Sep 6, 2017

Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.

@mhegazy mhegazy closed this as completed Sep 6, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

3 participants