Skip to content

Commit bc2495f

Browse files
authored
chore: replace tsc with tsgo (#21893)
1 parent bce7046 commit bc2495f

File tree

10 files changed

+118
-101
lines changed

10 files changed

+118
-101
lines changed

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"@types/yargs": "^17.0.33",
4141
"@typescript-eslint/eslint-plugin": "^8.32.0",
4242
"@typescript-eslint/parser": "^8.32.0",
43+
"@typescript/native-preview": "7.0.0-dev.20250912.1",
4344
"@unhead/vue": "^2.0.5",
4445
"@vitejs/plugin-vue": "^5.2.1",
4546
"@vue/compiler-sfc": "^3.5.13",
@@ -89,6 +90,7 @@
8990
"vue": "^3.5.13",
9091
"vue-eslint-parser": "^10.1.3",
9192
"vue-tsc": "^2.2.10",
93+
"vuetify": "workspace:*",
9294
"yargs": "^17.7.2"
9395
},
9496
"packageManager": "[email protected]"

packages/vuetify/build/remove-dts-styles.cts

Lines changed: 0 additions & 19 deletions
This file was deleted.

packages/vuetify/build/transform-types.js

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import path from 'upath'
55

66
const files = fg.sync('lib/**/*.d.ts')
77

8-
const importRegexp = /(?<a1>(?:import|export)(?:[^;])*?from ['"])(?<a2>\.\.?(?:\/[^;'"]*)?)(?<a3>['"];)|(?<b1>import\(['"])(?<b2>\.\.?(?:\/[^;'"]*)?)(?<b3>['"]\))/gm
8+
const importRegexp = /(?<a1>(?:import|export)(?:[^;])*?from ['"])(?<a2>(?:\.\.?|@)(?:\/[^;'"]*)?)(?<a3>['"];)|(?<b1>import\(['"])(?<b2>(?:\.\.?|@)(?:\/[^;'"]*)?)(?<b3>['"]\))/gm
99

