-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Add semicolon preference to formatter options #33402
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
df151ac
7cca9f4
461e6ad
0d96d40
7cae3cd
e27bc96
ae9a234
0ac2807
4027433
149eaf6
4555bb8
ac30127
ca8b8f0
9c33590
d5d23a2
5743d76
d36155f
047b55f
9bd7d54
2c1eef2
4675779
5625cb0
525e32e
498a320
68cf56d
623b4b3
61c3e61
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -329,6 +329,21 @@ namespace ts { | |
return undefined; | ||
} | ||
|
||
/** | ||
* Like `forEach`, but iterates in reverse order. | ||
*/ | ||
export function forEachRight<T, U>(array: readonly T[] | undefined, callback: (element: T, index: number) => U | undefined): U | undefined { | ||
if (array) { | ||
for (let i = array.length - 1; i >= 0; i--) { | ||
const result = callback(array[i], i); | ||
if (result) { | ||
return result; | ||
} | ||
} | ||
} | ||
return undefined; | ||
} | ||
|
||
/** Like `forEach`, but suitable for use with numbers and strings (which may be falsy). */ | ||
export function firstDefined<T, U>(array: readonly T[] | undefined, callback: (element: T, index: number) => U | undefined): U | undefined { | ||
if (array === undefined) { | ||
|
@@ -2159,8 +2174,19 @@ namespace ts { | |
return (arg: T) => f(arg) && g(arg); | ||
} | ||
|
||
export function or<T>(f: (arg: T) => boolean, g: (arg: T) => boolean): (arg: T) => boolean { | ||
return arg => f(arg) || g(arg); | ||
export function or<T extends unknown>(...fs: ((arg: T) => boolean)[]): (arg: T) => boolean { | ||
return arg => { | ||
for (const f of fs) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How do you choose between for-of, for-increment, and There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My personal tendencies:
const firstMatchingSignature = forEach(types, type => {
return firstDefined(type.getCallSignatures(), somePredicateThing);
});
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, that would work. I think I also have a tendency to implement abstractions with building blocks that are less abstract than the function I’m implementing, if that makes sense. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess, in my mind, if |
||
if (f(arg)) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
}; | ||
} | ||
|
||
export function not<T extends unknown[]>(fn: (...args: T) => boolean): (...args: T) => boolean { | ||
return (...args) => !fn(...args); | ||
} | ||
|
||
export function assertType<T>(_: T): void { } | ||
|
Uh oh!
There was an error while loading. Please reload this page.