Skip to main content
Solved

Importing a class(sample.ts) in code.ts throws error

  • December 5, 2022
  • 2 replies
  • 810 views

Anand_Kumar

Recently started to learn Figma Plugin where I could not figure not how to import a sample.ts file in code.ts

example: I had created a file called sample.ts which contains a function

export function testing() { return 'ABC'; }

Adding the following code in code.ts

import { testing } from './sample' console.log(testing())

I see following error in the console
Syntax error on line 80: Unexpected token import { testing } from './sample';

Best answer by Gleb

You need to compile the code to a single file instead of keeping them as separate modules.

View original

2 replies

Gleb
  • Power Member
  • 4706 replies
  • Answer
  • December 5, 2022

You need to compile the code to a single file instead of keeping them as separate modules.


Anand_Kumar

@Gleb Thank for the response.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings