* Returns if a type is or consists of a JSLiteral object type * In addition to objects which are directly literals, * * unions where every element is a jsliteral * * intersections where at least one element is a jsliteral * * and instantiable types constrained to
(type)
| 62038 | * This mirrors the behavior of the index signature propagation, to which this behaves similarly (but doesn't affect assignability or inference). |
| 62039 | */ |
| 62040 | function isJSLiteralType(type) { |
| 62041 | if (noImplicitAny) { |
| 62042 | return false; // Flag is meaningless under `noImplicitAny` mode |
| 62043 | } |
| 62044 | if (ts.getObjectFlags(type) & 4096 /* ObjectFlags.JSLiteral */) { |
| 62045 | return true; |
| 62046 | } |
| 62047 | if (type.flags & 1048576 /* TypeFlags.Union */) { |
| 62048 | return ts.every(type.types, isJSLiteralType); |
| 62049 | } |
| 62050 | if (type.flags & 2097152 /* TypeFlags.Intersection */) { |
| 62051 | return ts.some(type.types, isJSLiteralType); |
| 62052 | } |
| 62053 | if (type.flags & 465829888 /* TypeFlags.Instantiable */) { |
| 62054 | var constraint = getResolvedBaseConstraint(type); |
| 62055 | return constraint !== type && isJSLiteralType(constraint); |
| 62056 | } |
| 62057 | return false; |
| 62058 | } |
| 62059 | function getPropertyNameFromIndex(indexType, accessNode) { |
| 62060 | return isTypeUsableAsPropertyName(indexType) ? |
| 62061 | getPropertyNameFromType(indexType) : |
no test coverage detected