Typescript: Expose more functions of compiler api to public (from TypeChecker and Program)

Created on 8 Aug 2017  路  7Comments  路  Source: microsoft/TypeScript

I'm using compiler api for many code transformations, using Transformation Api (https://github.com/Microsoft/TypeScript/issues/13762) and Printing api(https://github.com/Microsoft/TypeScript/pull/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.

Duplicate

Most helpful comment

All 7 comments

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?

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.

@deamme node.getText() is not sufficient?

@mhegazy It is! Thank you 馃槃

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

born2net picture born2net  路  150Comments

kimamula picture kimamula  路  147Comments

metaweta picture metaweta  路  140Comments

tenry92 picture tenry92  路  146Comments

blakeembrey picture blakeembrey  路  171Comments