]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
types: use RawSourceMap types
authorEvan You <yyx990803@gmail.com>
Wed, 11 Dec 2019 18:33:45 +0000 (13:33 -0500)
committerEvan You <yyx990803@gmail.com>
Fri, 13 Dec 2019 02:09:46 +0000 (21:09 -0500)
packages/compiler-sfc/src/compileStyle.ts
packages/compiler-sfc/src/stylePreprocessors.ts

index 25b8d419c0739d852718e050b04422e4678b1a3f..a57e1073aadfc02405a7e0b13d091db162afbfe4 100644 (file)
@@ -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
   }
index 2c7b370282896f13f8e544bd47bb9c02eead0a41..b29f0279a758bd2c00586cffd070357061327d3c 100644 (file)
@@ -7,7 +7,7 @@ export interface StylePreprocessor {
 export interface StylePreprocessorResults {
   code: string
   map?: object
-  errors: Array<Error>
+  errors: Error[]
 }
 
 // .scss/.sass processor