chore: use type imports / avoid unnecessary API type export (#28088)

This commit is contained in:
Kevin Grüneberg authored and GitHub committed 2024-07-19 18:35:23 +08:00
1 parent cb4b0fe6d8
commit 3601bb52f5
17 files changed
+26 -26

No files matched your search

@@ -2,8 +2,8 @@
import { useEffect, useState } from 'react'
import { usePathname } from 'next/navigation'
import { ICommonItem } from '~/components/reference/Reference.types'
import { Json } from '~/types'
import type { ICommonItem } from '~/components/reference/Reference.types'
import type { Json } from '~/types'
import { menuState } from '../../../hooks/useMenuState'
export function getPathWithoutHash(relativePath: string) {
@@ -6,7 +6,7 @@ import Image from 'next/legacy/image'
import { Fragment, memo } from 'react'
import { cn } from 'ui'
import RevVersionDropdown from '~/components/RefVersionDropdown'
import { ICommonItem, ICommonSection } from '~/components/reference/Reference.types'
import type { ICommonItem, ICommonSection } from '~/components/reference/Reference.types'
import { menuState, useMenuActiveRefId } from '~/hooks/useMenuState'
import { BASE_PATH } from '~/lib/constants'
import MenuIconPicker from './MenuIconPicker'
@@ -3,7 +3,7 @@ import { usePathname } from 'next/navigation'
import { Admonition } from 'ui-patterns/admonition'
import { useMenuActiveRefId } from '~/hooks/useMenuState'
import { ICommonSection } from './Reference.types'
import type { ICommonSection } from './Reference.types'
export interface OldVersionAlertProps {
sections: ICommonSection[]
@@ -7,7 +7,7 @@ import Param from '~/components/Params'
import RefDetailCollapse from '~/components/reference/RefDetailCollapse'
import RefSubLayout from '~/layouts/ref/RefSubLayout'
import { extractTsDocNode, generateParameters } from '~/lib/refGenerator/helpers'
import { IRefFunctionSection } from './Reference.types'
import type { IRefFunctionSection } from './Reference.types'
const RefFunctionSection: React.FC<IRefFunctionSection> = (props) => {
const item = props.spec.functions.find((x: any) => x.id === props.funcData.id)
@@ -10,7 +10,7 @@ import RefSubLayout from '~/layouts/ref/RefSubLayout'
import ApiOperationSection from './ApiOperationSection'
import CliCommandSection from './CLICommandSection'
import OldVersionAlert from './OldVersionAlert'
import { IAPISpec, ICommonSection, IRefStaticDoc, ISpec, TypeSpec } from './Reference.types'
import type { IAPISpec, ICommonSection, IRefStaticDoc, ISpec, TypeSpec } from './Reference.types'
import { MainSkeleton } from '~/layouts/MainSkeleton'
import MgmtApiOperationSection from '~/components/reference/MgmtApiOperationSection'
@@ -1,4 +1,4 @@
import { enrichedOperation } from '~/lib/refGenerator/helpers'
import type { enrichedOperation } from '~/lib/refGenerator/helpers'
export interface ISpec {
openref: any
+1 -1
View File
@@ -1,6 +1,6 @@
import template from './templates/ApiTemplate'
import { slugify, toArrayWithKey, toTitle, writeToDisk } from './helpers'
import { OpenAPIV3, OpenAPIV2 } from 'openapi-types'
import type { OpenAPIV3, OpenAPIV2 } from 'openapi-types'
import * as fs from 'fs'
import * as ejs from 'ejs'
+1 -1
View File
@@ -1,4 +1,4 @@
import { type paths } from '~/types/api'
import type { paths } from 'api-types'
import createClient from 'openapi-fetch'
import { v4 as uuidv4 } from 'uuid'
import { API_URL } from '../constants'
+1 -1
View File
@@ -1,6 +1,6 @@
import { useQuery, UseQueryOptions } from '@tanstack/react-query'
import { get } from './fetchWrappers'
import type { components } from '~/types/api'
import type { components } from 'api-types'
import type { ResponseError } from '~/types/fetch'
const organizationKeys = {
+5 -1
View File
@@ -1,4 +1,8 @@
import { ICommonBase, ICommonItem, ICommonSection } from '../components/reference/Reference.types'
import type {
ICommonBase,
ICommonItem,
ICommonSection,
} from '../components/reference/Reference.types'
// menus to render in the SideBar.js (Ref Nav.constants.ts)
export function getPageType(asPath: string) {
+1 -1
View File
@@ -5,7 +5,7 @@ import codeHikeTheme from 'config/code-hike.theme.json' assert { type: 'json' }
import matter from 'gray-matter'
import { serialize } from 'next-mdx-remote/serialize'
import remarkGfm from 'remark-gfm'
import { ICommonMarkdown } from '~/components/reference/Reference.types'
import type { ICommonMarkdown } from '~/components/reference/Reference.types'
async function generateRefMarkdown(sections: ICommonMarkdown[], slug: string) {
let markdownContent = []
+1 -1
View File
@@ -1,4 +1,4 @@
import { ICommonSection } from '~/components/reference/Reference.types'
import type { ICommonSection } from '~/components/reference/Reference.types'
async function handleRefGetStaticPaths(sections: ICommonSection[]) {
// In preview environments, don't generate static pages (faster builds)
+1 -1
View File
@@ -1,4 +1,4 @@
import { ICommonMarkdown, ICommonSection } from '~/components/reference/Reference.types'
import type { ICommonMarkdown, ICommonSection } from '~/components/reference/Reference.types'
import generateRefMarkdown from '~/lib/mdx/generateRefMarkdown'
async function handleRefStaticProps(sections: ICommonSection[], libraryPath: string) {
+2 -2
View File
@@ -1,9 +1,9 @@
import { TsDoc } from '../../generator/legacy/definitions'
import { values, mapValues } from 'lodash'
import { OpenAPIV3 } from 'openapi-types'
import type { OpenAPIV3 } from 'openapi-types'
import { flattenSections } from '../helpers'
import { ICommonItem } from '~/components/reference/Reference.types'
import type { ICommonItem } from '~/components/reference/Reference.types'
export function extractTsDocNode(nodeToFind: string, definition: any) {
const nodePath = nodeToFind.split('.')
@@ -1,14 +1,14 @@
import { createHash } from 'crypto'
import { readFile } from 'fs/promises'
import yaml from 'js-yaml'
import { OpenAPIV3 } from 'openapi-types'
import {
import type { OpenAPIV3 } from 'openapi-types'
import type {
ICommonItem,
ICommonSection,
IFunctionDefinition,
ISpec,
} from '../../../components/reference/Reference.types'
import { CliCommand, CliSpec } from '../../../generator/types/CliSpec'
import type { CliCommand, CliSpec } from '../../../generator/types/CliSpec'
import { flattenSections } from '../../../lib/helpers'
import { enrichedOperation, gen_v3 } from '../../../lib/refGenerator/helpers'
import type { Json } from '../../helpers.mdx'
-4
View File
@@ -1,4 +0,0 @@
/**
* Avoid importing this file and import the types directly from api-types
*/
export * from 'api-types'
+3 -3
View File
@@ -1,6 +1,6 @@
import { NextPage } from 'next'
import { AppProps } from 'next/app'
import { ReactElement, ReactNode } from 'react'
import type { NextPage } from 'next'
import type { AppProps } from 'next/app'
import type { ReactElement, ReactNode } from 'react'
export type AppPropsWithLayout = AppProps & {
Component: NextPageWithLayout