Skip to content

Commit

Permalink
chore(types): perform strict es2016 lib check when building dts
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Apr 15, 2024
1 parent 7ae9dbf commit 2ae908d
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 28 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/compiler-sfc/src/compileStyle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
7 changes: 2 additions & 5 deletions packages/compiler-sfc/src/compileTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion packages/compiler-sfc/src/style/preprocessors.ts
Original file line number Diff line number Diff line change
@@ -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'

Expand Down
5 changes: 2 additions & 3 deletions packages/runtime-core/src/compat/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)!,
)
}
}
Expand Down
3 changes: 3 additions & 0 deletions packages/shared/src/general.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
4 changes: 3 additions & 1 deletion packages/shared/src/toDisplayString.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
20 changes: 20 additions & 0 deletions tsconfig.build-browser.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
15 changes: 15 additions & 0 deletions tsconfig.build-node.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
16 changes: 0 additions & 16 deletions tsconfig.build.json

This file was deleted.

0 comments on commit 2ae908d

Please sign in to comment.