Reputation: 12818
The following gets a rather cryptic TypeScript build error: Exported variable 'res' has or is using private type 'Result'
.
interface Result {
status: string;
comment: string;
}
function runTest(st: any) {
try {
} catch (err) {
console.log('Failed test task: ' + err);
console.log('Failed test task: ' + st.name);
console.log(err.stack);
var res: Result = {
status: 'bad',
comment: 'Nodejs exception: ' + err,
};
//saveTestResult(st, res);
}
};
export function what() {};
It's all ok if either:
what
What's going on here?
Upvotes: 2
Views: 3318
Reputation: 221282
You've found a bug in the compiler. You can work around it by moving the declaration of res
(this doesn't change the behavior of the code):
function runTest(st: any) {
var res: Result;
try {
} catch (err) {
console.log('Failed test task: ' + err);
console.log('Failed test task: ' + st.name);
console.log(err.stack);
res = {
status: 'bad',
comment: 'Nodejs exception: ' + err,
};
//saveTestResult(st, res);
}
};
Upvotes: 3