Merge pull request #18167 from overleaf/em-simpler-typescript-backend

Simpler Typescript setup in the backend

GitOrigin-RevId: 3a90f26a5ac8029d14203faa98008375ce933e7d
This commit is contained in:
Eric Mc Sween 2024-05-06 07:57:39 -04:00 committed by Copybot
parent 5da8662fa8
commit e87df4a791
43 changed files with 63 additions and 155 deletions

View file

@ -3,7 +3,6 @@
"version": "3.0.0",
"description": "",
"main": "index.js",
"types": "./types/index.d.ts",
"scripts": {
"test": "npm run lint && npm run format && npm run types:check && npm run test:unit",
"lint": "eslint --ext .js --ext .cjs --max-warnings 0 --format unix .",
@ -12,9 +11,7 @@
"format:fix": "prettier --write $PWD/'**/*.{js,cjs}'",
"test:ci": "npm run test:unit",
"test:unit": "mocha --exit test/**/*.{js,cjs}",
"types:build": "[ -d types ] || tsc --noEmit false --emitDeclarationOnly",
"types:check": "tsc --noEmit",
"types:rebuild": "rm -rf types && npm run types:build"
"types:check": "tsc --noEmit"
},
"author": "",
"license": "AGPL-3.0-only",

View file

@ -1,9 +1,5 @@
{
"extends": "../../tsconfig.backend.json",
"compilerOptions": {
"declaration": true,
"outDir": "types"
},
"include": [
"**/*.js",
"**/*.cjs"

View file

@ -3,7 +3,6 @@
"version": "0.1.0",
"description": "utilities for node-fetch",
"main": "index.js",
"types": "types/index.d.ts",
"scripts": {
"test": "npm run lint && npm run format && npm run types:check && npm run test:unit",
"lint": "eslint --ext .js --ext .cjs --max-warnings 0 --format unix .",
@ -12,9 +11,7 @@
"format:fix": "prettier --write $PWD/'**/*.{js,cjs}'",
"test:ci": "npm run test:unit",
"test:unit": "mocha --exit test/**/*.{js,cjs}",
"types:build": "[ -d types ] || tsc --noEmit false --emitDeclarationOnly",
"types:check": "tsc --noEmit",
"types:rebuild": "rm -rf types && npm run types:build"
"types:check": "tsc --noEmit"
},
"author": "Overleaf (https://www.overleaf.com)",
"license": "AGPL-3.0-only",

View file

@ -1,9 +1,5 @@
{
"extends": "../../tsconfig.backend.json",
"compilerOptions": {
"declaration": true,
"outDir": "types"
},
"include": [
"**/*.js",
"**/*.cjs"

View file

@ -7,7 +7,6 @@
"url": "https://github.com/overleaf/overleaf"
},
"main": "index.js",
"types": "types/index.d.ts",
"license": "AGPL-3.0-only",
"version": "3.1.1",
"scripts": {
@ -18,9 +17,7 @@
"lint:fix": "eslint --fix --ext .js --ext .cjs .",
"test:ci": "npm run test:unit",
"test:unit": "mocha --exit test/**/*.{js,cjs}",
"types:build": "[ -d types ] || tsc --noEmit false --emitDeclarationOnly",
"types:check": "tsc --noEmit",
"types:rebuild": "rm -rf types && npm run types:build"
"types:check": "tsc --noEmit"
},
"dependencies": {
"@google-cloud/logging-bunyan": "^5.0.0",

View file

@ -1,9 +1,5 @@
{
"extends": "../../tsconfig.backend.json",
"compilerOptions": {
"declaration": true,
"outDir": "types"
},
"include": [
"**/*.js",
"**/*.cjs"

View file

@ -7,7 +7,6 @@
"url": "https://github.com/overleaf/metrics-module.git"
},
"main": "index.js",
"types": "types/index.d.ts",
"dependencies": {
"@google-cloud/opentelemetry-cloud-trace-exporter": "^2.1.0",
"@google-cloud/profiler": "^6.0.0",
@ -38,9 +37,7 @@
"format": "prettier --list-different $PWD/'**/*.{js,cjs}'",
"format:fix": "prettier --write $PWD/'**/*.{js,cjs}'",
"test:ci": "npm run test:unit",
"types:build": "[ -d types ] || tsc --noEmit false --emitDeclarationOnly",
"types:check": "tsc --noEmit",
"types:rebuild": "rm -rf types && npm run types:build"
"types:check": "tsc --noEmit"
},
"peerDependencies": {
"@overleaf/logger": "*"

View file

@ -1,9 +1,5 @@
{
"extends": "../../tsconfig.backend.json",
"compilerOptions": {
"declaration": true,
"outDir": "types"
},
"include": [
"**/*.js",
"**/*.cjs"

View file

@ -13,10 +13,8 @@
"verror"
],
"main": "index.cjs",
"types": "types/index.d.cts",
"files": [
"index.cjs",
"types/index.d.cts"
"index.cjs"
],
"scripts": {
"build": "npm run --silent test",
@ -27,9 +25,7 @@
"format:fix": "prettier --write $PWD/'**/*.{js,cjs}'",
"test:ci": "npm run test:unit",
"test:unit": "mocha --exit test/**/*.{js,cjs}",
"types:build": "[ -d types ] || tsc --noEmit false --emitDeclarationOnly",
"types:check": "tsc --noEmit",
"types:rebuild": "rm -rf types && npm run types:build"
"types:check": "tsc --noEmit"
},
"author": "Overleaf (https://www.overleaf.com)",
"license": "MIT",

View file

@ -1,9 +1,5 @@
{
"extends": "../../tsconfig.backend.json",
"compilerOptions": {
"declaration": true,
"outDir": "types"
},
"include": [
"**/*.js",
"**/*.cjs"

View file

@ -3,7 +3,6 @@
"version": "1.0.2",
"description": "Module for storing objects in multiple backends, with fallback on 404 to assist migration between them",
"main": "index.js",
"types": "types/index.d.ts",
"scripts": {
"test": "npm run lint && npm run format && npm run types:check && npm run test:unit",
"test:unit": "mocha --exit test/**/*.{js,cjs}",
@ -12,9 +11,7 @@
"format": "prettier --list-different $PWD/'**/*.{js,cjs}'",
"format:fix": "prettier --write $PWD/'**/*.{js,cjs}'",
"test:ci": "npm run test:unit",
"types:build": "[ -d types ] || tsc --noEmit false --emitDeclarationOnly",
"types:check": "tsc --noEmit",
"types:rebuild": "rm -rf types && npm run types:build"
"types:check": "tsc --noEmit"
},
"repository": {
"type": "git",

View file

@ -1,9 +1,5 @@
{
"extends": "../../tsconfig.backend.json",
"compilerOptions": {
"declaration": true,
"outDir": "types"
},
"include": [
"**/*.js",
"**/*.cjs"

View file

@ -3,7 +3,6 @@
"version": "1.0.0",
"description": "Library shared between the editor server and clients.",
"main": "index.js",
"types": "types/index.d.ts",
"scripts": {
"test": "npm run lint && npm run format && npm run types:check && npm run test:unit",
"format": "prettier --list-different $PWD/'**/*.{js,cjs}'",
@ -12,9 +11,7 @@
"lint:fix": "eslint --fix --ext .js --ext .cjs .",
"test:ci": "npm run test:unit",
"test:unit": "mocha --exit test/**/*.{js,cjs}",
"types:build": "[ -d types ] || tsc --noEmit false --emitDeclarationOnly",
"types:check": "tsc --noEmit",
"types:rebuild": "rm -rf types && npm run types:build"
"types:check": "tsc --noEmit"
},
"author": "team@overleaf.com",
"license": "Proprietary",

View file

@ -1,9 +1,5 @@
{
"extends": "../../tsconfig.backend.json",
"compilerOptions": {
"declaration": true,
"outDir": "types"
},
"include": [
"**/*.js",
"**/*.cjs"

View file

@ -3,7 +3,6 @@
"version": "0.1.0",
"description": "utilities to help working with promises",
"main": "index.js",
"types": "types/index.d.ts",
"scripts": {
"test": "npm run lint && npm run format && npm run types:check && npm run test:unit",
"test:unit": "mocha --exit test/**/*.{js,cjs}",
@ -12,9 +11,7 @@
"format": "prettier --list-different $PWD/'**/*.{js,cjs}'",
"format:fix": "prettier --write $PWD/'**/*.{js,cjs}'",
"test:ci": "npm run test:unit",
"types:build": "[ -d types ] || tsc --noEmit false --emitDeclarationOnly",
"types:check": "tsc --noEmit",
"types:rebuild": "rm -rf types && npm run types:build"
"types:check": "tsc --noEmit"
},
"author": "Overleaf (https://www.overleaf.com)",
"license": "AGPL-3.0-only",

View file

@ -1,9 +1,5 @@
{
"extends": "../../tsconfig.backend.json",
"compilerOptions": {
"declaration": true,
"outDir": "types"
},
"include": [
"**/*.js",
"**/*.cjs"

View file

@ -1,4 +1,3 @@
// @ts-check
/**
* The purpose of this class is to track a set of inserts and deletes to a document, like
* track changes in Word. We store these as a set of ShareJs style ranges:

View file

@ -2,7 +2,6 @@
"name": "@overleaf/ranges-tracker",
"description": "Shared logic for syncing comments and tracked changes with operational transforms",
"main": "index.cjs",
"types": "types/index.d.cts",
"files": [
"index.cjs",
"types"
@ -17,9 +16,7 @@
"test": "npm run lint && npm run format && npm run types:check && npm run test:unit",
"test:ci": "npm run test:unit",
"test:unit": "mocha --exit test/**/*.{js,cjs}",
"types:build": "[ -d types ] || tsc --noEmit false --emitDeclarationOnly",
"types:check": "tsc --noEmit",
"types:rebuild": "rm -rf types && npm run types:build"
"types:check": "tsc --noEmit"
},
"devDependencies": {
"mocha": "^10.2.0",

View file

@ -1,9 +1,5 @@
{
"extends": "../../tsconfig.backend.json",
"compilerOptions": {
"declaration": true,
"outDir": "types"
},
"include": [
"**/*.js",
"**/*.cjs"

View file

@ -96,6 +96,9 @@ module.exports = class RedisLocker {
return `locked:host=${HOST}:pid=${PID}:random=${RND}:time=${time}:count=${COUNT++}`
}
/**
* @param {Callback} callback
*/
tryLock(id, callback) {
if (callback == null) {
callback = function () {}
@ -135,6 +138,9 @@ module.exports = class RedisLocker {
)
}
/**
* @param {Callback} callback
*/
getLock(id, callback) {
if (callback == null) {
callback = function () {}
@ -166,6 +172,9 @@ module.exports = class RedisLocker {
attempt()
}
/**
* @param {Callback} callback
*/
checkLock(id, callback) {
if (callback == null) {
callback = function () {}
@ -186,6 +195,9 @@ module.exports = class RedisLocker {
})
}
/**
* @param {Callback} callback
*/
releaseLock(id, lockValue, callback) {
const key = this.getKey(id)
return this.rclient.eval(

View file

@ -3,7 +3,6 @@
"version": "2.1.0",
"description": "Redis wrapper for node which will either use cluster or single instance redis",
"main": "index.js",
"types": "types/index.d.ts",
"files": [
"index.js",
"Errors.js",
@ -21,9 +20,7 @@
"test": "npm run lint && npm run format && npm run types:check && npm run test:unit",
"test:ci": "npm run test:unit",
"test:unit": "mocha --exit test/**/*.{js,cjs}",
"types:build": "[ -d types ] || tsc --noEmit false --emitDeclarationOnly",
"types:check": "tsc --noEmit",
"types:rebuild": "rm -rf types && npm run types:build"
"types:check": "tsc --noEmit"
},
"peerDependencies": {
"@overleaf/logger": "*",

View file

@ -1,9 +1,5 @@
{
"extends": "../../tsconfig.backend.json",
"compilerOptions": {
"declaration": true,
"outDir": "types"
},
"include": [
"**/*.js",
"**/*.cjs"

View file

@ -4,7 +4,6 @@
"version": "3.0.0",
"repository": "overleaf/settings-module",
"main": "index.js",
"types": "types/index.d.ts",
"scripts": {
"lint": "eslint --ext .js --ext .cjs --max-warnings 0 --format unix .",
"lint:fix": "eslint --fix --ext .js --ext .cjs .",
@ -13,9 +12,7 @@
"test": "npm run lint && npm run format && npm run types:check && npm run test:unit",
"test:ci": "npm run test:unit",
"test:unit": "mocha --exit test/**/*.{js,cjs}",
"types:build": "[ -d types ] || tsc --noEmit false --emitDeclarationOnly",
"types:check": "tsc --noEmit",
"types:rebuild": "rm -rf types && npm run types:build"
"types:check": "tsc --noEmit"
},
"devDependencies": {
"mocha": "^10.2.0",

View file

@ -1,9 +1,5 @@
{
"extends": "../../tsconfig.backend.json",
"compilerOptions": {
"declaration": true,
"outDir": "types"
},
"include": [
"**/*.js",
"**/*.cjs"

View file

@ -3,7 +3,6 @@
"version": "0.1.0",
"description": "stream handling utilities",
"main": "index.js",
"types": "types/index.d.ts",
"scripts": {
"test": "npm run lint && npm run format && npm run types:check && npm run test:unit",
"test:unit": "mocha --exit test/**/*.{js,cjs}",
@ -12,9 +11,7 @@
"format": "prettier --list-different $PWD/'**/*.{js,cjs}'",
"format:fix": "prettier --write $PWD/'**/*.{js,cjs}'",
"test:ci": "npm run test:unit",
"types:build": "[ -d types ] || tsc --noEmit false --emitDeclarationOnly",
"types:check": "tsc --noEmit",
"types:rebuild": "rm -rf types && npm run types:build"
"types:check": "tsc --noEmit"
},
"author": "Overleaf (https://www.overleaf.com)",
"license": "AGPL-3.0-only",

View file

@ -1,9 +1,5 @@
{
"extends": "../../tsconfig.backend.json",
"compilerOptions": {
"declaration": true,
"outDir": "types"
},
"include": [
"**/*.js",
"**/*.cjs"

12
package-lock.json generated
View file

@ -38926,9 +38926,9 @@
"integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c="
},
"node_modules/typescript": {
"version": "5.2.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz",
"integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==",
"version": "5.4.5",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.5.tgz",
"integrity": "sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==",
"dev": true,
"bin": {
"tsc": "bin/tsc",
@ -77933,9 +77933,9 @@
"integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c="
},
"typescript": {
"version": "5.2.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz",
"integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==",
"version": "5.4.5",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.5.tgz",
"integrity": "sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==",
"dev": true
},
"typical": {

View file

@ -48,10 +48,7 @@ lint:
lint_fix:
$(RUN_LINTING) lint:fix
build_types:
$(RUN_LINTING_MONOREPO) --workspaces --if-present types:build
typecheck: build_types
typecheck:
$(RUN_LINTING) types:check
test: format lint typecheck test_unit test_acceptance

View file

@ -48,10 +48,7 @@ lint:
lint_fix:
$(RUN_LINTING) lint:fix
build_types:
$(RUN_LINTING_MONOREPO) --workspaces --if-present types:build
typecheck: build_types
typecheck:
$(RUN_LINTING) types:check
test: format lint typecheck test_unit test_acceptance

View file

@ -48,10 +48,7 @@ lint:
lint_fix:
$(RUN_LINTING) lint:fix
build_types:
$(RUN_LINTING_MONOREPO) --workspaces --if-present types:build
typecheck: build_types
typecheck:
$(RUN_LINTING) types:check
test: format lint typecheck test_unit test_acceptance

View file

@ -48,10 +48,7 @@ lint:
lint_fix:
$(RUN_LINTING) lint:fix
build_types:
$(RUN_LINTING_MONOREPO) --workspaces --if-present types:build
typecheck: build_types
typecheck:
$(RUN_LINTING) types:check
test: format lint typecheck test_unit test_acceptance

View file

@ -48,10 +48,7 @@ lint:
lint_fix:
$(RUN_LINTING) lint:fix
build_types:
$(RUN_LINTING_MONOREPO) --workspaces --if-present types:build
typecheck: build_types
typecheck:
$(RUN_LINTING) types:check
test: format lint typecheck test_unit test_acceptance

View file

@ -1,4 +1,4 @@
import { TrackingPropsRawData } from 'overleaf-editor-core/types/lib/types'
import { TrackingPropsRawData } from 'overleaf-editor-core/lib/types'
/**
* An update coming from the editor

View file

@ -48,10 +48,7 @@ lint:
lint_fix:
$(RUN_LINTING) lint:fix
build_types:
$(RUN_LINTING_MONOREPO) --workspaces --if-present types:build
typecheck: build_types
typecheck:
$(RUN_LINTING) types:check
test: format lint typecheck test_unit test_acceptance

View file

@ -48,10 +48,7 @@ lint:
lint_fix:
$(RUN_LINTING) lint:fix
build_types:
$(RUN_LINTING_MONOREPO) --workspaces --if-present types:build
typecheck: build_types
typecheck:
$(RUN_LINTING) types:check
test: format lint typecheck test_unit test_acceptance

View file

@ -1,7 +1,7 @@
// @ts-check
'use strict'
/** @typedef {import('overleaf-editor-core/types').Snapshot} Snapshot */
/** @typedef {import('overleaf-editor-core').Snapshot} Snapshot */
const Archive = require('archiver')
const BPromise = require('bluebird')

View file

@ -48,10 +48,7 @@ lint:
lint_fix:
$(RUN_LINTING) lint:fix
build_types:
$(RUN_LINTING_MONOREPO) --workspaces --if-present types:build
typecheck: build_types
typecheck:
$(RUN_LINTING) types:check
test: format lint typecheck test_unit test_acceptance

View file

@ -48,10 +48,7 @@ lint:
lint_fix:
$(RUN_LINTING) lint:fix
build_types:
$(RUN_LINTING_MONOREPO) --workspaces --if-present types:build
typecheck: build_types
typecheck:
$(RUN_LINTING) types:check
test: format lint typecheck test_unit test_acceptance

View file

@ -48,10 +48,7 @@ lint:
lint_fix:
$(RUN_LINTING) lint:fix
build_types:
$(RUN_LINTING_MONOREPO) --workspaces --if-present types:build
typecheck: build_types
typecheck:
$(RUN_LINTING) types:check
test: format lint typecheck test_unit test_acceptance

View file

@ -48,10 +48,7 @@ lint:
lint_fix:
$(RUN_LINTING) lint:fix
build_types:
$(RUN_LINTING_MONOREPO) --workspaces --if-present types:build
typecheck: build_types
typecheck:
$(RUN_LINTING) types:check
test: format lint typecheck test_unit test_acceptance

View file

@ -35,9 +35,7 @@ FROM deps-prod as deps
ENV CYPRESS_INSTALL_BINARY=0
COPY tsconfig.backend.json /overleaf/
RUN cd /overleaf \
&& npm install \
&& npm run --workspaces --if-present types:build
RUN cd /overleaf && npm install
# the web image with only production dependencies but no webpack production build, for development
FROM deps-prod as app-only

View file

@ -12,7 +12,9 @@
"skipLibCheck": true /* Skip type checking of declaration files. */,
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */,
"paths": {
"@/*": ["./frontend/js/*"]
"@/*": ["./frontend/js/*"],
"@overleaf/o-error": ["../../libraries/o-error"],
"@overleaf/ranges-tracker": ["../../libraries/ranges-tracker"]
},
"types": ["cypress", "@testing-library/cypress"]
},

View file

@ -5,6 +5,21 @@
"moduleResolution": "node",
"noEmit": true,
"noImplicitAny": false,
"paths": {
"@overleaf/access-token-encryptor": ["./libraries/access-token-encryptor"],
"@overleaf/fetch-utils": ["./libraries/fetch-utils"],
"@overleaf/logger": ["./libraries/logger"],
"@overleaf/metrics": ["./libraries/metrics"],
"@overleaf/object-persistor": ["./libraries/object-persistor"],
"@overleaf/o-error": ["./libraries/o-error"],
"overleaf-editor-core": ["./libraries/overleaf-editor-core"],
"@overleaf/piece-table": ["./libraries/piece-table"],
"@overleaf/promise-utils": ["./libraries/promise-utils"],
"@overleaf/ranges-tracker": ["./libraries/ranges-tracker"],
"@overleaf/redis-wrapper": ["./libraries/redis-wrapper"],
"@overleaf/settings": ["./libraries/settings"],
"@overleaf/stream-utils": ["./libraries/stream-utils"]
},
"skipLibCheck": true,
"strict": true,
"target": "ES2022"