(type: Type)
| 206 | |
| 207 | // FIXME: This is the same as for C#. |
| 208 | protected namedTypeToNameForTopLevel(type: Type): NamedType | null { |
| 209 | const definedTypes = type.directlyReachableTypes(t => { |
| 210 | if ((!(t instanceof UnionType) && t.isNamedType()) || (t instanceof UnionType && !nullableFromUnion(t))) { |
| 211 | return OrderedSet([t]); |
| 212 | } |
| 213 | return null; |
| 214 | }); |
| 215 | assert(definedTypes.size <= 1, "Cannot have more than one defined type per top-level"); |
| 216 | |
| 217 | // If the top-level type doesn't contain any classes or unions |
| 218 | // we have to define a class just for the `FromJson` method, in |
| 219 | // emitFromJsonForTopLevel. |
| 220 | |
| 221 | const first = definedTypes.first(); |
| 222 | if (first === undefined) return null; |
| 223 | return first; |
| 224 | } |
| 225 | |
| 226 | fieldOrMethodName = (methodName: string, topLevelName: Name): Sourcelike => { |
| 227 | if (this.topLevels.size === 1) { |
nothing calls this directly
no test coverage detected