error TS2403: Subsequent variable declarations must have the same type
<h1>Error</h1>
<p>I'm getting this typescript error:</p>
<blockquote>
<p>error TS2403: Subsequent variable declarations must have the same type.  Variable 'environment' must be of type 'string', but here has type 'any'.</p>
</blockquote>
<h1>Code</h1>
<h2>package.json</h2>
<pre><code>...
&quot;typescript&quot;: &quot;^1.8.10&quot;,
...
</code></pre>
<h2>server.ts</h2>
<pre><code>var environment = require('./config/config.js')()
</code></pre>
<h2>./config/config.ts</h2>
<pre><code>module.exports = function(): string {
  //Environment
  let env:string = process.env.NODE_ENV || 'development'
  return env
}
</code></pre>
<h1>Question:</h1>
<p>What do I need to do, to get the return value of the function recognized as a <code>string</code>?</p>
<h1>Edit</h1>
<h2>tsconfig</h2>
<pre><code>{
  &quot;compilerOptions&quot;: {
    &quot;target&quot;: &quot;ES5&quot;,
    &quot;module&quot;: &quot;system&quot;,
    &quot;sourceMap&quot;: true,
    &quot;emitDecoratorMetadata&quot;: true,
    &quot;experimentalDecorators&quot;: true,
    &quot;moduleResolution&quot;: &quot;node&quot;,
    &quot;removeComments&quot;: false,
    &quot;noImplicitAny&quot;: true,
    &quot;suppressImplicitAnyIndexErrors&quot;: true
  },
  &quot;exclude&quot;: [
    &quot;node_modules&quot;,
    &quot;typings/main&quot;,
    &quot;typings/main.d.ts&quot;
  ]
}
</code></pre>
<h2>Installation of node</h2>
<p>I added a <code>typings.json</code> with</p>
<pre><code>{
  &quot;globalDependencies&quot;: {
    &quot;core-js&quot;: &quot;registry:dt/core-js#0.0.0+20160602141332&quot;,
    &quot;jasmine&quot;: &quot;registry:dt/jasmine#2.2.0+20160621224255&quot;,
    &quot;node&quot;: &quot;registry:dt/node#6.0.0+20160621231320&quot;
  }
}
</code></pre>
<p>And as I remember uses <code>tsd install</code>. I have a folder called <code>typings</code>, In that folder is another folder called <code>node</code> with an <code>index.d.ts</code>. I assume this is the same as a <code>node.d.ts</code>?</p>
<h1>Edit 2</h1>
<h2>gulp for frontend (angularjs) and backend (nodejs)</h2>
<pre><code>const gulp = require('gulp');
const gutil = require('gulp-util');
const paths = gulp.paths;
var $ = require('gulp-load-plugins')();

const tscConfig = require('../tsconfig.json');

gulp.task('scripts-frontend', function () {
  gulp.src(paths.src + '/systemjs.config.js')
   .pipe(gulp.dest(paths.out + '/'));

  return gulp.src([paths.src + '/frontend/**/*.ts', paths.typings + '/**/*', '!' + paths.src + '/**/*.spec.ts'])
    .pipe($.sourcemaps.init())
    .pipe($.typescript(tscConfig.compilerOptions))
    .pipe($.sourcemaps.write('.'))
    .pipe(gulp.dest(paths.out + '/frontend/'));
});

gulp.task('scripts-backend', function () {
  return gulp.src([paths.src + '/backend/**/*.ts', paths.typings + '/**/*', paths.src + '/server.ts', '!' + paths.src + '/**/*.spec.ts'])
    .pipe($.sourcemaps.init())
    .pipe($.typescript(tscConfig.compilerOptions))
    .pipe($.sourcemaps.write('.'))
    .pipe(gulp.dest(paths.out + '/backend/'));
});
</code></pre>