refactor(build): use type unsafe (#7523)

* refactor(build): use type unsafe

* fix: windows
This commit is contained in:
三咲智子 2022-05-13 16:55:10 +08:00 committed by GitHub
parent 4e66ca634a
commit 21a7089ec5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 85 additions and 56 deletions

View File

@ -1,4 +1,4 @@
export * from './tasks' export * from './tasks'
export * from './utils' export * from './utils'
export * from './build-info' export * from './build-info'
export { default as typeSafe } from './type-safe.json' export { default as typeUnsafe } from './type-unsafe.json'

View File

@ -14,18 +14,18 @@ import {
projRoot, projRoot,
} from '@element-plus/build-utils' } from '@element-plus/build-utils'
import { pathRewriter } from '../utils' import { pathRewriter } from '../utils'
import typeSafe from '../type-safe.json' import typeUnsafe from '../type-unsafe.json'
import type { SourceFile } from 'ts-morph' import type { SourceFile } from 'ts-morph'
const TSCONFIG_PATH = path.resolve(projRoot, 'tsconfig.web.json') const TSCONFIG_PATH = path.resolve(projRoot, 'tsconfig.web.json')
const outDir = path.resolve(buildOutput, 'types') const outDir = path.resolve(buildOutput, 'types')
// Type safe list. The TS errors are not all fixed yet, so we need a list of which files are fixed with TS errors to prevent accidental TS errors. // Type unsafe list. The TS errors are not all fixed yet, so we need a list of which files are not fixed with TS errors to prevent accidental TS errors.
const typeSafePaths = typeSafe.map((_path) => { const typeUnsafePaths = typeUnsafe.map((_path) => {
let safePath = path.resolve(projRoot, _path) let paths = path.resolve(projRoot, _path)
if (_path.endsWith('/')) safePath += path.sep if (_path.endsWith('/')) paths += path.sep
return safePath return paths
}) })
/** /**
@ -103,11 +103,10 @@ export const generateTypesDefinitions = async () => {
]) ])
const diagnostics = project.getPreEmitDiagnostics().filter((diagnostic) => { const diagnostics = project.getPreEmitDiagnostics().filter((diagnostic) => {
const filePath = diagnostic.getSourceFile()?.getFilePath() const filePath = diagnostic.getSourceFile()?.getFilePath()!
return ( if (!filePath) return false
filePath && const file = path.normalize(filePath)
typeSafePaths.some((safePath) => filePath.startsWith(safePath)) return !typeUnsafePaths.some((safePath) => file.startsWith(safePath))
)
}) })
if (diagnostics.length > 0) { if (diagnostics.length > 0) {
consola.error(project.formatDiagnosticsWithColorAndContext(diagnostics)) consola.error(project.formatDiagnosticsWithColorAndContext(diagnostics))

View File

@ -1,38 +0,0 @@
[
"packages/components/affix/",
"packages/components/alert/",
"packages/components/aside/",
"packages/components/autocomplete/",
"packages/components/avatar/",
"packages/components/backtop/",
"packages/components/badge/",
"packages/components/base/",
"packages/components/breadcrumb/",
"packages/components/breadcrumb-item/",
"packages/components/button/",
"packages/components/button-group/",
"packages/components/calendar/",
"packages/components/card/",
"packages/components/carousel/",
"packages/components/check-tag/",
"packages/components/col/",
"packages/components/collapse/",
"packages/components/collapse-item/",
"packages/components/dialog/",
"packages/components/icon/",
"packages/components/link/",
"packages/components/page-header/",
"packages/components/rate/",
"packages/components/row/",
"packages/components/slot/",
"packages/components/tabs/",
"packages/components/tag/",
"packages/components/teleport/",
"packages/components/upload/",
"packages/constants",
"packages/element-plus",
"packages/hooks",
"packages/locale",
"packages/tokens",
"packages/utils"
]

View File

@ -0,0 +1,56 @@
[
"packages/components/cascader/",
"packages/components/cascader-panel/",
"packages/components/checkbox/",
"packages/components/color-picker/",
"packages/components/date-picker/",
"packages/components/descriptions/",
"packages/components/drawer/",
"packages/components/dropdown/",
"packages/components/focus-trap/",
"packages/components/infinite-scroll/",
"packages/components/input/",
"packages/components/input-number/",
"packages/components/loading/",
"packages/components/menu/",
"packages/components/message/",
"packages/components/message-box/",
"packages/components/notification/",
"packages/components/option/",
"packages/components/option-group/",
"packages/components/overlay/",
"packages/components/pagination/",
"packages/components/popconfirm/",
"packages/components/popover/",
"packages/components/popper/",
"packages/components/radio/",
"packages/components/radio-button/",
"packages/components/radio-group/",
"packages/components/result/",
"packages/components/roving-focus-group/",
"packages/components/scrollbar/",
"packages/components/select/",
"packages/components/select-v2/",
"packages/components/skeleton/",
"packages/components/skeleton-item/",
"packages/components/slider/",
"packages/components/space/",
"packages/components/step/",
"packages/components/steps/",
"packages/components/table/",
"packages/components/table-column/",
"packages/components/table-v2/",
"packages/components/time-picker/",
"packages/components/time-select/",
"packages/components/timeline/",
"packages/components/timeline-item/",
"packages/components/tooltip/",
"packages/components/tooltip-v2/",
"packages/components/transfer/",
"packages/components/tree/",
"packages/components/tree-select/",
"packages/components/tree-v2/",
"packages/components/virtual-list/",
"packages/components/visual-hidden/",
"packages/directives/"
]

View File

@ -80,8 +80,8 @@ const showViewer = ref(false)
const container = ref<HTMLElement>() const container = ref<HTMLElement>()
const _scrollContainer = ref<HTMLElement | Window>() const _scrollContainer = ref<HTMLElement | Window>()
let stopScrollListener: () => void let stopScrollListener: (() => void) | undefined
let stopWheelListener: () => void let stopWheelListener: (() => void) | undefined
const containerStyle = computed(() => rawAttrs.style as StyleValue) const containerStyle = computed(() => rawAttrs.style as StyleValue)
@ -191,7 +191,7 @@ async function addLazyLoadListener() {
function removeLazyLoadListener() { function removeLazyLoadListener() {
if (!isClient || !_scrollContainer.value || !lazyLoadHandler) return if (!isClient || !_scrollContainer.value || !lazyLoadHandler) return
stopScrollListener() stopScrollListener?.()
_scrollContainer.value = undefined _scrollContainer.value = undefined
} }

View File

@ -0,0 +1,2 @@
import '@element-plus/components/base/style/css'
import '@element-plus/theme-chalk/menu-item-group.css'

View File

@ -0,0 +1,2 @@
import '@element-plus/components/base/style'
import '@element-plus/theme-chalk/src/menu-item-group.scss'

View File

@ -0,0 +1,2 @@
import '@element-plus/components/base/style/css'
import '@element-plus/theme-chalk/menu-item.css'

View File

@ -0,0 +1,2 @@
import '@element-plus/components/base/style'
import '@element-plus/theme-chalk/src/menu-item.scss'

View File

@ -0,0 +1,2 @@
import '@element-plus/components/base/style/css'
import '@element-plus/theme-chalk/el-sub-menu.css'

View File

@ -0,0 +1,2 @@
import '@element-plus/components/base/style'
import '@element-plus/theme-chalk/src/sub-menu.scss'

View File

@ -1 +1 @@
/* Empty file for avoiding plugin error */ export {}

View File

@ -1 +1 @@
/* Empty file for avoiding plugin error */ export {}

View File

@ -45,7 +45,7 @@ export type FormContext = FormProps &
} }
export interface FormItemContext extends FormItemProps { export interface FormItemContext extends FormItemProps {
$el: HTMLDivElement $el: HTMLDivElement | undefined
size: ComponentSize size: ComponentSize
validateState: string validateState: string
isGroup: boolean isGroup: boolean