Skip to content

Commit

Permalink
fix: suppress ts type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
zouyaoji committed Sep 14, 2021
1 parent 01fb85e commit f29907e
Show file tree
Hide file tree
Showing 15 changed files with 34 additions and 86 deletions.
4 changes: 2 additions & 2 deletions build/gen-dts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ const genVueTypes = async (root, outDir = path.resolve(__dirname, '../dist/types
},
skipLibCheck: true
},
tsConfigFilePath: TSCONFIG_PATH,
skipAddingFilesFromTsConfig: true
tsConfigFilePath: TSCONFIG_PATH
// skipAddingFilesFromTsConfig: true
})

const sourceFiles = []
Expand Down
5 changes: 3 additions & 2 deletions packages/components/controls/my-location/defaultProps.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { positionProps } from '@vue-cesium/composables/private/use-position'
import { t } from '@vue-cesium/locale'
import { PropType } from 'vue'

export default {
geolocation: {
Expand Down Expand Up @@ -31,7 +32,7 @@ export default {
default: t('vc.navigation.myLocation.centreMap')
},
pointColor: {
type: [Array, Object, String],
type: [Array, Object, String] as PropType<Cesium.Color>,
default: '#08ABD5'
},
pixelSize: {
Expand All @@ -43,7 +44,7 @@ export default {
default: 3
},
outlineColor: {
type: [Array, Object, String],
type: [Array, Object, String] as PropType<Cesium.Color>,
default: '#ffffff'
},
level: {
Expand Down
8 changes: 5 additions & 3 deletions packages/components/controls/my-location/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { $, getVcParentInstance, getInstanceListener } from '@vue-cesium/utils/p
import usePosition from '@vue-cesium/composables/private/use-position'
import { gcj02towgs84 } from '@vue-cesium/utils/coordtransform'
import { makeColor, makeCartesian3 } from '@vue-cesium/utils/cesium-helpers'
import { isArray, isFunction } from '@vue-cesium/utils/util'
import { isArray, isFunction, isPlainObject } from '@vue-cesium/utils/util'
import { useCommon } from '@vue-cesium/composables'
import defaultProps from './defaultProps'
import { t } from '@vue-cesium/locale'
Expand Down Expand Up @@ -63,7 +63,9 @@ export default defineComponent({
)
// computed
const myLocationTip = computed(() => {
return positioning.value ? t('vc.navigation.myLocation.positioning') : props.tooltip.tip || t('vc.navigation.myLocation.myLocationTip')
return positioning.value
? t('vc.navigation.myLocation.positioning')
: (isPlainObject(props.tooltip) && props.tooltip.tip) || t('vc.navigation.myLocation.myLocationTip')
})
// methods
instance.createCesiumObject = async () => {
Expand Down Expand Up @@ -408,7 +410,7 @@ export default defineComponent({

inner.push(h('div', null, props.label))

if (props.tooltip) {
if (isPlainObject(props.tooltip)) {
inner.push(
h(
VcTooltip,
Expand Down
5 changes: 3 additions & 2 deletions packages/components/controls/print/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import createPrintView from './createPrintView'
import defaultProps from './defaultProps'
import printWindow from './printWindow'
import { t } from '@vue-cesium/locale'
import { isPlainObject } from '@vue-cesium/utils/util'

export default defineComponent({
name: 'VcPrint',
Expand Down Expand Up @@ -227,7 +228,7 @@ export default defineComponent({
)

inner.push(h('div', null, props.label))
if (props.tooltip) {
if (isPlainObject(props.tooltip)) {
inner.push(
h(
VcTooltip,
Expand All @@ -236,7 +237,7 @@ export default defineComponent({
onBeforeShow: onTooltipBeforeShow,
...props.tooltip
},
() => h('strong', null, props.tooltip.tip || t('vc.navigation.print.printTip'))
() => h('strong', null, (isPlainObject(props.tooltip) && props.tooltip.tip) || t('vc.navigation.print.printTip'))
)
)
} else {
Expand Down
2 changes: 1 addition & 1 deletion packages/components/imagery-layer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ ImageryLayer.install = (app: App): void => {
const _ImageryLayer = ImageryLayer as SFCWithInstall<typeof ImageryLayer>

export default _ImageryLayer
export const VcImageryLayer = _ImageryLayer
export const VcLayerImagery = _ImageryLayer
13 changes: 7 additions & 6 deletions packages/components/viewer/__tests__/viewer.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { VcComponentPublicInstance } from '@vue-cesium/utils/types'
import { CameraOption, VcComponentPublicInstance } from '@vue-cesium/utils/types'
import { kebabCase } from '@vue-cesium/utils/util'
import { mount, config } from '@vue/test-utils'
import Viewer from '../src'
import VcViewer from '../src'
// import { createPointerEvent } from '@vue-cesium/utils/private/test-util'

const option = {
Expand All @@ -13,8 +13,8 @@ config.global.config.globalProperties.$VueCesium = option

describe('VcViewer', () => {
test('render test default', async () => {
const wrapper = mount(Viewer)
const vm = wrapper.vm as VcComponentPublicInstance
const wrapper = mount(VcViewer)
const vm = wrapper.vm as unknown as VcComponentPublicInstance
expect(wrapper.find(`.${kebabCase(vm.$options.name)}`).exists()).toBe(true)
await vm.createPromise
const viewer = vm.getCesiumObject() as Cesium.Viewer
Expand All @@ -37,7 +37,8 @@ describe('VcViewer', () => {
const onLeftClick = () => {
clicked = true
}
const wrapper = mount(Viewer, {

const wrapper = mount(VcViewer, {
props: {
showCredit: false,
animation: true,
Expand All @@ -64,7 +65,7 @@ describe('VcViewer', () => {
onClick: onLeftClick
}
})
const vm = wrapper.vm as VcComponentPublicInstance
const vm = wrapper.vm as unknown as VcComponentPublicInstance
expect(wrapper.find(`.${kebabCase(vm.$options.name)}`).exists()).toBe(true)
await vm.createPromise
let viewer = vm.getCesiumObject() as Cesium.Viewer
Expand Down
2 changes: 1 addition & 1 deletion packages/components/viewer/src/defaultProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export default {
},
accessToken: String,
camera: {
type: Object as PropType<CameraOption>,
type: Object,
default: () => ({
position: {
lng: 105,
Expand Down
11 changes: 0 additions & 11 deletions packages/composables/tsconfig.json

This file was deleted.

11 changes: 0 additions & 11 deletions packages/directives/tsconfig.json

This file was deleted.

9 changes: 0 additions & 9 deletions packages/locale/tsconfig.json

This file was deleted.

9 changes: 0 additions & 9 deletions packages/shared/tsconfig.json

This file was deleted.

5 changes: 0 additions & 5 deletions packages/theme-default/tsconfig.json

This file was deleted.

9 changes: 5 additions & 4 deletions packages/utils/cesium-props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ const height = {
*/
const heightReference = {
heightReference: {
type: [Number, Object, Function],
type: [Number, Object, Function]
// default: 0
}
}
Expand Down Expand Up @@ -252,7 +252,7 @@ const scaleByDistance = {
*/
const show = {
show: {
type: [Boolean, Object, Function],
type: [Boolean, Object, Function] as PropType<boolean>,
default: true
}
}
Expand Down Expand Up @@ -381,8 +381,9 @@ const shadows = {
*/
const positions = {
positions: {
type: [Array, Object, Function] as PropType<Array<Cesium.Cartesian3> | Array<number> | Array<Array<number>>
| Array<Cartesian3Option> | Array<CartographicInDegreeOption>>,
type: [Array, Object, Function] as PropType<
Array<Cesium.Cartesian3> | Array<number> | Array<Array<number>> | Array<Cartesian3Option> | Array<CartographicInDegreeOption>
>,
watcherOptions: {
cesiumObjectBuilder: makeCartesian3Array,
exclude: '_callback',
Expand Down
16 changes: 7 additions & 9 deletions packages/utils/private/test-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ function defaultValue(a, b) {
return b
}


export function createPointerEvent (type, options?) {
export function createPointerEvent(type, options?) {
options = defaultValue(options, {})
const event = new window.PointerEvent(type, {
canBubble: defaultValue(options.canBubble, true),
// canBubble: defaultValue(options.canBubble, true),
cancelable: defaultValue(options.cancelable, true),
view: defaultValue(options.view, window),
detail: defaultValue(options.detail, 0),
Expand All @@ -23,18 +22,18 @@ export function createPointerEvent (type, options?) {
metaKey: defaultValue(options.metaKey, false),
button: defaultValue(options.button, 0),
relatedTarget: defaultValue(options.relatedTarget, null),
offsetX: defaultValue(options.offsetX, 0),
offsetY: defaultValue(options.offsetY, 0),
// offsetX: defaultValue(options.offsetX, 0),
// offsetY: defaultValue(options.offsetY, 0),
width: defaultValue(options.width, 0),
height: defaultValue(options.height, 0),
pressure: defaultValue(options.pressure, 0),
rotation: defaultValue(options.rotation, 0),
// rotation: defaultValue(options.rotation, 0),
tiltX: defaultValue(options.tiltX, 0),
tiltY: defaultValue(options.tiltY, 0),
pointerId: defaultValue(options.pointerId, 1),
pointerType: defaultValue(options.pointerType, 'mouse'),
hwTimestamp: defaultValue(options.hwTimestamp, 0),
isPrimary: defaultValue(options.isPrimary, 0),
// hwTimestamp: defaultValue(options.hwTimestamp, 0),
isPrimary: defaultValue(options.isPrimary, 0)
})
return event
}
Expand Down Expand Up @@ -77,7 +76,6 @@ export function createMouseEvent(type, options) {
return event
}


/**
* 等待 ms 毫秒,返回 Promise
* @param {Number} ms
Expand Down
11 changes: 0 additions & 11 deletions packages/utils/tsconfig.json

This file was deleted.

0 comments on commit f29907e

Please sign in to comment.