Skip to content

Commit 6ebd8be

Browse files
committed
Use string literal types (TypeScript 1.8)
1 parent 43ae627 commit 6ebd8be

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/xdebugConnection.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,17 @@ export class StatusResponse extends Response {
113113
}
114114
}
115115

116+
export type BreakpointType = 'line' | 'call' | 'return' | 'exception' | 'conditional' | 'watch';
117+
export type BreakpointState = 'enabled' | 'disabled';
118+
116119
/** Abstract base class for all breakpoints */
117120
export abstract class Breakpoint {
118121
/** Unique ID which is used for modifying the breakpoint (only when received through breakpoint_list) */
119122
id: number;
120123
/** The type of the breakpoint: line, call, return, exception, conditional or watch */
121-
type: string;
124+
type: BreakpointType;
122125
/** State of the breakpoint: enabled, disabled */
123-
state: string;
126+
state: BreakpointState;
124127
/** The connection this breakpoint is set on */
125128
connection: Connection;
126129
/** dynamically detects the type of breakpoint and returns the appropiate object */
@@ -134,15 +137,15 @@ export abstract class Breakpoint {
134137
/** Constructs a breakpoint object from an XML node from a XDebug response */
135138
constructor(breakpointNode: Element, connection: Connection);
136139
/** To create a new breakpoint in derived classes */
137-
constructor(type: string);
140+
constructor(type: BreakpointType);
138141
constructor() {
139142
if (typeof arguments[0] === 'object') {
140143
// from XML
141144
const breakpointNode: Element = arguments[0];
142145
this.connection = arguments[1];
143-
this.type = breakpointNode.getAttribute('type');
146+
this.type = <BreakpointType>breakpointNode.getAttribute('type');
144147
this.id = parseInt(breakpointNode.getAttribute('id'));
145-
this.state = breakpointNode.getAttribute('state');
148+
this.state = <BreakpointState>breakpointNode.getAttribute('state');
146149
} else {
147150
this.type = arguments[0];
148151
}

0 commit comments

Comments
 (0)