Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update Terser type definitions (fix #17668) #17669

Merged
merged 3 commits into from
Jul 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'
}
}