]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
chore(types): perform strict es2016 lib check when building dts
authorEvan You <yyx990803@gmail.com>
Mon, 15 Apr 2024 07:52:48 +0000 (15:52 +0800)
committerEvan You <yyx990803@gmail.com>
Mon, 15 Apr 2024 07:52:48 +0000 (15:52 +0800)
package.json
packages/compiler-sfc/src/compileStyle.ts
packages/compiler-sfc/src/compileTemplate.ts
packages/compiler-sfc/src/style/preprocessors.ts
packages/runtime-core/src/compat/global.ts
packages/shared/src/general.ts
packages/shared/src/toDisplayString.ts
tsconfig.build-browser.json [new file with mode: 0644]
tsconfig.build-node.json [new file with mode: 0644]
tsconfig.build.json [deleted file]

index 071c51311a37364b418d183ac4163e8e50172177..2c8ba0b817c340d99cb549b6d5d2283d3b78c0c1 100644 (file)
@@ -6,7 +6,7 @@
   "scripts": {
     "dev": "node scripts/dev.js",
     "build": "node scripts/build.js",
-    "build-dts": "tsc -p tsconfig.build.json && rollup -c rollup.dts.config.js",
+    "build-dts": "tsc -p tsconfig.build-browser.json && tsc -p tsconfig.build-node.json && rollup -c rollup.dts.config.js",
     "clean": "rimraf packages/*/dist temp .eslintcache",
     "size": "run-s \"size-*\" && tsx scripts/usage-size.ts",
     "size-global": "node scripts/build.js vue runtime-dom -f global -p --size",
index 4390014e89e2980a55f1f3ab38edebaae59c3d6f..f27a6338e8e0b94c8fc0716090f7ddc37834403e 100644 (file)
@@ -13,7 +13,7 @@ import {
   type StylePreprocessorResults,
   processors,
 } from './style/preprocessors'
-import type { RawSourceMap } from 'source-map-js'
+import type { RawSourceMap } from '@vue/compiler-core'
 import { cssVarsPlugin } from './style/cssVars'
 import postcssModules from 'postcss-modules'
 
index 2d5ffdad7d8d4d78ce19fc446e49c172244afeae..5ba8a5e481298161b086f9a392b016a421fe4371 100644 (file)
@@ -6,14 +6,11 @@ import {
   type NodeTransform,
   NodeTypes,
   type ParserOptions,
+  type RawSourceMap,
   type RootNode,
   createRoot,
 } from '@vue/compiler-core'
-import {
-  type RawSourceMap,
-  SourceMapConsumer,
-  SourceMapGenerator,
-} from 'source-map-js'
+import { SourceMapConsumer, SourceMapGenerator } from 'source-map-js'
 import {
   type AssetURLOptions,
   type AssetURLTagConfig,
index 7915d1d14065f52ef26f32ec0556341edb075705..6a974368eccc191f019a1902a6ae5c8bfe4df23c 100644 (file)
@@ -1,5 +1,5 @@
 import merge from 'merge-source-map'
-import type { RawSourceMap } from 'source-map-js'
+import type { RawSourceMap } from '@vue/compiler-core'
 import type { SFCStyleCompileOptions } from '../compileStyle'
 import { isFunction } from '@vue/shared'
 
index 5bf234fcf4592fe68f89fbc7f09fb195fd3caca9..1c633ed52a3708e3fa64823bcd0182a49c5f8af5 100644 (file)
@@ -427,15 +427,14 @@ function applySingletonPrototype(app: App, Ctor: Function) {
     app.config.globalProperties = Object.create(Ctor.prototype)
   }
   let hasPrototypeAugmentations = false
-  const descriptors = Object.getOwnPropertyDescriptors(Ctor.prototype)
-  for (const key in descriptors) {
+  for (const key of Object.getOwnPropertyNames(Ctor.prototype)) {
     if (key !== 'constructor') {
       hasPrototypeAugmentations = true
       if (enabled) {
         Object.defineProperty(
           app.config.globalProperties,
           key,
-          descriptors[key],
+          Object.getOwnPropertyDescriptor(Ctor.prototype, key)!,
         )
       }
     }
index e04b961227adf545099818c2706cc59210323a34..47ab0229255e9431b3e51f877457bc02439bf295 100644 (file)
@@ -165,6 +165,9 @@ export const toNumber = (val: any): any => {
   return isNaN(n) ? val : n
 }
 
+// for typeof global checks without @types/node
+declare var global: {}
+
 let _globalThis: any
 export const getGlobalThis = (): any => {
   return (
index aff107cd97fabc5201674e2ece7c946c1bf99596..b63cb4112a5bff2aee777e30cbebfe0666fe7b38 100644 (file)
@@ -54,4 +54,6 @@ const replacer = (_key: string, val: any): any => {
 }
 
 const stringifySymbol = (v: unknown, i: number | string = ''): any =>
-  isSymbol(v) ? `Symbol(${v.description ?? i})` : v
+  // Symbol.description in es2019+ so we need to cast here to pass
+  // the lib: es2016 check
+  isSymbol(v) ? `Symbol(${(v as any).description ?? i})` : v
diff --git a/tsconfig.build-browser.json b/tsconfig.build-browser.json
new file mode 100644 (file)
index 0000000..707c99e
--- /dev/null
@@ -0,0 +1,20 @@
+{
+  "extends": "./tsconfig.json",
+  "compilerOptions": {
+    "types": [],
+    "declaration": true,
+    "emitDeclarationOnly": true,
+    "stripInternal": true
+  },
+  "include": [
+    "packages/global.d.ts",
+    "packages/vue/src",
+    "packages/vue-compat/src",
+    "packages/compiler-core/src",
+    "packages/compiler-dom/src",
+    "packages/runtime-core/src",
+    "packages/runtime-dom/src",
+    "packages/reactivity/src",
+    "packages/shared/src"
+  ]
+}
diff --git a/tsconfig.build-node.json b/tsconfig.build-node.json
new file mode 100644 (file)
index 0000000..fac1412
--- /dev/null
@@ -0,0 +1,15 @@
+{
+  "extends": "./tsconfig.json",
+  "compilerOptions": {
+    "types": ["node"],
+    "declaration": true,
+    "emitDeclarationOnly": true,
+    "stripInternal": true
+  },
+  "include": [
+    "packages/global.d.ts",
+    "packages/compiler-sfc/src",
+    "packages/compiler-ssr/src",
+    "packages/server-renderer/src"
+  ]
+}
diff --git a/tsconfig.build.json b/tsconfig.build.json
deleted file mode 100644 (file)
index ea2aecc..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-{
-  "extends": "./tsconfig.json",
-  "compilerOptions": {
-    "declaration": true,
-    "emitDeclarationOnly": true,
-    "stripInternal": true
-  },
-  "exclude": [
-    "packages/*/__tests__",
-    "packages/runtime-test",
-    "packages/template-explorer",
-    "packages/sfc-playground",
-    "packages/dts-test",
-    "packages/dts-built-test"
-  ]
-}