types: strong separation between `import` and `import type` (#1756)

pull/1759/head
Matteo Bilotta 2 years ago committed by GitHub
parent 72e24b5548
commit 4ac8c0482f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,6 +1,11 @@
import { watchEffect, Ref } from 'vue'
import { HeadConfig, SiteData, createTitle, mergeHead } from '../../shared.js'
import { Route } from '../router.js'
import { watchEffect, type Ref } from 'vue'
import {
type HeadConfig,
type SiteData,
createTitle,
mergeHead
} from '../../shared.js'
import type { Route } from '../router.js'
export function useUpdateHead(route: Route, siteDataByRouteRef: Ref<SiteData>) {
let managedHeadTags: HTMLElement[] = []

@ -1,17 +1,17 @@
import {
InjectionKey,
Ref,
type InjectionKey,
type Ref,
computed,
inject,
readonly,
ref,
shallowRef
} from 'vue'
import { Route } from './router.js'
import type { Route } from './router.js'
import siteData from '@siteData'
import {
PageData,
SiteData,
type PageData,
type SiteData,
resolveSiteDataByRoute,
createTitle
} from '../shared.js'

@ -1,5 +1,5 @@
import {
App,
type App,
createApp as createClientApp,
createSSRApp,
defineComponent,
@ -9,7 +9,7 @@ import {
} from 'vue'
import Theme from '@theme/index'
import { inBrowser, pathToFile } from './utils.js'
import { Router, RouterSymbol, createRouter } from './router.js'
import { type Router, RouterSymbol, createRouter } from './router.js'
import { siteDataRef, useData } from './data.js'
import { useUpdateHead } from './composables/head.js'
import { usePrefetch } from './composables/preFetch.js'

@ -1,6 +1,6 @@
import { App, Ref, Component } from 'vue'
import { Router } from './router.js'
import { SiteData } from '../shared.js'
import type { App, Ref, Component } from 'vue'
import type { Router } from './router.js'
import type { SiteData } from '../shared.js'
export interface EnhanceAppContext {
app: App

@ -1,5 +1,5 @@
<script setup lang="ts">
import { Ref, inject } from 'vue'
import { type Ref, inject } from 'vue'
import type { DefaultTheme } from 'vitepress/theme'
import VPButton from './VPButton.vue'
import VPImage from './VPImage.vue'

@ -1,6 +1,6 @@
<script lang="ts" setup>
import type { DefaultTheme } from 'vitepress/theme'
import { Ref, computed, inject, ref, watchEffect } from 'vue'
import { type Ref, computed, inject, ref, watchEffect } from 'vue'
import { useData } from 'vitepress'
import { useSidebar } from '../composables/sidebar.js'
import { isActive } from '../support/utils.js'

@ -1,4 +1,4 @@
import { Ref, ref, watch, readonly, onUnmounted } from 'vue'
import { type Ref, ref, watch, readonly, onUnmounted } from 'vue'
interface UseFlyoutOptions {
el: Ref<HTMLElement | undefined>

@ -1,4 +1,11 @@
import { computed, onMounted, onUnmounted, Ref, ref, watchEffect } from 'vue'
import {
computed,
onMounted,
onUnmounted,
type Ref,
ref,
watchEffect
} from 'vue'
import { useData, useRoute } from 'vitepress'
import { useMediaQuery } from '@vueuse/core'
import { getSidebar } from '../support/sidebar.js'

@ -1,4 +1,4 @@
import { Ref, onMounted, onUnmounted } from 'vue'
import { type Ref, onMounted, onUnmounted } from 'vue'
import { throttleAndDebounce } from '../support/utils.js'
export interface GridSetting {

@ -8,7 +8,7 @@ import './styles/components/vp-code-group.css'
import './styles/components/vp-doc.css'
import './styles/components/vp-sponsor.css'
import { Theme } from 'vitepress'
import type { Theme } from 'vitepress'
import VPBadge from './components/VPBadge.vue'
import Layout from './Layout.vue'
import NotFound from './NotFound.vue'

@ -1,8 +1,8 @@
import { createRequire } from 'module'
import { resolve, join } from 'path'
import { fileURLToPath } from 'url'
import { Alias, AliasOptions } from 'vite'
import { SiteConfig } from './config'
import type { Alias, AliasOptions } from 'vite'
import type { SiteConfig } from './config'
const require = createRequire(import.meta.url)
const PKG_ROOT = resolve(fileURLToPath(import.meta.url), '../..')

@ -1,8 +1,8 @@
import fs from 'fs-extra'
import path from 'path'
import ora from 'ora'
import { BuildOptions } from 'vite'
import { OutputChunk, OutputAsset } from 'rollup'
import type { BuildOptions } from 'vite'
import type { OutputChunk, OutputAsset } from 'rollup'
import { resolveConfig } from '../config'
import { renderPage } from './render'
import { bundle, okMark, failMark } from './bundle'

@ -1,6 +1,6 @@
import { build } from 'vite'
import { RollupOutput } from 'rollup'
import { SiteConfig } from '..'
import type { RollupOutput } from 'rollup'
import type { SiteConfig } from '..'
const virtualEntry = 'client.js'

@ -1,10 +1,14 @@
import ora from 'ora'
import path from 'path'
import fs from 'fs-extra'
import { build, BuildOptions, UserConfig as ViteUserConfig } from 'vite'
import { GetModuleInfo, RollupOutput } from 'rollup'
import {
build,
type BuildOptions,
type UserConfig as ViteUserConfig
} from 'vite'
import type { GetModuleInfo, RollupOutput } from 'rollup'
import { slash } from '../utils/slash'
import { SiteConfig } from '../config'
import type { SiteConfig } from '../config'
import { APP_PATH } from '../alias'
import { createVitePressPlugin } from '../plugin'
import { sanitizeFileName } from '../shared'

@ -3,10 +3,10 @@ import path from 'path'
import { pathToFileURL } from 'url'
import escape from 'escape-html'
import { normalizePath, transformWithEsbuild } from 'vite'
import { RollupOutput, OutputChunk, OutputAsset } from 'rollup'
import type { RollupOutput, OutputChunk, OutputAsset } from 'rollup'
import {
HeadConfig,
PageData,
type HeadConfig,
type PageData,
createTitle,
notFoundPageData,
mergeHead,
@ -14,7 +14,7 @@ import {
sanitizeFileName
} from '../shared'
import { slash } from '../utils/slash'
import { SiteConfig, resolveSiteDataByRoute } from '../config'
import { type SiteConfig, resolveSiteDataByRoute } from '../config'
export async function renderPage(
render: (path: string) => Promise<string>,

@ -4,24 +4,24 @@ import c from 'picocolors'
import fg from 'fast-glob'
import {
normalizePath,
UserConfig as ViteConfig,
type UserConfig as ViteConfig,
mergeConfig as mergeViteConfig,
loadConfigFromFile
} from 'vite'
import { Options as VuePluginOptions } from '@vitejs/plugin-vue'
import type { Options as VuePluginOptions } from '@vitejs/plugin-vue'
import {
SiteData,
HeadConfig,
LocaleConfig,
DefaultTheme,
type SiteData,
type HeadConfig,
type LocaleConfig,
type DefaultTheme,
APPEARANCE_KEY,
createLangDictionary,
CleanUrlsMode,
PageData,
Awaitable
type CleanUrlsMode,
type PageData,
type Awaitable
} from './shared'
import { DEFAULT_THEME_PATH } from './alias'
import { MarkdownOptions } from './markdown/markdown'
import type { MarkdownOptions } from './markdown/markdown'
import _debug from 'debug'
export { resolveSiteDataByRoute } from './shared'

@ -15,7 +15,7 @@ import { sfcPlugin, type SfcPluginOptions } from '@mdit-vue/plugin-sfc'
import { titlePlugin } from '@mdit-vue/plugin-title'
import { tocPlugin, type TocPluginOptions } from '@mdit-vue/plugin-toc'
import { slugify } from '@mdit-vue/shared'
import { IThemeRegistration } from 'shiki'
import type { IThemeRegistration } from 'shiki'
import { highlight } from './plugins/highlight'
import { highlightLinePlugin } from './plugins/highlightLines'
import { lineNumberPlugin } from './plugins/lineNumbers'
@ -24,7 +24,7 @@ import { snippetPlugin } from './plugins/snippet'
import { preWrapperPlugin } from './plugins/preWrapper'
import { linkPlugin } from './plugins/link'
import { imagePlugin } from './plugins/image'
import { Header } from '../shared'
import type { Header } from '../shared'
export type ThemeOptions =
| IThemeRegistration

@ -1,6 +1,6 @@
import MarkdownIt from 'markdown-it'
import { RenderRule } from 'markdown-it/lib/renderer'
import Token from 'markdown-it/lib/token'
import type MarkdownIt from 'markdown-it'
import type { RenderRule } from 'markdown-it/lib/renderer'
import type Token from 'markdown-it/lib/token'
import container from 'markdown-it-container'
import { nanoid } from 'nanoid'
import { extractTitle } from './preWrapper'

@ -2,7 +2,7 @@
// Now this plugin is only used to normalize line attrs.
// The else part of line highlights logic is in './highlight.ts'.
import MarkdownIt from 'markdown-it'
import type MarkdownIt from 'markdown-it'
const RE = /{([\d,-]+)}/

@ -1,6 +1,6 @@
// markdown-it plugin for normalizing image source
import MarkdownIt from 'markdown-it'
import type MarkdownIt from 'markdown-it'
import { EXTERNAL_URL_RE } from '../../shared'
export const imagePlugin = (md: MarkdownIt) => {

@ -1,7 +1,7 @@
// markdown-it plugin for generating line numbers.
// It depends on preWrapper plugin.
import MarkdownIt from 'markdown-it'
import type MarkdownIt from 'markdown-it'
export const lineNumberPlugin = (md: MarkdownIt, enable = false) => {
const fence = md.renderer.rules.fence!

@ -2,7 +2,7 @@
// 1. adding target="_blank" to external links
// 2. normalize internal links to end with `.html`
import MarkdownIt from 'markdown-it'
import type MarkdownIt from 'markdown-it'
import type { MarkdownEnv } from '../env'
import { URL } from 'url'
import { EXTERNAL_URL_RE, PATHNAME_PROTOCOL_RE } from '../../shared'

@ -1,4 +1,4 @@
import MarkdownIt from 'markdown-it'
import type MarkdownIt from 'markdown-it'
export function preWrapperPlugin(md: MarkdownIt) {
const fence = md.renderer.rules.fence!

@ -1,7 +1,7 @@
import fs from 'fs'
import path from 'path'
import MarkdownIt from 'markdown-it'
import { RuleBlock } from 'markdown-it/lib/parser_block'
import type MarkdownIt from 'markdown-it'
import type { RuleBlock } from 'markdown-it/lib/parser_block'
export function dedent(text: string): string {
const lines = text.split('\n')

@ -3,8 +3,13 @@ import path from 'path'
import c from 'picocolors'
import LRUCache from 'lru-cache'
import { resolveTitleFromToken } from '@mdit-vue/shared'
import { SiteConfig } from './config'
import { PageData, HeadConfig, EXTERNAL_URL_RE, CleanUrlsMode } from './shared'
import type { SiteConfig } from './config'
import {
type PageData,
type HeadConfig,
EXTERNAL_URL_RE,
type CleanUrlsMode
} from './shared'
import { slash } from './utils/slash'
import { getGitTimestamp } from './utils/getGitTimestamp'
import {

@ -4,10 +4,10 @@ import {
defineConfig,
mergeConfig,
searchForWorkspaceRoot,
Plugin,
ResolvedConfig
type Plugin,
type ResolvedConfig
} from 'vite'
import { SiteConfig } from './config'
import type { SiteConfig } from './config'
import { createMarkdownToVueRenderFn, clearCache } from './markdownToVue'
import {
DIST_CLIENT_PATH,
@ -16,9 +16,9 @@ import {
resolveAliases
} from './alias'
import { slash } from './utils/slash'
import { OutputAsset, OutputChunk } from 'rollup'
import type { OutputAsset, OutputChunk } from 'rollup'
import { staticDataPlugin } from './staticDataPlugin'
import { PageDataPayload } from './shared'
import type { PageDataPayload } from './shared'
import { webFontsPlugin } from './webFontsPlugin'
const hashRE = /\.(\w+)\.js$/

@ -1,8 +1,8 @@
import fs from 'fs'
import path from 'path'
import compression from 'compression'
import polka, { IOptions } from 'polka'
import sirv, { RequestHandler } from 'sirv'
import polka, { type IOptions } from 'polka'
import sirv, { type RequestHandler } from 'sirv'
import { resolveConfig } from '../config'
function trimChar(str: string, char: string) {

@ -1,5 +1,5 @@
import dns from 'dns'
import { createServer as createViteServer, ServerOptions } from 'vite'
import { createServer as createViteServer, type ServerOptions } from 'vite'
import { resolveConfig } from './config'
import { createVitePressPlugin } from './plugin'

@ -1,4 +1,9 @@
import { Plugin, ViteDevServer, loadConfigFromFile, normalizePath } from 'vite'
import {
type Plugin,
type ViteDevServer,
loadConfigFromFile,
normalizePath
} from 'vite'
import { dirname, resolve } from 'path'
import { isMatch } from 'micromatch'

@ -1,4 +1,4 @@
import { Plugin } from 'vite'
import type { Plugin } from 'vite'
const webfontMarkerRE =
/\/(?:\*|\/) *webfont-marker-begin *(?:\*\/|\n|\r|\n\r|\r\n)([^]*?)\/(?:\*|\/) *webfont-marker-end *(?:\*\/|\n|\r|\n\r|\r\n|$)/

@ -1,4 +1,4 @@
import {
import type {
SiteData,
PageData,
LocaleConfig,

@ -8,6 +8,9 @@
"skipLibCheck": true,
"noUnusedLocals": true,
"resolveJsonModule": true,
"isolatedModules": true,
"preserveValueImports": true,
"importsNotUsedAsValues": "error",
"jsx": "preserve",
"lib": ["ESNext", "DOM"]
},

Loading…
Cancel
Save