Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot find name 'exports' error in typescript

Tags:

I have a typescript file like below,

Environment.ts

var Environment = "DEV"
exports.Environment = Environment;

And I am using it in my app.config file like below,

var execEnv = require('./src/execEnvironment.ts');

which gives me the error

cannot find name 'exports'.

What am I doing wrong?

like image 654
Vinay Avatar asked Sep 20 '17 06:09

Vinay


1 Answers

Use "standarized" ES6 style exports which are supported by Typescript

environment.ts

export const Environment = "DEV"

app.config.ts

import {Environment} from './environment'  // <= no .ts at the end

You can even rename on import

import {Environment as execEnv} from './environment'
like image 83
Bruno Grieder Avatar answered Sep 29 '22 23:09

Bruno Grieder