chore(deps): bump TS to 5.4

This commit is contained in:
Evan You 2024-04-15 13:36:43 +08:00
parent 16174da21d
commit 7ae9dbf57d
No known key found for this signature in database
GPG Key ID: B9D421896CA450FB
11 changed files with 127 additions and 72 deletions

View File

@ -20,7 +20,7 @@
"test-unit": "vitest -c vitest.unit.config.ts",
"test-e2e": "node scripts/build.js vue -f global -d && vitest -c vitest.e2e.config.ts",
"test-dts": "run-s build-dts test-dts-only",
"test-dts-only": "tsc -p ./packages/dts-test/tsconfig.test.json",
"test-dts-only": "tsc -p packages/dts-built-test/tsconfig.json && tsc -p ./packages/dts-test/tsconfig.test.json",
"test-coverage": "vitest -c vitest.unit.config.ts --coverage",
"test-bench": "vitest bench",
"release": "node scripts/release.js",
@ -111,7 +111,7 @@
"todomvc-app-css": "^2.4.3",
"tslib": "^2.6.2",
"tsx": "^4.7.2",
"typescript": "^5.2.2",
"typescript": "~5.4.5",
"vite": "^5.2.7",
"vitest": "^1.4.0"
}

View File

@ -28,7 +28,7 @@ import {
getVNodeHelper,
locStub,
} from './ast'
import { type RawSourceMap, SourceMapGenerator } from 'source-map-js'
import { SourceMapGenerator } from 'source-map-js'
import {
advancePositionWithMutation,
assert,
@ -56,6 +56,45 @@ import {
} from './runtimeHelpers'
import type { ImportItem } from './transform'
/**
* The `SourceMapGenerator` type from `source-map-js` is a bit incomplete as it
* misses `toJSON()`. We also need to add types for internal properties which we
* need to access for better performance.
*
* Since TS 5.3, dts generation starts to strangely include broken triple slash
* references for source-map-js, so we are inlining all source map related types
* here to to workaround that.
*/
export interface CodegenSourceMapGenerator {
setSourceContent(sourceFile: string, sourceContent: string): void
// SourceMapGenerator has this method but the types do not include it
toJSON(): RawSourceMap
_sources: Set<string>
_names: Set<string>
_mappings: {
add(mapping: MappingItem): void
}
}
export interface RawSourceMap {
file?: string
sourceRoot?: string
version: string
sources: string[]
names: string[]
sourcesContent?: string[]
mappings: string
}
interface MappingItem {
source: string
generatedLine: number
generatedColumn: number
originalLine: number
originalColumn: number
name: string | null
}
const PURE_ANNOTATION = `/*#__PURE__*/`
const aliasHelper = (s: symbol) => `${helperNameMap[s]}: _${helperNameMap[s]}`
@ -85,7 +124,7 @@ export interface CodegenContext
offset: number
indentLevel: number
pure: boolean
map?: SourceMapGenerator
map?: CodegenSourceMapGenerator
helper(key: symbol): string
push(code: string, newlineIndex?: number, node?: CodegenNode): void
indent(): void
@ -218,14 +257,14 @@ function createCodegenContext(
generatedLine: context.line,
generatedColumn: context.column - 1,
source: filename,
// @ts-expect-error it is possible to be null
name,
})
}
if (!__BROWSER__ && sourceMap) {
// lazy require source-map implementation, only in non-browser builds
context.map = new SourceMapGenerator()
context.map =
new SourceMapGenerator() as unknown as CodegenSourceMapGenerator
context.map.setSourceContent(filename, context.source)
context.map._sources.add(filename)
}

View File

