Joy Singh
Joy Singh

Reputation: 375

typescript - What's wrong here

I'm new to TypeScript and I'm trying to import the fs package from node.js, however this syntax is wrong and I'm not sure what am I supposed to do.

import * as "fs" from "fs";

Upvotes: 0

Views: 72

Answers (1)

CertainPerformance
CertainPerformance

Reputation: 371168

What import does is it puts imported expressions into identifiers - or JavaScript variables. You need the syntax for an identifier to put the fs namespace into:

import * as fs from "fs";

Doing as "fs" doesn't work because what follows the as must be the variable name to put the namespace into, not a string.

Upvotes: 2

Related Questions