From a5200306f93a4029fb45ba948fa2a7d28847f17f Mon Sep 17 00:00:00 2001 From: Slava Fomin II Date: Mon, 19 Aug 2019 21:17:00 +0300 Subject: [PATCH] Extended "overrideBrowserslist" option to support environment maps (#37642) --- types/autoprefixer/autoprefixer-tests.ts | 19 ++++++++++++++++++- types/autoprefixer/index.d.ts | 8 ++++++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/types/autoprefixer/autoprefixer-tests.ts b/types/autoprefixer/autoprefixer-tests.ts index f3585fe30d..c8581b8da8 100644 --- a/types/autoprefixer/autoprefixer-tests.ts +++ b/types/autoprefixer/autoprefixer-tests.ts @@ -16,5 +16,22 @@ const ap2: Transformer = autoprefixer({ flexbox: true, grid: false, stats: {}, - ignoreUnknownVersions: false + ignoreUnknownVersions: false, +}); + +// Using environment map in "overrideBrowserslist" +const ap3: Transformer = autoprefixer({ + overrideBrowserslist: { + production: [ + '> 1%', + 'ie 10', + ], + modern: [ + 'last 1 chrome version', + 'last 1 firefox version', + ], + ssr: [ + 'node 12', + ], + }, }); diff --git a/types/autoprefixer/index.d.ts b/types/autoprefixer/index.d.ts index f689168751..95b0d99e9e 100644 --- a/types/autoprefixer/index.d.ts +++ b/types/autoprefixer/index.d.ts @@ -1,6 +1,8 @@ // Type definitions for autoprefixer 9.6 // Project: https://github.com/postcss/autoprefixer -// Definitions by: Armando Meziat , murt +// Definitions by: Armando Meziat +// murt +// Slava Fomin II // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.7 @@ -8,6 +10,8 @@ import { Plugin } from 'postcss'; import { Stats } from 'browserslist'; declare namespace autoprefixer { + type BrowserslistTarget = (string | string[] | { [key: string]: string[]; }); + interface Options { env?: string; cascade?: boolean; @@ -18,7 +22,7 @@ declare namespace autoprefixer { grid?: false | 'autoplace' | 'no-autoplace'; stats?: Stats; browsers?: string[] | string; - overrideBrowserslist?: string[] | string; + overrideBrowserslist?: BrowserslistTarget; ignoreUnknownVersions?: boolean; }