@ -21,7 +21,13 @@ export {
type StructuralDirectiveTransform,
type DirectiveTransform,
} from './transform'
export { generate, type CodegenContext, type CodegenResult } from './codegen'
export {
generate,
type CodegenContext,
type CodegenResult,
type CodegenSourceMapGenerator,
type RawSourceMap,
} from './codegen'
export {
ErrorCodes,
errorMessages,

View File

@ -1,15 +1,17 @@
import {
type BindingMetadata,
type CodegenSourceMapGenerator,
type CompilerError,
type ElementNode,
NodeTypes,
type ParserOptions,
type RawSourceMap,
type RootNode,
type SourceLocation,
createRoot,
} from '@vue/compiler-core'
import * as CompilerDOM from '@vue/compiler-dom'
import { type RawSourceMap, SourceMapGenerator } from 'source-map-js'
import { SourceMapGenerator } from 'source-map-js'
import type { TemplateCompiler } from './compileTemplate'
import { parseCssVars } from './style/cssVars'
import { createCache } from './cache'
@ -375,7 +377,7 @@ function generateSourceMap(
const map = new SourceMapGenerator({
file: filename.replace(/\\/g, '/'),
sourceRoot: sourceRoot.replace(/\\/g, '/'),
})
}) as unknown as CodegenSourceMapGenerator
map.setSourceContent(filename, source)
map._sources.add(filename)
generated.split(splitRE).forEach((line, index) => {
@ -390,7 +392,6 @@ function generateSourceMap(
generatedLine,
generatedColumn: i,
source: filename,
// @ts-expect-error
name: null,
})
}

View File

