Skip to content

Commit

Permalink
chore: update tsconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
Romakita committed Sep 27, 2024
1 parent 7b648d7 commit 2fcee85
Show file tree
Hide file tree
Showing 919 changed files with 3,268 additions and 2,743 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ tools/**/dist
.db
**/keys/jwks.json
/packages/prisma/test/prisma/generated
tsconfig.*.tsbuildinfo

# Website
/docs/api
Expand Down
2 changes: 1 addition & 1 deletion docs/getting-started/snippets/base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,6 @@
"supertest": "6.0.0",
"ts-node": "9.0.0",
"tslint": "6.1.3",
"typescript": "4.9.5"
"typescript": "5.6.2"
}
}
190 changes: 162 additions & 28 deletions docs/getting-started/snippets/migrate-from-express/server.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,163 @@
const express = require("express");
const bodyParser = require("body-parser");
const compress = require("compression");
const cookieParser = require("cookie-parser");
const methodOverride = require("method-override");
const {router: productRouter} = require("./routes/products");

const app = express();
const restRouter = express.Router({mergeParams: true});

// middlewares

app
.use(cookieParser())
.use(compress({}))
.use(methodOverride())
.use(bodyParser.json())
.use(
bodyParser.urlencoded({
extended: true
"use strict";
var __esDecorate =
(this && this.__esDecorate) ||
function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
function accept(f) {
if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected");
return f;
}
var kind = contextIn.kind,
key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
var target = !descriptorIn && ctor ? (contextIn["static"] ? ctor : ctor.prototype) : null;
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
var _,
done = false;
for (var i = decorators.length - 1; i >= 0; i--) {
var context = {};
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
context.addInitializer = function (f) {
if (done) throw new TypeError("Cannot add initializers after decoration has completed");
extraInitializers.push(accept(f || null));
};
var result = (0, decorators[i])(kind === "accessor" ? {get: descriptor.get, set: descriptor.set} : descriptor[key], context);
if (kind === "accessor") {
if (result === void 0) continue;
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
if ((_ = accept(result.get))) descriptor.get = _;
if ((_ = accept(result.set))) descriptor.set = _;
if ((_ = accept(result.init))) initializers.unshift(_);
} else if ((_ = accept(result))) {
if (kind === "field") initializers.unshift(_);
else descriptor[key] = _;
}
}
if (target) Object.defineProperty(target, contextIn.name, descriptor);
done = true;
};
var __runInitializers =
(this && this.__runInitializers) ||
function (thisArg, initializers, value) {
var useValue = arguments.length > 2;
for (var i = 0; i < initializers.length; i++) {
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
}
return useValue ? value : void 0;
};
var __setFunctionName =
(this && this.__setFunctionName) ||
function (f, name, prefix) {
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
return Object.defineProperty(f, "name", {configurable: true, value: prefix ? "".concat(prefix, " ", name) : name});
};
Object.defineProperty(exports, "__esModule", {value: true});
exports.Server = void 0;
var di_1 = require("@tsed/di");
// import compress from "compression";
// import cookieParser from "cookie-parser";
// import methodOverride from "method-override";
var Server = (function () {
var _classDecorators = [
(0, di_1.Configuration)({
acceptMimes: ["application/json"]
})
);

// routes
restRouter.use("/products", productRouter);

app.use("/rest", restRouter);

exports.expressApp = app;
];
var _classDescriptor;
var _classExtraInitializers = [];
var _classThis;
var _app_decorators;
var _app_initializers = [];
var _app_extraInitializers = [];
var _settings_decorators;
var _settings_initializers = [];
var _settings_extraInitializers = [];
var Server = (_classThis = /** @class */ (function () {
function Server_1() {
this.app = __runInitializers(this, _app_initializers, void 0);
this.settings = (__runInitializers(this, _app_extraInitializers), __runInitializers(this, _settings_initializers, void 0));
__runInitializers(this, _settings_extraInitializers);
}
/**
* This method let you configure the express middleware required by your application to works.
* @returns {Server}
*/
Server_1.prototype.$beforeRoutesInit = function () {
// Add middlewares here only when all of your legacy routes are migrated to Ts.ED
// this.app
// .use(cookieParser())
// .use(compress({}))
// .use(methodOverride())
};
return Server_1;
})());
__setFunctionName(_classThis, "Server");
(function () {
var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
_app_decorators = [(0, di_1.Inject)()];
_settings_decorators = [(0, di_1.Configuration)()];
__esDecorate(
null,
null,
_app_decorators,
{
kind: "field",
name: "app",
static: false,
private: false,
access: {
has: function (obj) {
return "app" in obj;
},
get: function (obj) {
return obj.app;
},
set: function (obj, value) {
obj.app = value;
}
},
metadata: _metadata
},
_app_initializers,
_app_extraInitializers
);
__esDecorate(
null,
null,
_settings_decorators,
{
kind: "field",
name: "settings",
static: false,
private: false,
access: {
has: function (obj) {
return "settings" in obj;
},
get: function (obj) {
return obj.settings;
},
set: function (obj, value) {
obj.settings = value;
}
},
metadata: _metadata
},
_settings_initializers,
_settings_extraInitializers
);
__esDecorate(
null,
(_classDescriptor = {value: _classThis}),
_classDecorators,
{kind: "class", name: _classThis.name, metadata: _metadata},
null,
_classExtraInitializers
);
Server = _classThis = _classDescriptor.value;
if (_metadata)
Object.defineProperty(_classThis, Symbol.metadata, {enumerable: true, configurable: true, writable: true, value: _metadata});
__runInitializers(_classThis, _classExtraInitializers);
})();
return (Server = _classThis);
})();
exports.Server = Server;
1 change: 1 addition & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default [
},
{
files: ["**/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}"],
ignores: ["**/lib/**", "**/dist/**", "**/coverage/**", "**/docs/**", "**/docs-references/**"],
languageOptions: {
ecmaVersion: "latest",
sourceType: "module",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"scripts": {
"postinstall": "cd docs && yarn install && cd .. && node ./tools/github-sponsors/bin/github-sponsors.js",
"configure": "monorepo ci configure",
"clean": "monorepo clean workspace",
"clean": "monorepo clean workspace && rimraf **/tsconfig.spec.tsbuildinfo",
"test": "vitest run",
"test:ci": "yarn test:lint && yarn test:core && yarn test:specs && yarn test:platform && yarn test:integration && yarn test:graphql && yarn test:orm && yarn test:security && yarn test:third-parties",
"test:lint": "eslint '**/*.{ts,js}'",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"types": "./lib/types/index.d.ts",
"browser": "./lib/browser/core.umd.min.js",
"import": "./lib/esm/index.js",
"default": "./lib/cjs/index.js"
"default": "./lib/esm/index.js"
}
},
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/decorators/deprecated.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Type} from "../domain/Type.js";
import type {Type} from "../domain/Type.js";

function deprecate(fn: any, msg: string) {
if (typeof process !== "undefined" && (process as any).noDeprecation === true) {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/decorators/storeFn.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Store} from "../domain/Store.js";
import {DecoratorParameters} from "../interfaces/DecoratorParameters.js";
import type {DecoratorParameters} from "../interfaces/DecoratorParameters.js";

/**
* Create a store correctly configured from the parameters given by the decorator.
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/decorators/storeMerge.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Store} from "../domain/Store.js";
import type {Store} from "../domain/Store.js";
import {StoreFn} from "./storeFn.js";

export function StoreMerge(key: any, value: any): Function {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/decorators/storeSet.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Store} from "../domain/Store.js";
import type {Store} from "../domain/Store.js";
import {StoreFn} from "./storeFn.js";

export function StoreSet(key: any, value: any): Function {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/utils/decorators/decoratorArgs.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {DecoratorParameters} from "../../interfaces/DecoratorParameters.js";
import type {DecoratorParameters} from "../../interfaces/DecoratorParameters.js";
import {descriptorOf} from "../objects/descriptorOf.js";

export function decoratorArgs(target: any, propertyKey: string): DecoratorParameters {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/utils/decorators/useDecorators.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {StoreFn} from "../../decorators/storeFn.js";
import {Store} from "../../domain/Store.js";
import {AnyDecorator} from "../../interfaces/AnyDecorator.js";
import type {AnyDecorator} from "../../interfaces/AnyDecorator.js";
import {useDecorators} from "./useDecorators.js";

describe("useDecorators", () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/utils/decorators/useDecorators.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {AnyDecorator} from "../../interfaces/AnyDecorator.js";
import {DecoratorParameters} from "../../interfaces/DecoratorParameters.js";
import type {AnyDecorator} from "../../interfaces/AnyDecorator.js";
import type {DecoratorParameters} from "../../interfaces/DecoratorParameters.js";

export function useDecorators(...decorators: AnyDecorator[]): any {
return (...args: DecoratorParameters) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/utils/decorators/useMethodDecorators.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {AnyDecorator} from "../../interfaces/AnyDecorator.js";
import type {AnyDecorator} from "../../interfaces/AnyDecorator.js";
import {descriptorOf} from "../objects/descriptorOf.js";

export function useMethodDecorator(decorator: AnyDecorator) {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/utils/objects/methodsOf.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Type} from "../../domain/Type.js";
import type {Type} from "../../domain/Type.js";
import {ancestorsOf} from "./ancestorsOf.js";
import {classOf} from "./classOf.js";
import {prototypeOf} from "./prototypeOf.js";
Expand Down
42 changes: 21 additions & 21 deletions packages/core/tsconfig.spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,31 @@
"compilerOptions": {
"baseUrl": ".",
"rootDir": "..",
"outDir": "./lib/cjs",
"declaration": false,
"composite": false,
"noEmit": true,
"paths": {
"@tsed/openspec": ["../specs/openspec/src"],
"@tsed/schema": ["../specs/schema/src"],
"@tsed/di": ["../di/src"],
"@tsed/exceptions": ["../specs/exceptions/src"],
"@tsed/json-mapper": ["../specs/json-mapper/src"],
"@tsed/platform-exceptions": ["../platform/platform-exceptions/src"],
"@tsed/platform-middlewares": ["../platform/platform-middlewares/src"],
"@tsed/platform-params": ["../platform/platform-params/src"],
"@tsed/platform-log-middleware": ["../platform/platform-log-middleware/src"],
"@tsed/platform-response-filter": ["../platform/platform-response-filter/src"],
"@tsed/platform-router": ["../platform/platform-router/src"],
"@tsed/platform-views": ["../platform/platform-views/src"],
"@tsed/components-scan": ["../third-parties/components-scan/src"],
"@tsed/common": ["../platform/common/src"],
"@tsed/ajv": ["../specs/ajv/src"],
"@tsed/platform-cache": ["../platform/platform-cache/src"],
"@tsed/swagger": ["../specs/swagger/src"],
"@tsed/platform-test-sdk": ["../platform/platform-test-sdk/src"],
"@tsed/platform-express": ["../platform/platform-express/src"],
"@tsed/platform-koa": ["../platform/platform-koa/src"]
"@tsed/openspec": ["../specs/openspec/src/index.ts"],
"@tsed/schema": ["../specs/schema/src/index.ts"],
"@tsed/di": ["../di/src/index.ts"],
"@tsed/exceptions": ["../specs/exceptions/src/index.ts"],
"@tsed/json-mapper": ["../specs/json-mapper/src/index.ts"],
"@tsed/platform-exceptions": ["../platform/platform-exceptions/src/index.ts"],
"@tsed/platform-middlewares": ["../platform/platform-middlewares/src/index.ts"],
"@tsed/platform-params": ["../platform/platform-params/src/index.ts"],
"@tsed/platform-log-middleware": ["../platform/platform-log-middleware/src/index.ts"],
"@tsed/platform-response-filter": ["../platform/platform-response-filter/src/index.ts"],
"@tsed/platform-router": ["../platform/platform-router/src/index.ts"],
"@tsed/platform-views": ["../platform/platform-views/src/index.ts"],
"@tsed/normalize-path": ["../utils/normalize-path/src/index.ts"],
"@tsed/components-scan": ["../third-parties/components-scan/src/index.ts"],
"@tsed/common": ["../platform/common/src/index.ts"],
"@tsed/ajv": ["../specs/ajv/src/index.ts"],
"@tsed/platform-cache": ["../platform/platform-cache/src/index.ts"],
"@tsed/swagger": ["../specs/swagger/src/index.ts"],
"@tsed/platform-test-sdk": ["../platform/platform-test-sdk/src/index.ts"],
"@tsed/platform-express": ["../platform/platform-express/src/index.ts"],
"@tsed/platform-koa": ["../platform/platform-koa/src/index.ts"]
},
"types": ["vite/client", "vitest/globals"]
},
Expand Down
4 changes: 2 additions & 2 deletions packages/di/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"types": "./lib/types/index.d.ts",
"browser": "./lib/browser/di.umd.min.js",
"import": "./lib/esm/index.js",
"default": "./lib/cjs/index.js"
"default": "./lib/esm/index.js"
}
},
"scripts": {
Expand All @@ -37,7 +37,7 @@
"cross-env": "7.0.3",
"eslint": "^8.57.0",
"typescript": "5.6.2",
"vitest": "2.0.4",
"vitest": "2.1.1",
"webpack": "^5.75.0"
},
"peerDependencies": {
Expand Down
5 changes: 3 additions & 2 deletions packages/di/src/common/decorators/configuration.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {DecoratorParameters, decoratorTypeOf, DecoratorTypes, StoreSet} from "@tsed/core";
import type {DecoratorParameters} from "@tsed/core";
import {decoratorTypeOf, DecoratorTypes, StoreSet} from "@tsed/core";

import {DIConfiguration} from "../services/DIConfiguration.js";
import type {DIConfiguration} from "../services/DIConfiguration.js";
import {Inject} from "./inject.js";

/**
Expand Down
5 changes: 3 additions & 2 deletions packages/di/src/common/decorators/controller.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import {isArrayOrArrayClass, Type, useDecorators} from "@tsed/core";
import type {Type} from "@tsed/core";
import {isArrayOrArrayClass, useDecorators} from "@tsed/core";
import {Children, Path} from "@tsed/schema";

import {ProviderOpts} from "../interfaces/ProviderOpts.js";
import type {ProviderOpts} from "../interfaces/ProviderOpts.js";
import {registerController} from "../registries/ProviderRegistry.js";

export type PathType = string | RegExp | (string | RegExp)[];
Expand Down
2 changes: 1 addition & 1 deletion packages/di/src/common/decorators/inject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {catchError, decoratorTypeOf, DecoratorTypes, isPromise, Metadata, Store,
import {DI_INJECTABLE_PROPS, DI_INVOKE_OPTIONS, DI_USE_OPTIONS} from "../constants/constants.js";
import {InvalidPropertyTokenError} from "../errors/InvalidPropertyTokenError.js";
import type {InvokeOptions} from "../interfaces/InvokeOptions.js";
import {TokenProvider} from "../interfaces/TokenProvider.js";
import type {TokenProvider} from "../interfaces/TokenProvider.js";
import {InjectorService} from "../services/InjectorService.js";
import {getConstructorDependencies, setConstructorDependencies} from "../utils/getConstructorDependencies.js";

Expand Down
Loading

0 comments on commit 2fcee85

Please sign in to comment.