Skip to content

Commit 8badb83

Browse files
committed
fix: normalize type export paths
1 parent d90a343 commit 8badb83

3 files changed

Lines changed: 25 additions & 3 deletions

File tree

packages/transloadit/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"zod": "3.25.76"
3131
},
3232
"devDependencies": {
33-
"@biomejs/biome": "^2.2.4",
33+
"@biomejs/biome": "^2.3.11",
3434
"@types/debug": "^4.1.12",
3535
"@types/minimist": "^1.2.5",
3636
"@types/node": "^24.10.3",

packages/types/scripts/emit-types.test.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import assert from 'node:assert/strict'
22

3-
import { escapeStringLiteral } from './emit-types.ts'
3+
import { escapeStringLiteral, normalizeExportPath } from './emit-types.ts'
44

55
const cases = [
66
{
@@ -30,3 +30,20 @@ for (const { input, expected } of cases) {
3030
}
3131

3232
console.log('emit-types escapeStringLiteral: ok')
33+
34+
const exportCases = [
35+
{
36+
input: 'robots\\image-resize.ts',
37+
expected: 'robots/image-resize',
38+
},
39+
{
40+
input: 'template.ts',
41+
expected: 'template',
42+
},
43+
]
44+
45+
for (const { input, expected } of exportCases) {
46+
assert.equal(normalizeExportPath(input), expected)
47+
}
48+
49+
console.log('emit-types normalizeExportPath: ok')

packages/types/scripts/emit-types.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,11 @@ const generateFile = (sourceFile: ts.SourceFile, checker: ts.TypeChecker): strin
386386
return `${lines.join('\n')}\n`
387387
}
388388

389+
export const normalizeExportPath = (relPath: string): string => {
390+
const trimmed = relPath.endsWith('.ts') ? relPath.slice(0, -3) : relPath
391+
return trimmed.replace(/\\/g, '/')
392+
}
393+
389394
const main = async () => {
390395
const schemaStats = await stat(schemaRoot).catch(() => null)
391396
if (!schemaStats?.isDirectory()) {
@@ -414,7 +419,7 @@ const main = async () => {
414419
const content = generateFile(sourceFile, checker)
415420
await writeFile(outFile, content, 'utf8')
416421

417-
const exportPath = rel.endsWith('.ts') ? rel.slice(0, -3) : rel
422+
const exportPath = normalizeExportPath(rel)
418423
if (exportPath.endsWith('/index')) {
419424
continue
420425
}

0 commit comments

Comments
 (0)