Update return types of APIs (#15887)

* Update types.ts

* Update types in parser.ts and scanner.ts
This commit is contained in:
Klaus Meinhardt
2017-05-16 23:13:58 +02:00
committed by Mohamed Hegazy
parent 8ceaa33943
commit 5fb77a0901
3 changed files with 26 additions and 25 deletions

View File

@@ -23,19 +23,19 @@ namespace ts {
}
}
function visitNode<T>(cbNode: (node: Node) => T, node: Node): T {
function visitNode<T>(cbNode: (node: Node) => T, node: Node): T | undefined {
if (node) {
return cbNode(node);
}
}
function visitNodeArray<T>(cbNodes: (nodes: Node[]) => T, nodes: Node[]) {
function visitNodeArray<T>(cbNodes: (nodes: Node[]) => T, nodes: Node[]): T | undefined {
if (nodes) {
return cbNodes(nodes);
}
}
function visitEachNode<T>(cbNode: (node: Node) => T, nodes: Node[]) {
function visitEachNode<T>(cbNode: (node: Node) => T, nodes: Node[]): T | undefined {
if (nodes) {
for (const node of nodes) {
const result = cbNode(node);
@@ -50,7 +50,7 @@ namespace ts {
// stored in properties. If a 'cbNodes' callback is specified, it is invoked for embedded arrays; otherwise,
// embedded arrays are flattened and the 'cbNode' callback is invoked for each element. If a callback returns
// a truthy value, iteration stops and that value is returned. Otherwise, undefined is returned.
export function forEachChild<T>(node: Node, cbNode: (node: Node) => T, cbNodeArray?: (nodes: Node[]) => T): T {
export function forEachChild<T>(node: Node, cbNode: (node: Node) => T, cbNodeArray?: (nodes: Node[]) => T): T | undefined {
if (!node) {
return;
}