3

screen shot of error

When I move my mouse over the red. it says:

Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from "mod"', 'import {a} from "mod"' or 'import d from "mod"' instead.

Like I said it compiles and runs just fine. It's just REALLY annoying having that constantly there?

I am brand new to node.js and typescript. But not brand new to programming, I'v been a C# developer for a long time.

2 Answers 2

2

I found the answer. I should have just done what it told me to do :)

I replaced

import http = require("http");

with

import * as http from "http"

no more complaining and it all compiles.

I followed the same pattern for the rest of the requires that I had.

Sign up to request clarification or add additional context in comments.

1 Comment

Yeah these ES6 imports really are powerful. I don't write any "require"s since they are available. And I'm looking forward to use them natively.
1

Import assignment cannot be used when targeting ECMAScript 6 or higher

Open you tsconfig.json and add the following (replacing an existing value if already present... and merging with existing data accordingly):

{
    "compilerOptions" :{
        "target": "es5"
    } 
}

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.