( cwd: string, sourceFile: ts.SourceFile, checker: ts.TypeChecker, entry: ProgramCacheEntry )
| 3149 | ...diagnostic("namespace-declare", "Namespaces must be declared with declare namespace"), |
| 3150 | range: nodeRange(node) |
| 3151 | }) |
| 3152 | return undefined |
| 3153 | } |
| 3154 | const documented = parseDocumentedTs(node, "namespace", diagnostics, true, linkContext) |
| 3155 | if (documented === undefined) return undefined |
| 3156 | const declarations: Array<ParsedNamespaceDeclaration> = [] |
| 3157 | const namespaces: Array<ParsedNamespace> = [] |
| 3158 | if (node.body !== undefined && ts.isModuleBlock(node.body)) { |
| 3159 | for (const statement of node.body.statements) { |
| 3160 | if (!hasExportModifier(statement)) continue |
| 3161 | if (ts.isModuleDeclaration(statement)) { |
| 3162 | const nested = parseNamespaceTs(statement, diagnostics, linkContext, true) |
| 3163 | if (nested !== undefined) namespaces.push(nested) |
| 3164 | continue |
| 3165 | } |
| 3166 | if (ts.isEnumDeclaration(statement)) { |
| 3167 | diagnostics.push({ ...diagnostic("enum", "Enums are not allowed"), range: nodeRange(statement) }) |
| 3168 | continue |
| 3169 | } |
| 3170 | const bucket = bucketOfTs(statement) |
| 3171 | if (bucket !== "type") { |
| 3172 | diagnostics.push({ |
| 3173 | ...diagnostic("namespace-value", "Namespace exports must be type declarations"), |
| 3174 | range: nodeRange(statement) |
| 3175 | }) |
| 3176 | continue |
| 3177 | } |
| 3178 | const nestedDocumented = parseDocumentedTs(statement, "namespace-declaration", diagnostics, true, linkContext) |
| 3179 | if (nestedDocumented === undefined) continue |
| 3180 | const name = declarationName(statement) |
| 3181 | if (name === undefined || name.length === 0) { |
| 3182 | diagnostics.push({ |
| 3183 | ...diagnostic("missing-name", "Namespace declaration name could not be determined"), |
| 3184 | range: nodeRange(statement) |
| 3185 | }) |
| 3186 | continue |
| 3187 | } |
| 3188 | declarations.push({ |
| 3189 | name, |
| 3190 | signature: null, |
| 3191 | range: publicDeclarationRange(statement, name), |
| 3192 | description: nestedDocumented.core.description, |
| 3193 | examples: nestedDocumented.core.examples, |
| 3194 | tags: nestedDocumented.tags as ParsedNamespaceTags, |
| 3195 | members: parseDeclarationMembersTs(statement, diagnostics, linkContext) |
| 3196 | }) |
| 3197 | } |
| 3198 | } |
| 3199 | return { |
| 3200 | name: node.name.text, |
| 3201 | signature: null, |
| 3202 | range: nodeRange(node), |
| 3203 | description: documented.core.description, |
| 3204 | examples: documented.core.examples, |
| 3205 | tags: documented.tags as ParsedNamespaceTags, |
| 3206 | declarations, |
| 3207 | namespaces |
| 3208 | } |
no test coverage detected
searching dependent graphs…