Closed as not planned
Closed as not planned
Description
Bug Report
Functions such as isArrayType()
and isTupleType
have a different signature in src/compiler/types.ts
and in the implementation in src/checker/types.ts
.
In src/compiler/types.ts
:
isArrayType(type: Type): boolean;
isTupleType(type: Type): boolean;
In src/compiler/checker.ts
:
isTupleType(type: Type): type is TupleTypeReference;
isArrayType(type: Type): type is TypeReference;
This means that the post-condition of these functions cannot be made use of in external code.
🔎 Search Terms
- isArrayType, isTupleType
- Signature, TypeChecker
🕗 Version & Regression Information
This was only an internal issue until these functions were exposed in #52467
💻 Code
if (typeChecker.isArrayType(type)) {
// complains that type is not TypeReference
typeChecker.getTypeArguments(type);
}
🙁 Actual behavior
TS2345 [ERROR]: Argument of type 'Type' is not assignable to parameter of type 'TypeReference'.
Type 'Type' is missing the following properties from type 'TypeReference': target, objectFlags
const typeArgument = checker.getTypeArguments(type);
🙂 Expected behavior
The code example given compiles without issues.
PS: I have a PR ready to be submitted to fix it for these particular functions