( imports: ParsedJSDocImports, kind: JSDocApiKind, bucket: ExportBucket | null, apiName: string )
| 1993 | } |
| 1994 | |
| 1995 | function importGuidance( |
| 1996 | imports: ParsedJSDocImports, |
| 1997 | kind: JSDocApiKind, |
| 1998 | bucket: ExportBucket | null, |
| 1999 | apiName: string |
| 2000 | ): JSDocApiImportGuidance | null { |
| 2001 | if (kind !== "root-declaration" || bucket !== "value" || !isIdentifierName(apiName)) { |
| 2002 | return null |
| 2003 | } |
| 2004 | if (imports.flatNames.includes(apiName) && imports.barrel !== null) { |
| 2005 | return { |
| 2006 | style: "named-barrel", |
| 2007 | importDeclaration: `import { ${apiName} } from "${imports.barrel.module}"`, |
| 2008 | usage: apiName |
| 2009 | } |
| 2010 | } |
| 2011 | if (imports.barrel?.type === "namespace") { |
| 2012 | if (!isIdentifierName(imports.barrel.name)) return null |
| 2013 | return { |
| 2014 | style: "namespace-barrel", |
| 2015 | importDeclaration: `import { ${imports.barrel.name} } from "${imports.barrel.module}"`, |
| 2016 | usage: `${imports.barrel.name}.${apiName}` |
| 2017 | } |
| 2018 | } |
| 2019 | if (imports.barrel?.type === "flat") { |
| 2020 | return { |
| 2021 | style: "named-barrel", |
| 2022 | importDeclaration: `import { ${apiName} } from "${imports.barrel.module}"`, |
| 2023 | usage: apiName |
| 2024 | } |
| 2025 | } |
| 2026 | return { |
| 2027 | style: "named-module", |
| 2028 | importDeclaration: `import { ${apiName} } from "${imports.module}"`, |
| 2029 | usage: apiName |
| 2030 | } |
| 2031 | } |
| 2032 | |
| 2033 | function makeApi(input: { |
| 2034 | readonly file: JSDocModelFile |
no test coverage detected