]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
build: adjust dts test setup
authorEvan You <yyx990803@gmail.com>
Fri, 3 Feb 2023 09:10:31 +0000 (17:10 +0800)
committerEvan You <yyx990803@gmail.com>
Fri, 3 Feb 2023 09:10:31 +0000 (17:10 +0800)
28 files changed:
.eslintrc.js
package.json
packages/dts-test/README.md [new file with mode: 0644]
packages/dts-test/appUse.test-d.ts [moved from test-dts/appUse.test-d.ts with 100% similarity]
packages/dts-test/compiler.test-d.ts [moved from test-dts/compiler.test-d.ts with 100% similarity]
packages/dts-test/component.test-d.ts [moved from test-dts/component.test-d.ts with 100% similarity]
packages/dts-test/componentTypeExtensions.test-d.tsx [moved from test-dts/componentTypeExtensions.test-d.tsx with 100% similarity]
packages/dts-test/defineComponent.test-d.tsx [moved from test-dts/defineComponent.test-d.tsx with 100% similarity]
packages/dts-test/defineCustomElement.test-d.ts [moved from test-dts/defineCustomElement.test-d.ts with 100% similarity]
packages/dts-test/functionalComponent.test-d.tsx [moved from test-dts/functionalComponent.test-d.tsx with 100% similarity]
packages/dts-test/h.test-d.ts [moved from test-dts/h.test-d.ts with 100% similarity]
packages/dts-test/index.d.ts [moved from test-dts/index.d.ts with 94% similarity]
packages/dts-test/inject.test-d.ts [moved from test-dts/inject.test-d.ts with 100% similarity]
packages/dts-test/package.json [new file with mode: 0644]
packages/dts-test/reactivity.test-d.ts [moved from test-dts/reactivity.test-d.ts with 100% similarity]
packages/dts-test/reactivityMacros.test-d.ts [moved from test-dts/reactivityMacros.test-d.ts with 93% similarity]
packages/dts-test/ref.test-d.ts [moved from test-dts/ref.test-d.ts with 100% similarity]
packages/dts-test/setupHelpers.test-d.ts [moved from test-dts/setupHelpers.test-d.ts with 100% similarity]
packages/dts-test/tsconfig.test.json [moved from test-dts/tsconfig.build.json with 100% similarity]
packages/dts-test/tsx.test-d.tsx [moved from test-dts/tsx.test-d.tsx with 100% similarity]
packages/dts-test/watch.test-d.ts [moved from test-dts/watch.test-d.ts with 100% similarity]
packages/runtime-core/src/apiSetupHelpers.ts
pnpm-lock.yaml
scripts/aliases.mjs
test-dts/README.md [deleted file]
test-dts/tsconfig.json [deleted file]
tsconfig.build.json
tsconfig.json

index fe5e1493e0d0f6b6f703573bc39756b3e1a91fff..5d096dd3ab2367bbe066c9e182f1c9d2d263adbe 100644 (file)
@@ -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',
index 48b3a6da5dc8b2d73eba551254629b5d4a5610a3..9edd2c5c6033151ae6106921a0454dd3a87721ef 100644 (file)
@@ -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",
@@ -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"
@@ -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",
     "tslib": "^2.4.0",
     "typescript": "^4.9.0",
     "vite": "^4.0.4",
-    "vitest": "^0.28.2",
-    "vue": "workspace:*"
+    "vitest": "^0.28.2"
   }
 }
