Skip to content

Commit 86ff612

Browse files
authored
fix: improve ts output for create logger (#8763)
## Description Typescript =< 5.2 generated better types for `log` than >= 5.3. We're on 5.5 as that has the better import syntax. Changing createLogger to use `function log()` rather than `const log = function()` outputs as before. Also updates typescript to 5.5.1 (rc) from 5.5.0 (beta). 5.2, or 5.5 with this change ``` export default log; declare const log: { (...args: any[]): void; createLogger(subName: string, subDelimiter?: string, subStyles?: string): any; createNewLogger(newName: string, newDelimiter?: string, newStyles?: string): any; levels: any; level(lvl?: "info" | "error" | "all" | "debug" | "warn" | "off"): string; history: { (): any[]; filter(fname: string): any[]; clear(): void; disable(): void; enable(): void; }; error(...args: any[]): any; warn(...args: any[]): any; debug(...args: any[]): any; }; export const createLogger: (subName: string, subDelimiter?: string, subStyles?: string) => any; //# sourceMappingURL=log.d.ts.map% ``` 5.3+, without this change ``` export default log; declare function log(...args: any[]): void; declare namespace log { } export const createLogger: (subName: string, subDelimiter?: string, subStyles?: string) => any; //# sourceMappingURL=log.d.ts.map% ``` ## Requirements Checklist - [x] Feature implemented / Bug fixed - [ ] If necessary, more likely in a feature request than a bug fix - [x] Change has been verified in an actual browser (Chrome, Firefox, IE) - [ ] Unit Tests updated or fixed - [ ] Docs/guides updated - [ ] Example created ([starter template on JSBin](https://codepen.io/gkatsev/pen/GwZegv?editors=1000#0)) - [x] Has no DOM changes which impact accessiblilty or trigger warnings (e.g. Chrome issues tab) - [x] Has no changes to JSDoc which cause `npm run docs:api` to error - [ ] Reviewed by Two Core Contributors
1 parent b58b4c5 commit 86ff612

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@
160160
"shelljs": "^0.8.5",
161161
"shx": "^0.3.2",
162162
"sinon": "^11.1.1",
163-
"typescript": "^5.5.0-beta",
163+
"typescript": "^5.5.1-rc",
164164
"uglify-js": "^3.6.0",
165165
"unified": "^7.0.2",
166166
"videojs-generate-karma-config": "^8.1.0",

src/js/utils/create-logger.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,17 +104,17 @@ export default function createLogger(name, delimiter = ':', styles = '') {
104104
* @param {...*} args
105105
* One or more messages or objects that should be logged.
106106
*/
107-
const log = function(...args) {
107+
function log(...args) {
108108
logByType('log', level, args);
109-
};
109+
}
110110

111111
// This is the logByType helper that the logging methods below use
112112
logByType = LogByTypeFactory(name, log, styles);
113113

114114
/**
115115
* Create a new subLogger which chains the old name to the new name.
116116
*
117-
* For example, doing `videojs.log.createLogger('player')` and then using that logger will log the following:
117+
* For example, doing `mylogger = videojs.log.createLogger('player')` and then using that logger will log the following:
118118
* ```js
119119
* mylogger('foo');
120120
* // > VIDEOJS: player: foo

0 commit comments

Comments
 (0)