Skip to content

Commit b723a75

Browse files
authored
fix: update Terser type definitions (fix #17668) (#17669)
1 parent 2f7bf79 commit b723a75

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

packages/vite/src/types/terser.d.ts

+10-5
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ SUCH DAMAGE.
3737
export namespace Terser {
3838
export type ECMA = 5 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020
3939

40+
export type ConsoleProperty = keyof typeof console
41+
type DropConsoleOption = boolean | ConsoleProperty[]
42+
4043
export interface ParseOptions {
4144
bare_returns?: boolean
4245
/** @deprecated legacy option. Currently, all supported EcmaScript is valid to parse. */
@@ -57,7 +60,7 @@ export namespace Terser {
5760
dead_code?: boolean
5861
defaults?: boolean
5962
directives?: boolean
60-
drop_console?: boolean
63+
drop_console?: DropConsoleOption
6164
drop_debugger?: boolean
6265
ecma?: ECMA
6366
evaluate?: boolean
@@ -80,6 +83,7 @@ export namespace Terser {
8083
passes?: number
8184
properties?: boolean
8285
pure_funcs?: string[]
86+
pure_new?: boolean
8387
pure_getters?: boolean | 'strict'
8488
reduce_funcs?: boolean
8589
reduce_vars?: boolean
@@ -129,7 +133,7 @@ export namespace Terser {
129133
* Obtains the nth most favored (usually shortest) identifier to rename a variable to.
130134
* The mangler will increment n and retry until the return value is not in use in scope, and is not a reserved word.
131135
* This function is expected to be stable; Evaluating get(n) === get(n) should always return true.
132-
* @param n - The ordinal of the identifier.
136+
* @param n The ordinal of the identifier.
133137
*/
134138
get(n: number): string
135139
}
@@ -141,8 +145,8 @@ export namespace Terser {
141145
/**
142146
* Modifies the internal weighting of the input characters by the specified delta.
143147
* Will be invoked on the entire printed AST, and then deduct mangleable identifiers.
144-
* @param chars - The characters to modify the weighting of.
145-
* @param delta - The numeric weight to add to the characters.
148+
* @param chars The characters to modify the weighting of.
149+
* @param delta The numeric weight to add to the characters.
146150
*/
147151
consider(chars: string, delta: number): number
148152
/**
@@ -225,7 +229,7 @@ export namespace Terser {
225229
module?: boolean
226230
nameCache?: object
227231
format?: FormatOptions
228-
/** @deprecated deprecated */
232+
/** @deprecated */
229233
output?: FormatOptions
230234
parse?: ParseOptions
231235
safari10?: boolean
@@ -245,6 +249,7 @@ export namespace Terser {
245249
includeSources?: boolean
246250
filename?: string
247251
root?: string
252+
asObject?: boolean
248253
url?: string | 'inline'
249254
}
250255
}

0 commit comments

Comments
 (0)