Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/data-context/src/actions/CodegenActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class CodegenActions {
const src = await this.ctx.fs.readFile(filePath, 'utf8')

const exportResolver: ExportResolver = new Map()
let result = parseReactComponent(src, findAllWithLink(exportResolver))
let result = parseReactComponent(src, findAllWithLink(exportResolver), undefined, { parserOptions: { plugins: ['typescript', 'jsx'] } })

// types appear to be incorrect in [email protected]
// TODO: update when 6.0.0 stable is out for fixed types.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,14 @@ describe('CodegenActions', () => {
expect(components[0].isDefault).to.equal(true)
})

it('correctly parses typescript files', async () => {
const { components } = await actions.getReactComponentsFromFile(`${absolutePathPrefix}/LoginForm.tsx`)

expect(components).to.have.length(1)
expect(components[0].exportName).to.equal('LoginForm')
expect(components[0].isDefault).to.equal(true)
})

it('does not throw while parsing empty file', async () => {
const { components } = await actions.getReactComponentsFromFile(`${absolutePathPrefix}/empty.jsx`)

Expand Down
21 changes: 21 additions & 0 deletions packages/data-context/test/unit/actions/project/LoginForm.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from 'react'

interface LoginFormProps {
onLogin: ({
username,
password,
}: {
username: string
password: string
}) => void
title?: string
errorMessage?: string
}

const LoginForm: React.FC<LoginFormProps> = (props) => {
return (
<div />
)
}

export default LoginForm