import { describe, expect, it } from 'vitest'
import type { Props } from '../html-types.ts'
import type { Handle } from '@remix-run/component'
describe('Props type', () => {
it('works with simple components w/o props', () => {
function Test() {
return null
}
let el =
// @ts-expect-error - unknown prop
let el2 =
expect(true).toBe(true)
})
it('works with simple components with props', () => {
function Test({ foo }: { foo: string }) {
return null
}
let el =
// @ts-expect-error - missing prop
let el2 =
expect(true).toBe(true)
})
it('works with Handle components', () => {
function Test(this: Handle) {
return null
}
let el =
// @ts-expect-error - unknown prop
let el2 =
expect(true).toBe(true)
})
it('works with Handle components with props', () => {
function Test(this: Handle) {
return ({ foo }: { foo: string }) => null
}
let el =
// @ts-expect-error - missing prop
let el2 =
expect(true).toBe(true)
})
it('works with stateful components', () => {
function Test(this: Handle) {
return () => null
}
let el =
// @ts-expect-error - unknown prop
let el2 =
expect(true).toBe(true)
})
it('works with setup/render props', () => {
function Test(this: Handle, { initial }: { initial: string }) {
return ({ foo }: { foo: string }) => null
}
let el =
// @ts-expect-error - missing prop
let el2 =
// @ts-expect-error - foo
let el3 =
expect(true).toBe(true)
})
it('works with required setup prop and optional render prop', () => {
function Test(this: Handle, { initial }: { initial: string }) {
return ({ foo }: { foo?: string }) => null
}
let el =
let el2 =
let el3 =
// @ts-expect-error - missing initial
let el4 =
expect(true).toBe(true)
})
it('works with required render prop and optional setup prop', () => {
function Test(this: Handle, { initial }: { initial?: string }) {
return ({ foo }: { foo: string }) => null
}
let el =
let el2 =
let el3 =
// @ts-expect-error - missing foo
let el4 =
expect(true).toBe(true)
})
it('allows aria props', () => {
let el =
expect(true).toBe(true)
})
it('maintains original types', () => {
function TestComp1({ foo }: { foo: string }) {
return {foo}
}
// @ts-expect-error - missing `foo`
let el1 =
interface TestProps extends Props<'div'> {
foo: string
}
function TestComp2({ foo }: TestProps) {
return {foo}
}
// @ts-expect-error - missing `foo`
let el2 =
let el3 =
// get test to pass, we only care about `typecheck`
expect(true).toBe(true)
})
})