Skip to content

Commit

Permalink
fix: update Terser type definitions (fix #17668) (#17669)
Browse files Browse the repository at this point in the history
  • Loading branch information
luc122c authored Jul 15, 2024
1 parent 2f7bf79 commit b723a75
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions packages/vite/src/types/terser.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ SUCH DAMAGE.
export namespace Terser {
export type ECMA = 5 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020

export type ConsoleProperty = keyof typeof console
type DropConsoleOption = boolean | ConsoleProperty[]

export interface ParseOptions {
bare_returns?: boolean
/** @deprecated legacy option. Currently, all supported EcmaScript is valid to parse. */
Expand All @@ -57,7 +60,7 @@ export namespace Terser {
dead_code?: boolean
defaults?: boolean
directives?: boolean
drop_console?: boolean
drop_console?: DropConsoleOption
drop_debugger?: boolean
ecma?: ECMA
evaluate?: boolean
Expand All @@ -80,6 +83,7 @@ export namespace Terser {
passes?: number
properties?: boolean
pure_funcs?: string[]
pure_new?: boolean
pure_getters?: boolean | 'strict'
reduce_funcs?: boolean
reduce_vars?: boolean
Expand Down Expand Up @@ -129,7 +133,7 @@ export namespace Terser {
* Obtains the nth most favored (usually shortest) identifier to rename a variable to.
* The mangler will increment n and retry until the return value is not in use in scope, and is not a reserved word.
* This function is expected to be stable; Evaluating get(n) === get(n) should always return true.
* @param n - The ordinal of the identifier.
* @param n The ordinal of the identifier.
*/
get(n: number): string
}
Expand All @@ -141,8 +145,8 @@ export namespace Terser {
/**
* Modifies the internal weighting of the input characters by the specified delta.
* Will be invoked on the entire printed AST, and then deduct mangleable identifiers.
* @param chars - The characters to modify the weighting of.
* @param delta - The numeric weight to add to the characters.
* @param chars The characters to modify the weighting of.
* @param delta The numeric weight to add to the characters.
*/
consider(chars: string, delta: number): number
/**
Expand Down Expand Up @@ -225,7 +229,7 @@ export namespace Terser {
module?: boolean
nameCache?: object
format?: FormatOptions
/** @deprecated deprecated */
/** @deprecated */
output?: FormatOptions
parse?: ParseOptions
safari10?: boolean
Expand All @@ -245,6 +249,7 @@ export namespace Terser {
includeSources?: boolean
filename?: string
root?: string
asObject?: boolean
url?: string | 'inline'
}
}

0 comments on commit b723a75

Please sign in to comment.