1010
for (const name of files) {
1111
const code = await fs.readFile(name, 'utf-8')
@@ -14,19 +14,29 @@ for (const name of files) {
1414

1515
for (const match of code.matchAll(importRegexp)) {
1616
const pre = match.groups.a1 ?? match.groups.b1
17-
const matchPath = match.groups.a2 ?? match.groups.b2
17+
let matchPath = match.groups.a2 ?? match.groups.b2
1818
const post = match.groups.a3 ?? match.groups.b3
19-
if (/\.[jt]s$/.test(matchPath)) continue
20-
21-
let target
22-
try {
23-
const dir = await fs.stat(path.join(path.dirname(name), matchPath))
24-
target = matchPath + '/index.js'
25-
} catch (err) {
26-
if (err.code !== 'ENOENT') throw err
27-
target = matchPath + '.js'
19+
20+
let target = matchPath
21+
if (target.startsWith('@/')) {
22+
target = path.relative(path.dirname(name), target.replace(/^@\//, 'lib/'))
23+
if (!target.startsWith('.')) {
24+
target = './' + target
25+
}
26+
}
27+
28+
if (!/\.[jt]s$/.test(target)) {
29+
try {
30+
const dir = await fs.stat(path.join(path.dirname(name), target))
31+
target = target + '/index.js'
32+
} catch (err) {
33+
if (err.code !== 'ENOENT') throw err
34+
target = target + '.js'
35+
}
36+
}
37+
if (target !== matchPath) {
38+
newCode = newCode.replace(match[0], pre + target + post)
2839
}
29-
newCode = newCode.replace(match[0], pre + target + post)
3040
}
3141

3242
if (newCode === code) continue

packages/vuetify/build/types-code-transform.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@ export function codeTransform (code) {
88
.replaceAll(/import([^;])*?from 'vue-router'/gm, '// @ts-ignore\n$&')
99
// tsc adds extra export statements to namespaces that break module augmentation
1010
.replaceAll(/^\s*export \{\s*\};?$/gm, '')
11+
// ignore style imports
12+
.replaceAll(/import '[^']*\.s[ac]ss';$/gm, '')
1113
}

packages/vuetify/package.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115
"build:dist": "rollup --config build/rollup.config.js",
116116
"build:lib": "NODE_ENV=lib babel src --out-dir lib --source-maps --extensions \".ts\",\".tsx\",\".snap\" --copy-files --no-copy-ignored --out-file-extension .js",
117117
"build:types": "pnpm build:types:lib && pnpm build:types:bundle",
118-
"build:types:lib": "tspc --pretty --emitDeclarationOnly -p tsconfig.dist.json && node build/transform-types.js",
118+
"build:types:lib": "tsgo --pretty --emitDeclarationOnly -p tsconfig.dist.json && node build/transform-types.js",
119119
"build:types:bundle": "rollup --config build/rollup.types.config.js",
120120
"tsc": "tsc",
121121
"test": "vitest",
@@ -125,8 +125,8 @@
125125
"test:coverage": "pnpm test --coverage",
126126
"test:percy": "percy exec -- vitest --project browser",
127127
"test:all": "concurrently -gr 'vitest --project unit' 'vitest --project browser --shard=1/5' 'vitest --project browser --shard=2/5' 'vitest --project browser --shard=3/5' 'vitest --project browser --shard=4/5' 'vitest --project browser --shard=5/5'",
128-
"lint": "concurrently -n \"tsc,eslint\" --kill-others-on-fail \"tsc -p tsconfig.checks.json --noEmit --pretty\" \"eslint src -f codeframe --max-warnings 0\"",
129-
"lint:fix": "concurrently -n \"tsc,eslint\" \"tsc -p tsconfig.checks.json --noEmit --pretty\" \"eslint --fix src\""
128+
"lint": "concurrently -n \"tsc,eslint\" --kill-others-on-fail \"tsgo -p tsconfig.checks.json --noEmit --pretty\" \"eslint src -f codeframe --max-warnings 0\"",
129+
"lint:fix": "concurrently -n \"tsc,eslint\" \"tsgo -p tsconfig.checks.json --noEmit --pretty\" \"eslint --fix src\""
130130
},
131131
"devDependencies": {
132132
"@date-io/core": "3.2.0",
@@ -180,8 +180,6 @@
180180
"roboto-fontface": "^0.10.0",
181181
"timezone-mock": "^1.3.6",
182182
"ts-node": "^10.9.2",
183-
"ts-patch": "^3.3.0",
184-
"typescript-transform-paths": "^3.5.5",
185183
"unplugin-auto-import": "19.3.0",
186184
"unplugin-vue-components": "^0.28.0",
187185
"upath": "^2.0.1",

packages/vuetify/tsconfig.dist.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,5 @@
44
"compilerOptions": {
55
"outDir": "./lib",
66
"emitDeclarationOnly": true,
7-
"plugins": [
8-
{ "transform": "typescript-transform-paths", "afterDeclarations": true },
9-
{ "transform": "./build/remove-dts-styles.cts", "afterDeclarations": true },
10-
],
117
},
128
}

packages/vuetify/tsconfig.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@
66
],
77
"exclude": ["**/*.spec.cy.ts", "**/*.spec.cy.tsx"],
88
"compilerOptions": {
9-
"baseUrl": ".",
109
"paths": {
11-
"@/*": ["src/*"],
12-
"@test": ["test/index.ts"]
10+
"@/*": ["./src/*"],
11+
"@test": ["./test/index.ts"]
1312
},
1413
"types": [
1514
"node",

packages/vuetify/vitest.workspace.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,13 @@ export default defineWorkspace([
3737
capabilities: {
3838
browserVersion: '136',
3939
'goog:chromeOptions': {
40-
// @ts-expect-error
4140
args: [
4241
'--start-maximized',
4342
process.env.TEST_BAIL && '--auto-open-devtools-for-tabs',
4443
// I have no idea why this is needed, it throws "WebDriverError: session
4544
// not created: probably user data directory is already in use" without it
4645
process.env.CI && '--no-sandbox',
47-
].filter(v => !!v),
46+
].filter(v => !!v) as string[],
4847
},
4948
},
5049
}],

0 commit comments

Comments
 (0)