From 115f41ee8d34ee66f1a2443817dbd013e5ebd4ae Mon Sep 17 00:00:00 2001 From: alexander-akait Date: Fri, 14 Mar 2025 01:20:37 +0300 Subject: [PATCH] ci: add typescript validation test using old version --- .github/workflows/test.yml | 5 + package.json | 1 + tsconfig.validation.json | 4 + types.d.ts | 185 +++++++++++++++++-------------------- yarn.lock | 5 - 5 files changed, 97 insertions(+), 103 deletions(-) create mode 100644 tsconfig.validation.json diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 66a28f0a3..7756d253d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -43,6 +43,11 @@ jobs: key: lint-cspell-${{ runner.os }}-node-${{ hashFiles('**/yarn.lock', '**/cspell.json') }} restore-keys: lint-cspell- - run: yarn lint + - name: Validate types using old typescript version + run: | + yarn upgrade typescript@5.0 + yarn --frozen-lockfile + yarn type-validate basic: runs-on: ubuntu-latest steps: diff --git a/package.json b/package.json index 5b4f32e0b..0679f2e32 100644 --- a/package.json +++ b/package.json @@ -154,6 +154,7 @@ "lint": "yarn code-lint && yarn special-lint && yarn type-lint && yarn typings-test && yarn module-typings-test && yarn yarn-lint && yarn pretty-lint && yarn spellcheck", "code-lint": "node node_modules/eslint/bin/eslint.js --cache .", "type-lint": "tsc", + "type-validate": "tsc -p tsconfig.validation.json", "typings-test": "tsc -p tsconfig.types.test.json", "module-typings-test": "tsc -p tsconfig.module.test.json", "spellcheck": "cspell --cache --no-must-find-files --quiet \"**/*.*\"", diff --git a/tsconfig.validation.json b/tsconfig.validation.json new file mode 100644 index 000000000..576457fdf --- /dev/null +++ b/tsconfig.validation.json @@ -0,0 +1,4 @@ +{ + "extends": "./tsconfig", + "include": ["types.d.ts"] +} diff --git a/types.d.ts b/types.d.ts index 03e2cafd0..f03614f1f 100644 --- a/types.d.ts +++ b/types.d.ts @@ -244,20 +244,19 @@ declare interface ArgumentConfig { type: "string" | "number" | "boolean" | "path" | "enum" | "RegExp" | "reset"; values?: any[]; } -type ArrayBufferLike = ArrayBuffer | SharedArrayBuffer; -type ArrayBufferView = - | Uint8Array - | Uint8ClampedArray - | Uint16Array - | Uint32Array - | Int8Array - | Int16Array - | Int32Array - | BigUint64Array - | BigInt64Array - | Float32Array - | Float64Array - | DataView; +type ArrayBufferView = + | Uint8Array + | Uint8ClampedArray + | Uint16Array + | Uint32Array + | Int8Array + | Int16Array + | Int32Array + | BigUint64Array + | BigInt64Array + | Float32Array + | Float64Array + | DataView; declare interface Asset { /** * the filename of the asset @@ -872,10 +871,10 @@ type BufferEncoding = | "utf-16le" | "ucs2" | "ucs-2" - | "base64" - | "base64url" | "latin1" | "binary" + | "base64" + | "base64url" | "hex"; type BufferEncodingOption = "buffer" | { encoding: "buffer" }; type BuildInfo = KnownBuildInfo & Record; @@ -3953,10 +3952,10 @@ type EncodingOption = | "utf-16le" | "ucs2" | "ucs-2" - | "base64" - | "base64url" | "latin1" | "binary" + | "base64" + | "base64url" | "hex" | ObjectEncodingOptions; type Entry = @@ -5541,7 +5540,7 @@ declare interface HashedModuleIdsPluginOptions { /** * The encoding to use when generating the hash, defaults to 'base64'. All encodings from Node.JS' hash.digest are supported. */ - hashDigest?: "base64" | "latin1" | "hex"; + hashDigest?: "latin1" | "base64" | "hex"; /** * The prefix length of the hash digest to use, defaults to 4. @@ -5890,15 +5889,15 @@ declare interface IntermediateFileSystemExtras { | "utf-16le" | "ucs2" | "ucs-2" - | "base64" - | "base64url" | "latin1" | "binary" + | "base64" + | "base64url" | "hex" | WriteStreamOptions ) => NodeJS.WritableStream; open: Open; - read: Read>; + read: Read; close: ( df: number, callback: (err: null | NodeJS.ErrnoException) => void @@ -10144,10 +10143,10 @@ declare interface ObjectEncodingOptions { | "utf-16le" | "ucs2" | "ucs-2" - | "base64" - | "base64url" | "latin1" | "binary" + | "base64" + | "base64url" | "hex"; } declare interface ObjectForExtract { @@ -11368,13 +11367,9 @@ declare interface PathData { url?: string; } type PathLikeFs = string | Buffer | URL; -type PathLikeTypes = string | URL_url | Buffer; +type PathLikeTypes = string | Buffer | URL_url; type PathOrFileDescriptorFs = string | number | Buffer | URL; -type PathOrFileDescriptorTypes = - | string - | number - | Buffer - | URL_url; +type PathOrFileDescriptorTypes = string | number | Buffer | URL_url; type Pattern = | Identifier | MemberExpression @@ -11725,10 +11720,7 @@ declare interface RawSourceMap { mappings: string; file: string; } -declare interface Read< - TBuffer extends - ArrayBufferView = ArrayBufferView -> { +declare interface Read { ( fd: number, buffer: TBuffer, @@ -11755,13 +11747,11 @@ declare interface Read< callback: ( err: null | NodeJS.ErrnoException, bytesRead: number, - buffer: ArrayBufferView + buffer: ArrayBufferView ) => void ): void; } -declare interface ReadAsyncOptions< - TBuffer extends ArrayBufferView -> { +declare interface ReadAsyncOptions { offset?: number; length?: number; position?: null | number | bigint; @@ -11813,7 +11803,6 @@ declare interface ReadFileFs { ( path: PathOrFileDescriptorFs, options: - | ({ encoding: BufferEncoding; flag?: string } & Abortable) | "ascii" | "utf8" | "utf-8" @@ -11821,10 +11810,11 @@ declare interface ReadFileFs { | "utf-16le" | "ucs2" | "ucs-2" - | "base64" - | "base64url" | "latin1" | "binary" + | ({ encoding: BufferEncoding; flag?: string } & Abortable) + | "base64" + | "base64url" | "hex", callback: (err: null | NodeJS.ErrnoException, result?: string) => void ): void; @@ -11840,10 +11830,10 @@ declare interface ReadFileFs { | "utf-16le" | "ucs2" | "ucs-2" - | "base64" - | "base64url" | "latin1" | "binary" + | "base64" + | "base64url" | "hex" | (ObjectEncodingOptions & { flag?: string } & Abortable), callback: ( @@ -11871,10 +11861,10 @@ declare interface ReadFileSync { | "utf-16le" | "ucs2" | "ucs-2" - | "base64" - | "base64url" | "latin1" | "binary" + | "base64" + | "base64url" | "hex" | { encoding: BufferEncoding; flag?: string } ): string; @@ -11889,10 +11879,10 @@ declare interface ReadFileSync { | "utf-16le" | "ucs2" | "ucs-2" - | "base64" - | "base64url" | "latin1" | "binary" + | "base64" + | "base64url" | "hex" | (ObjectEncodingOptions & { flag?: string }) ): string | Buffer; @@ -11916,10 +11906,10 @@ declare interface ReadFileTypes { | "utf-16le" | "ucs2" | "ucs-2" - | "base64" - | "base64url" | "latin1" | "binary" + | "base64" + | "base64url" | "hex" | ({ encoding: BufferEncoding; flag?: string } & Abortable), callback: (arg0: null | NodeJS.ErrnoException, arg1?: string) => void @@ -11936,10 +11926,10 @@ declare interface ReadFileTypes { | "utf-16le" | "ucs2" | "ucs-2" - | "base64" - | "base64url" | "latin1" | "binary" + | "base64" + | "base64url" | "hex" | (ObjectEncodingOptions & { flag?: string } & Abortable), callback: ( @@ -11965,10 +11955,10 @@ declare interface ReaddirFs { | "utf-16le" | "ucs2" | "ucs-2" - | "base64" - | "base64url" | "latin1" | "binary" + | "base64" + | "base64url" | "hex" | { encoding: @@ -11980,10 +11970,10 @@ declare interface ReaddirFs { | "utf-16le" | "ucs2" | "ucs-2" - | "base64" - | "base64url" | "latin1" | "binary" + | "base64" + | "base64url" | "hex"; withFileTypes?: false; recursive?: boolean; @@ -12013,10 +12003,10 @@ declare interface ReaddirFs { | "utf-16le" | "ucs2" | "ucs-2" - | "base64" - | "base64url" | "latin1" | "binary" + | "base64" + | "base64url" | "hex" | (ObjectEncodingOptions & { withFileTypes?: false; @@ -12048,10 +12038,10 @@ declare interface ReaddirSync { | "utf-16le" | "ucs2" | "ucs-2" - | "base64" - | "base64url" | "latin1" | "binary" + | "base64" + | "base64url" | "hex" | { encoding: @@ -12063,10 +12053,10 @@ declare interface ReaddirSync { | "utf-16le" | "ucs2" | "ucs-2" - | "base64" - | "base64url" | "latin1" | "binary" + | "base64" + | "base64url" | "hex"; withFileTypes?: false; recursive?: boolean; @@ -12089,10 +12079,10 @@ declare interface ReaddirSync { | "utf-16le" | "ucs2" | "ucs-2" - | "base64" - | "base64url" | "latin1" | "binary" + | "base64" + | "base64url" | "hex" | (ObjectEncodingOptions & { withFileTypes?: false; recursive?: boolean }) ): string[] | Buffer[]; @@ -12117,10 +12107,10 @@ declare interface ReaddirTypes { | "utf-16le" | "ucs2" | "ucs-2" - | "base64" - | "base64url" | "latin1" | "binary" + | "base64" + | "base64url" | "hex" | { encoding: @@ -12132,10 +12122,10 @@ declare interface ReaddirTypes { | "utf-16le" | "ucs2" | "ucs-2" - | "base64" - | "base64url" | "latin1" | "binary" + | "base64" + | "base64url" | "hex"; withFileTypes?: false; recursive?: boolean; @@ -12165,10 +12155,10 @@ declare interface ReaddirTypes { | "utf-16le" | "ucs2" | "ucs-2" - | "base64" - | "base64url" | "latin1" | "binary" + | "base64" + | "base64url" | "hex" | (ObjectEncodingOptions & { withFileTypes?: false; @@ -15601,7 +15591,6 @@ declare class WebpackError extends Error { * Creates an instance of WebpackError. */ constructor(message?: string); - [index: number]: () => string; details?: string; module?: null | Module; loc?: SyntheticDependencyLocation | RealDependencyLocation; @@ -15899,18 +15888,18 @@ declare interface WriteFile { file: PathOrFileDescriptorFs, data: | string - | Uint8Array - | Uint8ClampedArray - | Uint16Array - | Uint32Array - | Int8Array - | Int16Array - | Int32Array - | BigUint64Array - | BigInt64Array - | Float32Array - | Float64Array - | DataView, + | Uint8Array + | Uint8ClampedArray + | Uint16Array + | Uint32Array + | Int8Array + | Int16Array + | Int32Array + | BigUint64Array + | BigInt64Array + | Float32Array + | Float64Array + | DataView, options: WriteFileOptions, callback: (err: null | NodeJS.ErrnoException) => void ): void; @@ -15918,18 +15907,18 @@ declare interface WriteFile { file: PathOrFileDescriptorFs, data: | string - | Uint8Array - | Uint8ClampedArray - | Uint16Array - | Uint32Array - | Int8Array - | Int16Array - | Int32Array - | BigUint64Array - | BigInt64Array - | Float32Array - | Float64Array - | DataView, + | Uint8Array + | Uint8ClampedArray + | Uint16Array + | Uint32Array + | Int8Array + | Int16Array + | Int32Array + | BigUint64Array + | BigInt64Array + | Float32Array + | Float64Array + | DataView, callback: (err: null | NodeJS.ErrnoException) => void ): void; } @@ -15942,10 +15931,10 @@ type WriteFileOptions = | "utf-16le" | "ucs2" | "ucs-2" - | "base64" - | "base64url" | "latin1" | "binary" + | "base64" + | "base64url" | "hex" | (ObjectEncodingOptions & Abortable & { mode?: string | number; flag?: string; flush?: boolean }); @@ -15963,10 +15952,10 @@ declare interface WriteStreamOptions { | "utf-16le" | "ucs2" | "ucs-2" - | "base64" - | "base64url" | "latin1" | "binary" + | "base64" + | "base64url" | "hex"; fd?: any; mode?: number; diff --git a/yarn.lock b/yarn.lock index dbbcf7830..5da19b1fc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6107,11 +6107,6 @@ uglify-js@^3.1.4: resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.19.3.tgz#82315e9bbc6f2b25888858acd1fff8441035b77f" integrity sha512-v3Xu+yuwBXisp6QYTcH4UbH+xYJXqnq2m/LtQVWKWzYc1iehYnLixoQDN9FH6/j9/oybfd6W9Ghwkl8+UMKTKQ== -undici-types@~6.19.2: - version "6.19.8" - resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-6.19.8.tgz#35111c9d1437ab83a7cdc0abae2f26d88eda0a02" - integrity sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw== - undici-types@~6.20.0: version "6.20.0" resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-6.20.0.tgz#8171bf22c1f588d1554d55bf204bc624af388433"