Skip to content

typscript async/await not working #3274

@wedelgaard

Description

@wedelgaard

It seems like async/await it not working when using gatsby-plugin-typescript :( The following error is thrown:

{my path}/gatsby-site/src/pages/index.tsx Unexpected token (13:26) You may need an appropriate loader to handle this file type.

this is how the pages/index.tsx looks like. It works without any problems if index.tsx is renamed to index.js (not typescript), but this is not desirable.
`
import * as React from 'react'
import Link from 'gatsby-link'

const asyncFunc = () => {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve('done!')
}, 1000)
})
}

const getStuff = async () => {
return await asyncFunc()
}

const IndexPage = (props: any) => {

const test = getStuff()

return (
...something
)
}

export default IndexPage
`

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugAn issue or pull request relating to a bug in Gatsby

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions