Skip to content

Update return types of APIs#15887

Merged
mhegazy merged 2 commits into
microsoft:masterfrom
ajafff:update-types
May 16, 2017
Merged

Update return types of APIs#15887
mhegazy merged 2 commits into
microsoft:masterfrom
ajafff:update-types

Conversation

@ajafff

@ajafff ajafff commented May 16, 2017

Copy link
Copy Markdown
Contributor

This PR updates some return types to include undefined. That helps documenting the API and prevents bugs when using strictNullChecks

Fixes #15841

@mhegazy mhegazy merged commit 5fb77a0 into microsoft:master May 16, 2017
Comment thread src/compiler/parser.ts
// 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 {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The callbacks should also return T | undefined.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants