From 86fde8f2305f4a857fd8dbf043b9b38211ea72da Mon Sep 17 00:00:00 2001 From: Brendan Bond Date: Tue, 23 Apr 2024 13:52:47 -0500 Subject: [PATCH] remove all prebuilt types; emit .d.ts files as part of build; add tsc as dev dependency (#5577) --- index.d.ts | 1 - package.json | 11 +----- sdk.d.ts | 1 - tsconfig.json | 4 +- types/Embed.d.ts | 13 ------- types/Plugins.d.ts | 95 ---------------------------------------------- types/sdk.d.ts | 1 - utils.d.ts | 1 - yarn.lock | 36 ++++-------------- 9 files changed, 12 insertions(+), 151 deletions(-) delete mode 100644 index.d.ts delete mode 100644 sdk.d.ts delete mode 100644 types/Embed.d.ts delete mode 100644 types/Plugins.d.ts delete mode 100644 types/sdk.d.ts delete mode 100644 utils.d.ts diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index fcb073fefc..0000000000 --- a/index.d.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './types'; diff --git a/package.json b/package.json index 4cf3a1e0cf..31c0f1fa06 100644 --- a/package.json +++ b/package.json @@ -5,12 +5,10 @@ "main": "lib/cjs/index.js", "exports": { ".": { - "types": "index.d.ts", "import": "./lib/cjs/index.js", "require": "./lib/cjs/index.js" }, "./sdk": { - "types": "./types/Formio.d.ts", "import": "./lib/cjs/Formio.js", "require": "./lib/cjs/Formio.js" }, @@ -23,7 +21,6 @@ "require": "./lib/cjs/formio.form.js" }, "./embed": { - "types": "./types/Embed.d.ts", "import": "./lib/cjs/Embed.js", "require": "./lib/cjs/Embed.js" }, @@ -31,12 +28,7 @@ }, "files": [ "dist", - "lib", - "types", - "index.d.ts", - "embed.d.ts", - "sdk.d.ts", - "utils.d.ts" + "lib" ], "pre-commit": [ "lint" @@ -175,6 +167,7 @@ "string-replace-loader": "^3.1.0", "ts-loader": "^9.4.4", "ts-node": "^10.9.1", + "tsc": "^2.0.4", "typescript": "5.3.2", "webpack": "^5.90.3", "webpack-bundle-analyzer": "^4.10.2", diff --git a/sdk.d.ts b/sdk.d.ts deleted file mode 100644 index 0ab92af402..0000000000 --- a/sdk.d.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './types/formio'; diff --git a/tsconfig.json b/tsconfig.json index fe89ac154a..37e7d470ea 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,7 +6,7 @@ "allowJs": true, /* Allow javascript files to be compiled. */ "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ "noImplicitThis": false, /* Raise error on 'this' expressions with an implied 'any' type. */ - "declaration": false, /* Generates corresponding '.d.ts' file. */ + "declaration": true, /* Generates corresponding '.d.ts' file. */ "baseUrl": "src", /* Base directory to resolve non-absolute module names. */ "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ "inlineSourceMap": false, /* Emit a single file with source maps instead of having a separate file. */ @@ -22,7 +22,7 @@ "traceResolution": false, "types": ["node"], "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ - "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */ + "forceConsistentCasingInFileNames": true, /* Disallow inconsistently-cased references to the same file. */ }, "include": [ "src/**/*.js" diff --git a/types/Embed.d.ts b/types/Embed.d.ts deleted file mode 100644 index f1ca9af2bb..0000000000 --- a/types/Embed.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -export declare class Formio { - static config: any; - static icons: string; - static setBaseUrl(url: string): void; - static setApiUrl(url: string): void; - static setAppUrl(url: string): void; - static setProjectUrl(url: string): void; - static clearCache(): void; - static setPathType(type: string): void; - static createForm(element: HTMLElement, form: any, options: any): any; - static builder(element: HTMLElement, form: any, options: any): any; - static use(module: any): void; -} diff --git a/types/Plugins.d.ts b/types/Plugins.d.ts deleted file mode 100644 index 37afe4929f..0000000000 --- a/types/Plugins.d.ts +++ /dev/null @@ -1,95 +0,0 @@ -/** - * The plugin initialization function, which will receive the Formio interface as its first argument. - */ -export interface PluginInitFunction { - /** - * @param Formio - The Formio interface class. - */ - (Formio: any): void; -} -/** - * Function that is called when the plugin is deregistered. - */ -export interface PluginDeregisterFunction { - /** - * @param Formio The Formio interface class. - */ - (Formio: any): void; -} -/** - * A Formio Plugin interface. - */ -export interface Plugin { - /** - * The name of the plugin. - */ - __name: string; - /** - * The priority of this plugin. - */ - priority: number; - /** - * An initialization function called when registered with Formio. - */ - init: PluginInitFunction; - /** - * Called when the plugin is deregistered. - */ - deregister: PluginDeregisterFunction; -} -/** - * The Form.io Plugins allow external systems to "hook" into the default behaviors of the JavaScript SDK. - */ -export default class Plugins { - /** - * An array of Form.io Plugins. - */ - static plugins: Array; - /** - * The Formio class. - */ - static Formio: any; - /** - * Returns the plugin identity. - * - * @param value - */ - static identity(value: string): string; - /** - * De-registers a plugin. - * @param plugin The plugin you wish to deregister. - */ - static deregisterPlugin(plugin: (Plugin | string)): boolean; - /** - * Registers a new plugin. - * - * @param plugin The Plugin object. - * @param name The name of the plugin you wish to register. - */ - static registerPlugin(plugin: Plugin, name: string): void; - /** - * Returns a plugin provided the name of the plugin. - * @param name The name of the plugin you would like to get. - */ - static getPlugin(name: string): Plugin | null; - /** - * Wait for a plugin function to complete. - * @param pluginFn - A function within the plugin. - * @param args - */ - static pluginWait(pluginFn: any, ...args: any[]): Promise; - /** - * Gets a value from a Plugin - * @param pluginFn - * @param args - */ - static pluginGet(pluginFn: any, ...args: any[]): any; - /** - * Allows a Plugin to alter the behavior of the JavaScript library. - * - * @param pluginFn - * @param value - * @param args - */ - static pluginAlter(pluginFn: any, value: any, ...args: any[]): any; -} diff --git a/types/sdk.d.ts b/types/sdk.d.ts deleted file mode 100644 index 479b40eb04..0000000000 --- a/types/sdk.d.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './formio'; diff --git a/utils.d.ts b/utils.d.ts deleted file mode 100644 index 049ff1312b..0000000000 --- a/utils.d.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './types/utils'; diff --git a/yarn.lock b/yarn.lock index a76e9b345e..d34ee45783 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7757,7 +7757,7 @@ string-replace-loader@^3.1.0: loader-utils "^2.0.0" schema-utils "^3.0.0" -"string-width-cjs@npm:string-width@^4.2.0": +"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0, string-width@^4.2.0: version "4.2.3" resolved "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== @@ -7784,15 +7784,6 @@ string-width@^3.0.0: is-fullwidth-code-point "^2.0.0" strip-ansi "^5.1.0" -string-width@^4.1.0, string-width@^4.2.0: - version "4.2.3" - resolved "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" - integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== - dependencies: - emoji-regex "^8.0.0" - is-fullwidth-code-point "^3.0.0" - strip-ansi "^6.0.1" - string-width@^5.0.1, string-width@^5.1.2: version "5.1.2" resolved "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz#14f8daec6d81e7221d2a357e668cab73bdbca794" @@ -7858,7 +7849,7 @@ stringifier@^1.3.0: traverse "^0.6.6" type-name "^2.0.1" -"strip-ansi-cjs@npm:strip-ansi@^6.0.1": +"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1: version "6.0.1" resolved "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== @@ -7886,13 +7877,6 @@ strip-ansi@^5.1.0, strip-ansi@^5.2.0: dependencies: ansi-regex "^4.1.0" -strip-ansi@^6.0.0, strip-ansi@^6.0.1: - version "6.0.1" - resolved "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" - integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== - dependencies: - ansi-regex "^5.0.1" - strip-ansi@^7.0.1: version "7.1.0" resolved "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45" @@ -8241,6 +8225,11 @@ ts-node@^10.9.1: v8-compile-cache-lib "^3.0.1" yn "3.1.1" +tsc@^2.0.4: + version "2.0.4" + resolved "https://registry.yarnpkg.com/tsc/-/tsc-2.0.4.tgz#5f6499146abea5dca4420b451fa4f2f9345238f5" + integrity sha512-fzoSieZI5KKJVBYGvwbVZs/J5za84f2lSTLPYf6AGiIf43tZ3GNrI1QzTLcjtyDDP4aLxd46RTZq1nQxe7+k5Q== + tslib@^1.9.0: version "1.14.1" resolved "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00" @@ -8960,7 +8949,7 @@ workerpool@6.2.1: resolved "https://registry.npmjs.org/workerpool/-/workerpool-6.2.1.tgz#46fc150c17d826b86a008e5a4508656777e9c343" integrity sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw== -"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0": +"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0: version "7.0.0" resolved "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== @@ -8977,15 +8966,6 @@ wrap-ansi@^2.0.0: string-width "^1.0.1" strip-ansi "^3.0.1" -wrap-ansi@^7.0.0: - version "7.0.0" - resolved "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" - integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== - dependencies: - ansi-styles "^4.0.0" - string-width "^4.1.0" - strip-ansi "^6.0.0" - wrap-ansi@^8.1.0: version "8.1.0" resolved "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"