Reputation: 1339
I'm trying to import a function in a class, and the function is located in an other file. I have types.ts with :
export castToString = () => {//implementation}
And in my file form.tsx, I want to import this function :
import {castToString } from '../types.ts'
To use this function, I call it like this :
castToString ()
But it doesn't work, an idea ? Thank you
Upvotes: 0
Views: 3459
Reputation: 249506
Remove .ts from the import statement (you will be importing the resulting JS not the TS and you should not specify the extension in either case). Also the declaration should be export const castToString = ...
Upvotes: 3