Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

MooseSaid's avatar

How to import an exported constant from typescript file to javascript file

I'm trying to import a constant from typescript file in javascript file but I'm always ending up with Unexpected token, expected , error.

Here is the constant in ts file:

export const articleQuery = (slug: string, categorySlug?: string) => 'context'

And I want to be able to use this function in a javascript file like this and pass the params.

import {articleQuery} from "./path/to/file.ts"

const query = articleQuery(slug, categorySlug)

I'm not sure if this is doable or not, but any recommendations to achieve this?

0 likes
0 replies

Please or to participate in this conversation.