diff --git a/packages/dts-test/README.md b/packages/dts-test/README.md
new file mode 100644 (file)
index 0000000..692229f
--- /dev/null
@@ -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`.
similarity index 94%
rename from test-dts/index.d.ts
rename to packages/dts-test/index.d.ts
index 0662a6447e6a9218f64b8cd3e4030430a38c4f8b..2945d492de83339eda723bb2d4aa2eea5c7c5c59 100644 (file)
@@ -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
diff --git a/packages/dts-test/package.json b/packages/dts-test/package.json
new file mode 100644 (file)
index 0000000..72f0e32
--- /dev/null
@@ -0,0 +1,10 @@
+{
+  "name": "dts-test",
+  "private": true,
+  "dependencies": {
+    "vue": "workspace:*",
+    "@vue/runtime-core": "workspace:*",
+    "@vue/runtime-dom": "workspace:*",
+    "@vue/reactivity": "workspace:*"
+  }
+}
similarity index 93%
rename from test-dts/reactivityMacros.test-d.ts
rename to packages/dts-test/reactivityMacros.test-d.ts
index 3bae078297ee70527719b04ad62d2aba726aeb33..6bc5f17cba862120634cdedaf8a8d61a64aa7e66 100644 (file)
@@ -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'
 
index 6f6097aa80918fbb02aacc56638387b09072fb0e..798b3a0c0005aa5398424cb8dc7e2f13db420ae2 100644 (file)
@@ -1,4 +1,3 @@
-import { ComponentPropsOptions } from '@vue/runtime-core'
 import { isArray, isPromise, isFunction } from '@vue/shared'
 import {
   getCurrentInstance,
@@ -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
index b9ee76003f4cf9354c6232304e050861b940d512..927376bffc9f88c9ef2298482988cf9f7d9d48ef 100644 (file)
@@ -18,9 +18,6 @@ importers:
       '@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
@@ -55,7 +52,6 @@ importers:
       typescript: ^4.9.0
       vite: ^4.0.4
       vitest: ^0.28.2
-      vue: workspace:*
     devDependencies:
       '@babel/parser': 7.20.15
       '@babel/types': 7.20.7
@@ -71,9 +67,6 @@ importers:
       '@typescript-eslint/parser': 5.50.0_jofidmxrjzhj7l6vknpw5ecvfe
       '@vitest/coverage-istanbul': 0.28.3_jsdom@21.1.0+terser@5.16.2
       '@vue/consolidate': 0.17.3
-      '@vue/reactivity': link:packages/reactivity
-      '@vue/runtime-core': link:packages/runtime-core
-      '@vue/runtime-dom': link:packages/runtime-dom
       brotli: 1.3.3
       chalk: 4.1.2
       conventional-changelog-cli: 2.2.2
@@ -108,7 +101,6 @@ importers:
       typescript: 4.9.5
       vite: 4.1.1_ghge5pqdvzsmxto52quo4r2say
       vitest: 0.28.3_jsdom@21.1.0+terser@5.16.2
-      vue: link:packages/vue
 
   packages/compiler-core:
     specifiers:
@@ -188,6 +180,18 @@ importers:
       '@vue/compiler-dom': link:../compiler-dom
       '@vue/shared': link:../shared
 
+  packages/dts-test:
+    specifiers:
+      '@vue/reactivity': workspace:*
+      '@vue/runtime-core': workspace:*
+      '@vue/runtime-dom': workspace:*
+      vue: workspace:*
+    dependencies:
+      '@vue/reactivity': link:../reactivity
+      '@vue/runtime-core': link:../runtime-core
+      '@vue/runtime-dom': link:../runtime-dom
+      vue: link:../vue
+
   packages/reactivity:
     specifiers:
       '@vue/shared': 3.2.47
index 4cbdf10b256318484b50e295122bf389ae77cfb4..95e3016322c0c753c2007046857e703a1ed633ed 100644 (file)
@@ -22,7 +22,8 @@ const entries = {
 const nonSrcPackages = [
   'sfc-playground',
   'size-check',
-  'template-explorer'
+  'template-explorer',
+  'dts-test'
 ]
 
 for (const dir of dirs) {
diff --git a/test-dts/README.md b/test-dts/README.md
deleted file mode 100644 (file)
index 966374b..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-# Test-ts
-
-Tests Typescript types to ensure the types remain as expected.
-
-## Configuration
-
-### tsconfig.json
-
-Config used to test against the package source
-
-### tsconfig.build.json
-
-Replaces the `vue` and `@vue/*` dependencies with the built Typescript to ensure the published types are correct.
diff --git a/test-dts/tsconfig.json b/test-dts/tsconfig.json
deleted file mode 100644 (file)
index 433de21..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-{
-  "extends": "../tsconfig.json",
-  "compilerOptions": {
-    "noEmit": true,
-    "declaration": true
-  },
-  "exclude": ["../packages/*/__tests__", "../packages/template-explorer"]
-}
index 8e93e992f6d3ea77bb584aef17106c4f281d2980..8b7749b858b02f5ebedadd528f9e31383bc31c29 100644 (file)
@@ -10,6 +10,6 @@
     "packages/template-explorer",
     "packages/sfc-playground",
     "packages/size-check",
-    "test-dts"
+    "packages/dts-test"
   ]
 }
index 2a3f429d8ad0dd44be76efb857fd97968855762b..15e013c5fa0e2ba793d33e752dd945b8d71b6e16 100644 (file)
@@ -32,6 +32,6 @@
     "packages/*/src",
     "packages/runtime-dom/types/jsx.d.ts",
     "packages/*/__tests__",
-    "test-dts"
+    "packages/dts-test"
   ]
 }