@ -2,7 +2,7 @@
"name": "@vue/dts-built-test",
"private": true,
"version": "0.0.0",
"types": "dist/dts-built-test.d.ts",
"types": "dist/index.d.ts",
"dependencies": {
"@vue/shared": "workspace:*",
"@vue/reactivity": "workspace:*",

View File

@ -0,0 +1,14 @@
{
"compilerOptions": {
"baseUrl": ".",
"outDir": "dist",
"jsx": "preserve",
"module": "esnext",
"strict": true,
"moduleResolution": "Bundler",
"lib": ["esnext", "dom"],
"declaration": true,
"emitDeclarationOnly": true
},
"include": ["./src"]
}

12
packages/global.d.ts vendored
View File

@ -45,18 +45,6 @@ declare module 'estree-walker' {
)
}
declare module 'source-map-js' {
export interface SourceMapGenerator {
// SourceMapGenerator has this method but the types do not include it
toJSON(): RawSourceMap
_sources: Set<string>
_names: Set<string>
_mappings: {
add(mapping: MappingItem): void
}
}
}
declare interface String {
/**
* @deprecated Please use String.prototype.slice instead of String.prototype.substring in the repository.

View File

@ -409,5 +409,5 @@ export const toReactive = <T extends unknown>(value: T): T =>
*
* @param value - The value for which a readonly proxy shall be created.
*/
export const toReadonly = <T extends unknown>(value: T): T =>
isObject(value) ? readonly(value) : value
export const toReadonly = <T extends unknown>(value: T): DeepReadonly<T> =>
isObject(value) ? readonly(value) : (value as DeepReadonly<T>)

View File

@ -1,3 +1,2 @@
// serve vue to the iframe sandbox during dev.
// @ts-expect-error
export * from 'vue/dist/vue.runtime.esm-browser.prod.js'

View File

@ -49,10 +49,10 @@ importers:
version: 7.5.8
'@typescript-eslint/eslint-plugin':
specifier: ^7.4.0
version: 7.4.0(@typescript-eslint/parser@7.4.0)(eslint@8.57.0)(typescript@5.2.2)
version: 7.4.0(@typescript-eslint/parser@7.4.0)(eslint@8.57.0)(typescript@5.4.5)
'@typescript-eslint/parser':
specifier: ^7.4.0
version: 7.4.0(eslint@8.57.0)(typescript@5.2.2)
version: 7.4.0(eslint@8.57.0)(typescript@5.4.5)
'@vitest/coverage-istanbul':
specifier: ^1.4.0
version: 1.4.0(vitest@1.4.0)
@ -82,7 +82,7 @@ importers:
version: /eslint-plugin-i@2.29.1(@typescript-eslint/parser@7.4.0)(eslint@8.57.0)
eslint-plugin-jest:
specifier: ^27.9.0
version: 27.9.0(@typescript-eslint/eslint-plugin@7.4.0)(eslint@8.57.0)(typescript@5.2.2)
version: 27.9.0(@typescript-eslint/eslint-plugin@7.4.0)(eslint@8.57.0)(typescript@5.4.5)
estree-walker:
specifier: ^2.0.2
version: 2.0.2
@ -127,7 +127,7 @@ importers:
version: 3.0.2
puppeteer:
specifier: ~22.6.3
version: 22.6.3(typescript@5.2.2)
version: 22.6.3(typescript@5.4.5)
rimraf:
specifier: ^5.0.5
version: 5.0.5
@ -136,7 +136,7 @@ importers:
version: 4.13.2
rollup-plugin-dts:
specifier: ^6.1.0
version: 6.1.0(rollup@4.13.2)(typescript@5.2.2)
version: 6.1.0(rollup@4.13.2)(typescript@5.4.5)
rollup-plugin-esbuild:
specifier: ^6.1.1
version: 6.1.1(esbuild@0.20.2)(rollup@4.13.2)
@ -165,8 +165,8 @@ importers:
specifier: ^4.7.2
version: 4.7.2
typescript:
specifier: ^5.2.2
version: 5.2.2
specifier: ~5.4.5
version: 5.4.5
vite:
specifier: ^5.2.7
version: 5.2.7(@types/node@20.12.5)(terser@5.30.1)
@ -1524,7 +1524,7 @@ packages:
dev: true
optional: true
/@typescript-eslint/eslint-plugin@7.4.0(@typescript-eslint/parser@7.4.0)(eslint@8.57.0)(typescript@5.2.2):
/@typescript-eslint/eslint-plugin@7.4.0(@typescript-eslint/parser@7.4.0)(eslint@8.57.0)(typescript@5.4.5):
resolution: {integrity: sha512-yHMQ/oFaM7HZdVrVm/M2WHaNPgyuJH4WelkSVEWSSsir34kxW2kDJCxlXRhhGWEsMN0WAW/vLpKfKVcm8k+MPw==}
engines: {node: ^18.18.0 || >=20.0.0}
peerDependencies:
@ -1536,10 +1536,10 @@ packages:
optional: true
dependencies:
'@eslint-community/regexpp': 4.9.1
'@typescript-eslint/parser': 7.4.0(eslint@8.57.0)(typescript@5.2.2)
'@typescript-eslint/parser': 7.4.0(eslint@8.57.0)(typescript@5.4.5)
'@typescript-eslint/scope-manager': 7.4.0
'@typescript-eslint/type-utils': 7.4.0(eslint@8.57.0)(typescript@5.2.2)
'@typescript-eslint/utils': 7.4.0(eslint@8.57.0)(typescript@5.2.2)
'@typescript-eslint/type-utils': 7.4.0(eslint@8.57.0)(typescript@5.4.5)
'@typescript-eslint/utils': 7.4.0(eslint@8.57.0)(typescript@5.4.5)
'@typescript-eslint/visitor-keys': 7.4.0
debug: 4.3.4
eslint: 8.57.0
@ -1547,13 +1547,13 @@ packages:
ignore: 5.2.4
natural-compare: 1.4.0
semver: 7.6.0
ts-api-utils: 1.0.3(typescript@5.2.2)
typescript: 5.2.2
ts-api-utils: 1.0.3(typescript@5.4.5)
typescript: 5.4.5
transitivePeerDependencies:
- supports-color
dev: true
/@typescript-eslint/parser@7.4.0(eslint@8.57.0)(typescript@5.2.2):
/@typescript-eslint/parser@7.4.0(eslint@8.57.0)(typescript@5.4.5):
resolution: {integrity: sha512-ZvKHxHLusweEUVwrGRXXUVzFgnWhigo4JurEj0dGF1tbcGh6buL+ejDdjxOQxv6ytcY1uhun1p2sm8iWStlgLQ==}
engines: {node: ^18.18.0 || >=20.0.0}
peerDependencies:
@ -1565,11 +1565,11 @@ packages:
dependencies:
'@typescript-eslint/scope-manager': 7.4.0
'@typescript-eslint/types': 7.4.0
'@typescript-eslint/typescript-estree': 7.4.0(typescript@5.2.2)
'@typescript-eslint/typescript-estree': 7.4.0(typescript@5.4.5)
'@typescript-eslint/visitor-keys': 7.4.0
debug: 4.3.4
eslint: 8.57.0
typescript: 5.2.2
typescript: 5.4.5
transitivePeerDependencies:
- supports-color
dev: true
@ -1590,7 +1590,7 @@ packages:
'@typescript-eslint/visitor-keys': 7.4.0
dev: true
/@typescript-eslint/type-utils@7.4.0(eslint@8.57.0)(typescript@5.2.2):
/@typescript-eslint/type-utils@7.4.0(eslint@8.57.0)(typescript@5.4.5):
resolution: {integrity: sha512-247ETeHgr9WTRMqHbbQdzwzhuyaJ8dPTuyuUEMANqzMRB1rj/9qFIuIXK7l0FX9i9FXbHeBQl/4uz6mYuCE7Aw==}
engines: {node: ^18.18.0 || >=20.0.0}
peerDependencies:
@ -1600,12 +1600,12 @@ packages:
typescript:
optional: true
dependencies:
'@typescript-eslint/typescript-estree': 7.4.0(typescript@5.2.2)
'@typescript-eslint/utils': 7.4.0(eslint@8.57.0)(typescript@5.2.2)
'@typescript-eslint/typescript-estree': 7.4.0(typescript@5.4.5)
'@typescript-eslint/utils': 7.4.0(eslint@8.57.0)(typescript@5.4.5)
debug: 4.3.4
eslint: 8.57.0
ts-api-utils: 1.0.3(typescript@5.2.2)
typescript: 5.2.2
ts-api-utils: 1.0.3(typescript@5.4.5)
typescript: 5.4.5
transitivePeerDependencies:
- supports-color
dev: true
@ -1620,7 +1620,7 @@ packages:
engines: {node: ^18.18.0 || >=20.0.0}
dev: true
/@typescript-eslint/typescript-estree@5.62.0(typescript@5.2.2):
/@typescript-eslint/typescript-estree@5.62.0(typescript@5.4.5):
resolution: {integrity: sha512-CmcQ6uY7b9y694lKdRB8FEel7JbU/40iSAPomu++SjLMntB+2Leay2LO6i8VnJk58MtE9/nQSFIH6jpyRWyYzA==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
peerDependencies:
@ -1635,13 +1635,13 @@ packages:
globby: 11.1.0
is-glob: 4.0.3
semver: 7.6.0
tsutils: 3.21.0(typescript@5.2.2)
typescript: 5.2.2
tsutils: 3.21.0(typescript@5.4.5)
typescript: 5.4.5
transitivePeerDependencies:
- supports-color
dev: true
/@typescript-eslint/typescript-estree@7.4.0(typescript@5.2.2):
/@typescript-eslint/typescript-estree@7.4.0(typescript@5.4.5):
resolution: {integrity: sha512-A99j5AYoME/UBQ1ucEbbMEmGkN7SE0BvZFreSnTd1luq7yulcHdyGamZKizU7canpGDWGJ+Q6ZA9SyQobipePg==}
engines: {node: ^18.18.0 || >=20.0.0}
peerDependencies:
@ -1657,13 +1657,13 @@ packages:
is-glob: 4.0.3
minimatch: 9.0.3
semver: 7.6.0
ts-api-utils: 1.0.3(typescript@5.2.2)
typescript: 5.2.2
ts-api-utils: 1.0.3(typescript@5.4.5)
typescript: 5.4.5
transitivePeerDependencies:
- supports-color
dev: true
/@typescript-eslint/utils@5.62.0(eslint@8.57.0)(typescript@5.2.2):
/@typescript-eslint/utils@5.62.0(eslint@8.57.0)(typescript@5.4.5):
resolution: {integrity: sha512-n8oxjeb5aIbPFEtmQxQYOLI0i9n5ySBEY/ZEHHZqKQSFnxio1rv6dthascc9dLuwrL0RC5mPCxB7vnAVGAYWAQ==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
peerDependencies:
@ -1674,7 +1674,7 @@ packages:
'@types/semver': 7.5.8
'@typescript-eslint/scope-manager': 5.62.0
'@typescript-eslint/types': 5.62.0
'@typescript-eslint/typescript-estree': 5.62.0(typescript@5.2.2)
'@typescript-eslint/typescript-estree': 5.62.0(typescript@5.4.5)
eslint: 8.57.0
eslint-scope: 5.1.1
semver: 7.6.0
@ -1683,7 +1683,7 @@ packages:
- typescript
dev: true
/@typescript-eslint/utils@7.4.0(eslint@8.57.0)(typescript@5.2.2):
/@typescript-eslint/utils@7.4.0(eslint@8.57.0)(typescript@5.4.5):
resolution: {integrity: sha512-NQt9QLM4Tt8qrlBVY9lkMYzfYtNz8/6qwZg8pI3cMGlPnj6mOpRxxAm7BMJN9K0AiY+1BwJ5lVC650YJqYOuNg==}
engines: {node: ^18.18.0 || >=20.0.0}
peerDependencies:
@ -1694,7 +1694,7 @@ packages:
'@types/semver': 7.5.8
'@typescript-eslint/scope-manager': 7.4.0
'@typescript-eslint/types': 7.4.0
'@typescript-eslint/typescript-estree': 7.4.0(typescript@5.2.2)
'@typescript-eslint/typescript-estree': 7.4.0(typescript@5.4.5)
eslint: 8.57.0
semver: 7.6.0
transitivePeerDependencies:
@ -2501,7 +2501,7 @@ packages:
resolution: {integrity: sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==}
dev: false
/cosmiconfig@9.0.0(typescript@5.2.2):
/cosmiconfig@9.0.0(typescript@5.4.5):
resolution: {integrity: sha512-itvL5h8RETACmOTFc4UfIyB2RfEHi71Ax6E/PivVxq9NseKbOWpeyHEOIbmAw1rs8Ak0VursQNww7lf7YtUwzg==}
engines: {node: '>=14'}
peerDependencies:
@ -2514,7 +2514,7 @@ packages:
import-fresh: 3.3.0
js-yaml: 4.1.0
parse-json: 5.2.0
typescript: 5.2.2
typescript: 5.4.5
dev: true
/cross-spawn@7.0.3:
@ -2866,7 +2866,7 @@ packages:
eslint-import-resolver-webpack:
optional: true
dependencies:
'@typescript-eslint/parser': 7.4.0(eslint@8.57.0)(typescript@5.2.2)
'@typescript-eslint/parser': 7.4.0(eslint@8.57.0)(typescript@5.4.5)
debug: 3.2.7
eslint: 8.57.0
eslint-import-resolver-node: 0.3.9
@ -2896,7 +2896,7 @@ packages:
- supports-color
dev: true
/eslint-plugin-jest@27.9.0(@typescript-eslint/eslint-plugin@7.4.0)(eslint@8.57.0)(typescript@5.2.2):
/eslint-plugin-jest@27.9.0(@typescript-eslint/eslint-plugin@7.4.0)(eslint@8.57.0)(typescript@5.4.5):
resolution: {integrity: sha512-QIT7FH7fNmd9n4se7FFKHbsLKGQiw885Ds6Y/sxKgCZ6natwCsXdgPOADnYVxN2QrRweF0FZWbJ6S7Rsn7llug==}
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
peerDependencies:
@ -2909,8 +2909,8 @@ packages:
jest:
optional: true
dependencies:
'@typescript-eslint/eslint-plugin': 7.4.0(@typescript-eslint/parser@7.4.0)(eslint@8.57.0)(typescript@5.2.2)
'@typescript-eslint/utils': 5.62.0(eslint@8.57.0)(typescript@5.2.2)
'@typescript-eslint/eslint-plugin': 7.4.0(@typescript-eslint/parser@7.4.0)(eslint@8.57.0)(typescript@5.4.5)
'@typescript-eslint/utils': 5.62.0(eslint@8.57.0)(typescript@5.4.5)
eslint: 8.57.0
transitivePeerDependencies:
- supports-color
@ -4788,14 +4788,14 @@ packages:
- utf-8-validate
dev: true
/puppeteer@22.6.3(typescript@5.2.2):
/puppeteer@22.6.3(typescript@5.4.5):
resolution: {integrity: sha512-KZOnthMbvr4+7cPKFeeOCJPe8DzOKGC0GbMXmZKOP/YusXQ6sqxA0vt6frstZq3rUJ277qXHlZNFf01VVwdHKw==}
engines: {node: '>=18'}
hasBin: true
requiresBuild: true
dependencies:
'@puppeteer/browsers': 2.2.1
cosmiconfig: 9.0.0(typescript@5.2.2)
cosmiconfig: 9.0.0(typescript@5.4.5)
devtools-protocol: 0.0.1262051
puppeteer-core: 22.6.3
transitivePeerDependencies:
@ -4967,7 +4967,7 @@ packages:
glob: 10.3.10
dev: true
/rollup-plugin-dts@6.1.0(rollup@4.13.2)(typescript@5.2.2):
/rollup-plugin-dts@6.1.0(rollup@4.13.2)(typescript@5.4.5):
resolution: {integrity: sha512-ijSCPICkRMDKDLBK9torss07+8dl9UpY9z1N/zTeA1cIqdzMlpkV3MOOC7zukyvQfDyxa1s3Dl2+DeiP/G6DOw==}
engines: {node: '>=16'}
peerDependencies:
@ -4976,7 +4976,7 @@ packages:
dependencies:
magic-string: 0.30.8
rollup: 4.13.2
typescript: 5.2.2
typescript: 5.4.5
optionalDependencies:
'@babel/code-frame': 7.23.5
dev: true
@ -5503,13 +5503,13 @@ packages:
punycode: 2.3.1
dev: true
/ts-api-utils@1.0.3(typescript@5.2.2):
/ts-api-utils@1.0.3(typescript@5.4.5):
resolution: {integrity: sha512-wNMeqtMz5NtwpT/UZGY5alT+VoKdSsOOP/kqHFcUW1P/VRhH2wJ48+DN2WwUliNbQ976ETwDL0Ifd2VVvgonvg==}
engines: {node: '>=16.13.0'}
peerDependencies:
typescript: '>=4.2.0'
dependencies:
typescript: 5.2.2
typescript: 5.4.5
dev: true
/tslib@1.14.1:
@ -5520,14 +5520,14 @@ packages:
resolution: {integrity: sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==}
dev: true
/tsutils@3.21.0(typescript@5.2.2):
/tsutils@3.21.0(typescript@5.4.5):
resolution: {integrity: sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==}
engines: {node: '>= 6'}
peerDependencies:
typescript: '>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta'
dependencies:
tslib: 1.14.1
typescript: 5.2.2
typescript: 5.4.5
dev: true
/tsx@4.7.2:
@ -5577,6 +5577,13 @@ packages:
resolution: {integrity: sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==}
engines: {node: '>=14.17'}
hasBin: true
dev: false
/typescript@5.4.5:
resolution: {integrity: sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==}
engines: {node: '>=14.17'}
hasBin: true
dev: true
/ufo@1.3.1:
resolution: {integrity: sha512-uY/99gMLIOlJPwATcMVYfqDSxUR9//AUcgZMzwfSTJPDKzA1S8mX4VLqa+fiAtveraQUBCz4FFcwVZBGbwBXIw==}

View File

@ -10,6 +10,7 @@
"packages/runtime-test",
"packages/template-explorer",
"packages/sfc-playground",
"packages/dts-test"
"packages/dts-test",
"packages/dts-built-test"
]
}