Nov 18, 2022
0
Level 4
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?
Please or to participate in this conversation.