You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Expose isArrayType, isTupleType, isArrayLikeType in TypeChecker #37711
Expose isArrayType, isTupleType, isArrayLikeType in the TypeChecker interfaace
Use Cases
Today, a consumer of the TypeScript compiler API must roll their own implementation of these functions (or call into a type checker's private API) to validate some type. It would be convenient if these functions were exposed publicly instead.
This is somewhat related to #9879 but is of a much smaller scope -- here we only wish to provide comparison methods for array-like and tuple types.
Examples
Current:
import*astsfrom'typescript';functionisArrayType(type: Type,checker: ts.TypeChecker): boolean{return(checkerasany).isArrayType(type);}letty: ts.Type=makeType();if(isArrayType(ty)){// do some array things}
Suggested:
letty: ts.Type=makeType();letchecker: ts.TypeChecker=getTypeChecker();if(checker.isArrayType(ty)){// do some array things}
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. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
Activity