philkunz
philkunz

Reputation: 461

TypeScript import export behaviour of modules

I'm currently bundling typings d.ts files with my modules, and I came across this weird behaviour:

import * as validator from "./ZipCodeValidator" // works  
export * from "./ZipCodeValidator"; // works  
export import validator = require("./ZipCodeValidator"); // works  
export * as validator from "./ZipCodeValidator"; // does not work

Why does line 4 not show the same behaviour as line 3?

Upvotes: 0

Views: 52

Answers (1)

basarat
basarat

Reputation: 275799

export * as validator from "./ZipCodeValidator"; // does not work

It does not work because it is not valid ES6 syntax. The import * / export * are valid es6 syntaxes. The closes you can get with ES6 style module is:

import * as _validator from "./ZipCodeValidator" // works  
export validator = _validator;

Upvotes: 1

Related Questions