TypeScript Version: 2.3.4
Code
// foo.ts
console.log(BAR);
import {BAR} from './bar';
// bar.ts
export const BAR = 'bar';
// tsconfig.json
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"strict": true
}
}
Expected behavior:
TypeScript should reject foo.ts, because it is referring to BAR before it is initialized.
Actual behavior:
tsc raises no errors, and generates the following foo.js file:
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
console.log(bar_1.BAR);
var bar_1 = require("./bar");
This fails at runtime with a TypeError.
TypeScript Version: 2.3.4
Code
Expected behavior:
TypeScript should reject
foo.ts, because it is referring toBARbefore it is initialized.Actual behavior:
tscraises no errors, and generates the followingfoo.jsfile:This fails at runtime with a
TypeError.