-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert prefer-default and log-line-function to TS (#23677)
* chore(ts): convert log-line-function to TS * chore(ts): convert prefer-default to TS
- Loading branch information
1 parent
56f91a5
commit f4cb5b0
Showing
7 changed files
with
25 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
;[`log`, `warn`].forEach((method: string): void => { | ||
const old = console[method] | ||
|
||
console[method] = (...methodArgs: []): void => { | ||
const error: Error = new Error() | ||
let stack = error.stack ? error.stack.split(/\n/) : [] | ||
|
||
// Chrome includes a single "Error" line, FF doesn't. | ||
if (stack[0].indexOf(`Error`) === 0) { | ||
stack = stack.slice(1) | ||
} | ||
|
||
const [, trace] = stack[1] || `` | ||
const args: string[] = ([] as string[]).slice | ||
.apply(methodArgs) | ||
.concat([trace.trim()]) | ||
|
||
return old.apply(console, args) | ||
} | ||
}) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const preferDefault = (m: any): any => (m && m.default) || m |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters