Closed
Description
TypeScript Version: 3.3.3333
Search Terms:
typescript default get when only set present
namespace Controller
{
export class MainController
{
private readonly _codeWorkflowState = new CodeWorkflowState();
private handleInterpreterWorkerMessage(e: any)
{
if(this._codeWorkflowState.hasNexToInterpret)
{
// bug? nextToInterpret accessor does not exist. No static error reported. newerCode's value is undefined (the value) at runtime.
const newerCode: string = this._codeWorkflowState.nextToInterpret;
}
}
}
class CodeWorkflowState
{
private _nextToInterpret : string | null = null;
set nextToInterpret(code: string)
{
this._nextToInterpret = code;
}
get hasNexToInterpret() : boolean
{
return this._nextToInterpret !== null;
}
}
}
Expected behavior:
Error: no 'nextToInterpret' property on class 'CodeWorkflowState'
OR
Error: default compiler supplied accessor 'nextToInterpret' has type undefined but assigning to type string.
Actual behavior:
Compiles fine. Variable of type string has value undefined at runtime.