How to import library with TypeScript Playground

0 votes

TypeScript Playground does not seem to work the right way with this import:

import * as _ from "underscore";

until you try to use it, like:

const equalResult = _.isEqual('ABC', '123');

Then, it generates the error:

[ERR]: Executed JavaScript Failed:
[ERR]: Cannot use import statement outside a module

The playground seems to understand the library because it gives JSDoc, so I'm thinking that this can work, but how?

Jun 13 in TypeSript by Logan
• 2,140 points
60 views

1 answer to this question.

0 votes

TypeScript Playground isn't a fully fledged sandbox solution. It's merely meant as a simple type explorer that doesn't need dependencies.

For your use case I would recommend using CodeSandbox instead. It comes with a whole bunch of TypeScript templates to choose from when creating a sandbox. TypeScript Playground also has an export menu where you can open your code in CodeSandbox directly.

CodeSandbox export

The UI is based off of VS Code, so if you're used to that you will feel just at home.

answered Jun 13 by Nina
• 3,020 points

Related Questions In TypeSript

0 votes
1 answer

How to use useState hook in React with TypeScript correctly?

Without any initial argument, the type of email and setEmail will ...READ MORE

answered Jun 10 in TypeSript by Nina
• 3,020 points
41 views
0 votes
1 answer

How to use useState hook in React with typescript correctly?

You can set a string type for it Explicit way: const ...READ MORE

answered 4 days ago in TypeSript by Abhinaya
• 760 points
8 views
0 votes
1 answer

How to create ES6 Map in Typescript

Refer this as an example this.configs = new ...READ MORE

answered May 31 in TypeSript by Nina
• 3,020 points
22 views
0 votes
1 answer

How to declare and initialize a Dictionary in Typescript

Apparently this doesn't work when passing the ...READ MORE

answered May 31 in TypeSript by Nina
• 3,020 points
177 views
0 votes
1 answer

How to read local csv file in JavaScript/TypeScript?

Here is how to use the readAsBinaryString() from the FileReader API ...READ MORE

answered Jun 9 in TypeSript by Nina
• 3,020 points
6 views
0 votes
1 answer

Cannot access web3 object with typescript and ethereum

You still need to instantiate it first. ...READ MORE

answered Sep 25, 2018 in Blockchain by slayer
• 29,310 points
1,849 views
0 votes
1 answer

Display details of importer

Yes, you can perform the same by ...READ MORE

answered Mar 15, 2019 in Python by SDeb
• 13,300 points
109 views
0 votes
1 answer

Can't import tkinter

You can Try this code to import ...READ MORE

answered May 21, 2019 in Python by SDeb
• 13,300 points
807 views
0 votes
1 answer

How to use moment.js library in angular 2 typescript app?

REFERENCE: https://momentjs.com/docs/#/use-it/typescript/ You can install this by using: npm install ...READ MORE

answered Jun 1 in TypeSript by Nina
• 3,020 points
51 views
0 votes
1 answer

how to use spread syntax and new Set() with TypeScript

The ... operator should work on anything ...READ MORE

answered Jun 10 in TypeSript by Nina
• 3,020 points
10 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP