From 3de7315b7aba61f25db14f45d848076290c84fb5 Mon Sep 17 00:00:00 2001 From: Evan You Date: Wed, 11 Dec 2019 13:33:45 -0500 Subject: [PATCH] types: use RawSourceMap types --- packages/compiler-sfc/src/compileStyle.ts | 15 ++++++++------- packages/compiler-sfc/src/stylePreprocessors.ts | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/packages/compiler-sfc/src/compileStyle.ts b/packages/compiler-sfc/src/compileStyle.ts index 25b8d419..a57e1073 100644 --- a/packages/compiler-sfc/src/compileStyle.ts +++ b/packages/compiler-sfc/src/compileStyle.ts @@ -8,12 +8,13 @@ import { StylePreprocessorResults, PreprocessLang } from './stylePreprocessors' +import { RawSourceMap } from 'source-map' export interface StyleCompileOptions { source: string filename: string id: string - map?: object + map?: RawSourceMap scoped?: boolean trim?: boolean preprocessLang?: PreprocessLang @@ -28,9 +29,9 @@ export interface AsyncStyleCompileOptions extends StyleCompileOptions { export interface StyleCompileResults { code: string - map: object | void + map: RawSourceMap | undefined rawResult: LazyResult | Result | undefined - errors: string[] + errors: Error[] } export function compileStyle( @@ -89,7 +90,7 @@ export function doCompileStyle( let code: string | undefined let outMap: ResultMap | undefined - const errors: any[] = [] + const errors: Error[] = [] if (preProcessedSource && preProcessedSource.errors.length) { errors.push(...preProcessedSource.errors) } @@ -102,14 +103,14 @@ export function doCompileStyle( return result .then(result => ({ code: result.css || '', - map: result.map && result.map.toJSON(), + map: result.map && (result.map.toJSON() as any), errors, rawResult: result })) .catch(error => ({ code: '', map: undefined, - errors: [...errors, error.message], + errors: [...errors, error], rawResult: undefined })) } @@ -123,7 +124,7 @@ export function doCompileStyle( return { code: code || ``, - map: outMap && outMap.toJSON(), + map: outMap && (outMap.toJSON() as any), errors, rawResult: result } diff --git a/packages/compiler-sfc/src/stylePreprocessors.ts b/packages/compiler-sfc/src/stylePreprocessors.ts index 2c7b3702..b29f0279 100644 --- a/packages/compiler-sfc/src/stylePreprocessors.ts +++ b/packages/compiler-sfc/src/stylePreprocessors.ts @@ -7,7 +7,7 @@ export interface StylePreprocessor { export interface StylePreprocessorResults { code: string map?: object - errors: Array + errors: Error[] } // .scss/.sass processor