test(typia-validator): use `unplugin-typia` (#1000)

* test(typia-validator): use `unplugin-typia`

Fixes #999

* chore: cleanup ignored test-generated
pull/1004/head
Jonathan Haines 2025-03-05 16:13:40 +11:00 committed by GitHub
parent 7007f19734
commit cc26ddcae3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 794 additions and 43 deletions

View File

@ -3,6 +3,6 @@ import baseConfig from './packages/eslint-config/index.js'
export default [
...baseConfig,
{
ignores: ['**/dist/*', '**/test-generated/*'],
ignores: ['**/dist/*'],
},
]

View File

@ -1 +0,0 @@
/test-generated

View File

@ -23,8 +23,7 @@
"dist"
],
"scripts": {
"generate-test": "rimraf test-generated && typia generate --input test --output test-generated --project tsconfig.json && node scripts/add-ts-ignore.cjs",
"test": "npm run generate-test && vitest",
"test": "vitest",
"build:cjs": "tsc -p tsconfig.cjs.json",
"build:esm": "tsc -p tsconfig.esm.json",
"build": "rimraf dist && yarn build:cjs && yarn build:esm",
@ -46,6 +45,7 @@
"typia": "^7.0.0"
},
"devDependencies": {
"@ryoppippi/unplugin-typia": "^1.2.0",
"hono": "^3.11.7",
"rimraf": "^5.0.5",
"typescript": "^5.4.0",

View File

@ -1,27 +0,0 @@
// @ts-check
const fs = require('node:fs')
const path = require('node:path')
// https://github.com/samchon/typia/issues/1432
// typia generated files have some type errors
const generatedFiles = fs
.readdirSync(path.resolve(__dirname, '../test-generated'))
.map((file) => path.resolve(__dirname, '../test-generated', file))
for (const file of generatedFiles) {
const content = fs.readFileSync(file, 'utf8')
const lines = content.split('\n')
const distLines = []
for (const line of lines) {
if (
line.includes('._httpHeaderReadNumber(') ||
line.includes('._httpHeaderReadBigint(') ||
line.includes('._httpHeaderReadBoolean(')
)
distLines.push(`// @ts-ignore`)
distLines.push(line)
}
fs.writeFileSync(file, distLines.join('\n'))
}

View File

@ -2,7 +2,7 @@ import { Hono } from 'hono'
import type { Equal, Expect } from 'hono/utils/types'
import type { tags } from 'typia'
import typia from 'typia'
import { typiaValidator } from '../src/http'
import { typiaValidator } from './http'
// eslint-disable-next-line @typescript-eslint/no-unused-vars
type ExtractSchema<T> = T extends Hono<infer _, infer S> ? S : never

View File

@ -2,7 +2,7 @@ import { Hono } from 'hono'
import type { Equal, Expect } from 'hono/utils/types'
import type { tags } from 'typia'
import typia from 'typia'
import { typiaValidator } from '../src'
import { typiaValidator } from '.'
// eslint-disable-next-line @typescript-eslint/no-unused-vars
type ExtractSchema<T> = T extends Hono<infer _, infer S> ? S : never

View File

@ -0,0 +1,13 @@
import UnpluginTypia from '@ryoppippi/unplugin-typia/vite'
import { defineConfig } from 'vitest/config'
export default defineConfig({
plugins: [
UnpluginTypia({
tsconfig: './tsconfig.json',
}),
],
test: {
globals: true,
},
})

View File

@ -1,8 +0,0 @@
import { defineConfig, defaultExclude } from 'vitest/config'
export default defineConfig({
test: {
globals: true,
exclude: [...defaultExclude, 'test'],
},
})

778
yarn.lock

File diff suppressed because it is too large Load Diff