Skip to content

Commit 2ae908d

Browse files
committed
chore(types): perform strict es2016 lib check when building dts
1 parent 7ae9dbf commit 2ae908d

File tree

10 files changed

+48
-28
lines changed

10 files changed

+48
-28
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"scripts": {
77
"dev": "node scripts/dev.js",
88
"build": "node scripts/build.js",
9-
"build-dts": "tsc -p tsconfig.build.json && rollup -c rollup.dts.config.js",
9+
"build-dts": "tsc -p tsconfig.build-browser.json && tsc -p tsconfig.build-node.json && rollup -c rollup.dts.config.js",
1010
"clean": "rimraf packages/*/dist temp .eslintcache",
1111
"size": "run-s \"size-*\" && tsx scripts/usage-size.ts",
1212
"size-global": "node scripts/build.js vue runtime-dom -f global -p --size",

packages/compiler-sfc/src/compileStyle.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
type StylePreprocessorResults,
1414
processors,
1515
} from './style/preprocessors'
16-
import type { RawSourceMap } from 'source-map-js'
16+
import type { RawSourceMap } from '@vue/compiler-core'
1717
import { cssVarsPlugin } from './style/cssVars'
1818
import postcssModules from 'postcss-modules'
1919

packages/compiler-sfc/src/compileTemplate.ts

+2-5
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,11 @@ import {
66
type NodeTransform,
77
NodeTypes,
88
type ParserOptions,
9+
type RawSourceMap,
910
type RootNode,
1011
createRoot,
1112
} from '@vue/compiler-core'
12-
import {
13-
type RawSourceMap,
14-
SourceMapConsumer,
15-
SourceMapGenerator,
16-
} from 'source-map-js'
13+
import { SourceMapConsumer, SourceMapGenerator } from 'source-map-js'
1714
import {
1815
type AssetURLOptions,
1916
type AssetURLTagConfig,

packages/compiler-sfc/src/style/preprocessors.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import merge from 'merge-source-map'
2-
import type { RawSourceMap } from 'source-map-js'
2+
import type { RawSourceMap } from '@vue/compiler-core'
33
import type { SFCStyleCompileOptions } from '../compileStyle'
44
import { isFunction } from '@vue/shared'
55

packages/runtime-core/src/compat/global.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -427,15 +427,14 @@ function applySingletonPrototype(app: App, Ctor: Function) {
427427
app.config.globalProperties = Object.create(Ctor.prototype)
428428
}
429429
let hasPrototypeAugmentations = false
430-
const descriptors = Object.getOwnPropertyDescriptors(Ctor.prototype)
431-
for (const key in descriptors) {
430+
for (const key of Object.getOwnPropertyNames(Ctor.prototype)) {
432431
if (key !== 'constructor') {
433432
hasPrototypeAugmentations = true
434433
if (enabled) {
435434
Object.defineProperty(
436435
app.config.globalProperties,
437436
key,
438-
descriptors[key],
437+
Object.getOwnPropertyDescriptor(Ctor.prototype, key)!,
439438
)
440439
}
441440
}

packages/shared/src/general.ts

+3
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,9 @@ export const toNumber = (val: any): any => {
165165
return isNaN(n) ? val : n
166166
}
167167

168+
// for typeof global checks without @types/node
169+
declare var global: {}
170+
168171
let _globalThis: any
169172
export const getGlobalThis = (): any => {
170173
return (

packages/shared/src/toDisplayString.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,6 @@ const replacer = (_key: string, val: any): any => {
5454
}
5555

5656
const stringifySymbol = (v: unknown, i: number | string = ''): any =>
57-
isSymbol(v) ? `Symbol(${v.description ?? i})` : v
57+
// Symbol.description in es2019+ so we need to cast here to pass
58+
// the lib: es2016 check
59+
isSymbol(v) ? `Symbol(${(v as any).description ?? i})` : v

tsconfig.build-browser.json

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"types": [],
5+
"declaration": true,
6+
"emitDeclarationOnly": true,
7+
"stripInternal": true
8+
},
9+
"include": [
10+
"packages/global.d.ts",
11+
"packages/vue/src",
12+
"packages/vue-compat/src",
13+
"packages/compiler-core/src",
14+
"packages/compiler-dom/src",
15+
"packages/runtime-core/src",
16+
"packages/runtime-dom/src",
17+
"packages/reactivity/src",
18+
"packages/shared/src"
19+
]
20+
}

tsconfig.build-node.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"types": ["node"],
5+
"declaration": true,
6+
"emitDeclarationOnly": true,
7+
"stripInternal": true
8+
},
9+
"include": [
10+
"packages/global.d.ts",
11+
"packages/compiler-sfc/src",
12+
"packages/compiler-ssr/src",
13+
"packages/server-renderer/src"
14+
]
15+
}

tsconfig.build.json

-16
This file was deleted.

0 commit comments

Comments
 (0)