Merge pull request #16524 from overleaf/em-fix-typescript-backend

Fix typescript config in the backend

GitOrigin-RevId: fb292968bc14da6d7c17bee1da00803a74901899
This commit is contained in:
Eric Mc Sween
2024-01-17 09:03:42 +00:00
committed by Copybot
parent 5f336d0494
commit a2e4480396
50 changed files with 324 additions and 180 deletions
-83
View File
@@ -1,83 +0,0 @@
export = OError;
/**
* Light-weight helpers for handling JavaScript Errors in node.js and the
* browser.
*/
declare class OError extends Error {
/**
* @param {string} message as for built-in Error
* @param {Object} [info] extra data to attach to the error
* @param {Error} [cause] the internal error that caused this error
*/
constructor(message: string, info?: any, cause?: Error);
info: any;
cause: Error;
/** @private @type {Array<TaggedError> | undefined} */
private _oErrorTags;
/**
* Set the extra info object for this error.
*
* @param {Object} info extra data to attach to the error
* @return {this}
*/
withInfo(info: any): OError;
/**
* Wrap the given error, which caused this error.
*
* @param {Error} cause the internal error that caused this error
* @return {this}
*/
withCause(cause: Error): OError;
}
declare namespace OError {
/**
* Tag debugging information onto any error (whether an OError or not) and
* return it.
*
* @example <caption>An error in a callback</caption>
* function findUser(name, callback) {
* fs.readFile('/etc/passwd', (err, data) => {
* if (err) return callback(OError.tag(err, 'failed to read passwd'))
* // ...
* })
* }
*
* @example <caption>A possible error in a callback</caption>
* function cleanup(callback) {
* fs.unlink('/tmp/scratch', (err) => callback(err && OError.tag(err)))
* }
*
* @example <caption>An error with async/await</caption>
* async function cleanup() {
* try {
* await fs.promises.unlink('/tmp/scratch')
* } catch (err) {
* throw OError.tag(err, 'failed to remove scratch file')
* }
* }
*
* @param {Error} error the error to tag
* @param {string} [message] message with which to tag `error`
* @param {Object} [info] extra data with wich to tag `error`
* @return {Error} the modified `error` argument
*/
export function tag(error: Error, message?: string, info?: any): Error;
/**
* The merged info from any `tag`s and causes on the given error.
*
* If an info property is repeated, the last one wins.
*
* @param {Error | null | undefined} error any error (may or may not be an `OError`)
* @return {Object}
*/
export function getFullInfo(error: Error): any;
/**
* Return the `stack` property from `error`, including the `stack`s for any
* tagged errors added with `OError.tag` and for any `cause`s.
*
* @param {Error | null | undefined} error any error (may or may not be an `OError`)
* @return {string}
*/
export function getFullStack(error: Error): string;
export const maxTags: Number;
}
+6 -8
View File
@@ -13,26 +13,24 @@
"verror"
],
"main": "index.cjs",
"types": "types/index.cjs",
"types": "types/index.d.cts",
"files": [
"index.cjs",
"index.d.ts"
],
"scripts": {
"build": "npm run --silent typecheck && npm run --silent test && npm run --silent declaration:build && npm run --silent update-readme",
"declaration:build": "rm -f index.d.ts && tsc --allowJs --declaration --emitDeclarationOnly --moduleResolution node --target ES6 index.js",
"declaration:check": "git diff --exit-code -- index.d.ts",
"build": "npm run --silent test && npm run --silent update-readme",
"lint": "eslint --ext .js --ext .cjs --max-warnings 0 --format unix .",
"lint:fix": "eslint --fix --ext .js --ext .cjs .",
"prepublishOnly": "npm run --silent declaration:build && npm run --silent declaration:check",
"test": "npm run lint && npm run format && npm run typecheck && npm run test:unit",
"typecheck": "tsc --noEmit",
"test": "npm run lint && npm run format && npm run types:check && npm run test:unit",
"update-readme": "doc/update-readme.js",
"format": "prettier --list-different $PWD/'**/*.{js,cjs}'",
"format:fix": "prettier --write $PWD/'**/*.{js,cjs}'",
"test:ci": "npm run test:unit",
"test:unit": "mocha --exit test/**/*.{js,cjs}",
"update-types": "rm -rf types && tsc --emitDeclarationOnly"
"types:build": "[ -d types ] || tsc --emitDeclarationOnly",
"types:check": "tsc --noEmit",
"types:rebuild": "rm -rf types && npm run types:build"
},
"author": "Overleaf (https://www.overleaf.com)",
"license": "MIT",
+4
View File
@@ -1,5 +1,9 @@
{
"extends": "../../tsconfig.backend.json",
"compilerOptions": {
"declaration": true,
"outDir": "types"
},
"include": [
"**/*.js",
"**/*.cjs"