Skip to content

Commit

Permalink
build: adjust dts test setup
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Feb 3, 2023
1 parent d10a81e commit 1ddde63
Show file tree
Hide file tree
Showing 28 changed files with 50 additions and 45 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ module.exports = {
overrides: [
// tests, no restrictions (runs in Node / jest with jsdom)
{
files: ['**/__tests__/**', 'test-dts/**'],
files: ['**/__tests__/**', 'packages/dts-test/**'],
rules: {
'no-restricted-globals': 'off',
'no-restricted-syntax': 'off',
Expand Down
9 changes: 2 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"test-unit": "vitest -c vitest.unit.config.ts",
"test-e2e": "node scripts/build.mjs vue -f global -d && vitest -c vitest.e2e.config.ts",
"test-dts": "run-s build-dts test-dts-only",
"test-dts-only": "tsc -p ./test-dts/tsconfig.build.json",
"test-dts-only": "tsc -p ./packages/dts-test/tsconfig.test.json",
"test-coverage": "vitest -c vitest.unit.config.ts --coverage",
"release": "node scripts/release.mjs",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
Expand All @@ -37,7 +37,6 @@
"preinstall": "node ./scripts/preinstall.mjs",
"postinstall": "simple-git-hooks"
},
"types": "test-dts/index.d.ts",
"simple-git-hooks": {
"pre-commit": "pnpm lint-staged && pnpm check",
"commit-msg": "node scripts/verifyCommit.mjs"
Expand Down Expand Up @@ -69,9 +68,6 @@
"@typescript-eslint/parser": "^5.23.0",
"@vitest/coverage-istanbul": "^0.28.2",
"@vue/consolidate": "0.17.3",
"@vue/reactivity": "workspace:*",
"@vue/runtime-core": "workspace:*",
"@vue/runtime-dom": "workspace:*",
"brotli": "^1.3.2",
"chalk": "^4.1.0",
"conventional-changelog-cli": "^2.0.31",
Expand Down Expand Up @@ -105,7 +101,6 @@
"tslib": "^2.4.0",
"typescript": "^4.9.0",
"vite": "^4.0.4",
"vitest": "^0.28.2",
"vue": "workspace:*"
"vitest": "^0.28.2"
}
}
7 changes: 7 additions & 0 deletions packages/dts-test/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# dts-test

Tests Typescript types to ensure the types remain as expected.

- This directory is included in the root `tsconfig.json`, where package imports are aliased to `src` directories, so in IDEs and the `pnpm check` script the types are validated against source code.

- When runnong `tsc` with `packages/dts-test/tsconfig.test.json`, packages are resolved using using normal `node` resolution, so the types are validated against actual **built** types. This requires the types to be built first via `pnpm build-types`.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion test-dts/index.d.ts → packages/dts-test/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// This directory contains a number of d.ts assertions
// use \@ts-expect-error where errors are expected.

export * from '@vue/runtime-dom'
export * from 'vue'

export function describe(_name: string, _fn: () => void): void
export function test(_name: string, _fn: () => any): void
Expand Down
File renamed without changes.
10 changes: 10 additions & 0 deletions packages/dts-test/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "dts-test",
"private": true,
"dependencies": {
"vue": "workspace:*",
"@vue/runtime-core": "workspace:*",
"@vue/runtime-dom": "workspace:*",
"@vue/reactivity": "workspace:*"
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { WritableComputedRef } from '@vue/reactivity'
import { expectType, ref, computed, Ref, ComputedRef } from './index'
import {
expectType,
ref,
computed,
Ref,
ComputedRef,
WritableComputedRef
} from './index'
import 'vue/macros-global'
import { RefType, RefTypes } from 'vue/macros'

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 5 additions & 2 deletions packages/runtime-core/src/apiSetupHelpers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { ComponentPropsOptions } from '@vue/runtime-core'
import { isArray, isPromise, isFunction } from '@vue/shared'
import {
getCurrentInstance,
Expand All @@ -8,7 +7,11 @@ import {
unsetCurrentInstance
} from './component'
import { EmitFn, EmitsOptions } from './componentEmits'
import { ComponentObjectPropsOptions, ExtractPropTypes } from './componentProps'
import {
ComponentPropsOptions,
ComponentObjectPropsOptions,
ExtractPropTypes
} from './componentProps'
import { warn } from './warning'

// dev only
Expand Down
20 changes: 12 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion scripts/aliases.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ const entries = {
const nonSrcPackages = [
'sfc-playground',
'size-check',
'template-explorer'
'template-explorer',
'dts-test'
]

for (const dir of dirs) {
Expand Down
13 changes: 0 additions & 13 deletions test-dts/README.md

This file was deleted.

8 changes: 0 additions & 8 deletions test-dts/tsconfig.json

This file was deleted.

2 changes: 1 addition & 1 deletion tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
"packages/template-explorer",
"packages/sfc-playground",
"packages/size-check",
"test-dts"
"packages/dts-test"
]
}
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@
"packages/*/src",
"packages/runtime-dom/types/jsx.d.ts",
"packages/*/__tests__",
"test-dts"
"packages/dts-test"
]
}

0 comments on commit 1ddde63

Please sign in to comment.