ソースを参照

types(compiler-sfc): type annotation tweaks + move @babel/types to devDeps

Evan You 4 年 前
コミット
a42a14d3bc

+ 1 - 1
packages/compiler-sfc/package.json

@@ -33,7 +33,6 @@
   "homepage": "https://github.com/vuejs/vue-next/tree/master/packages/compiler-sfc#readme",
   "dependencies": {
     "@babel/parser": "^7.15.0",
-    "@babel/types": "^7.15.0",
     "@types/estree": "^0.0.48",
     "@vue/compiler-core": "3.2.12",
     "@vue/compiler-dom": "3.2.12",
@@ -52,6 +51,7 @@
     "source-map": "^0.6.1"
   },
   "devDependencies": {
+    "@babel/types": "^7.15.0",
     "@types/consolidate": "^0.14.0",
     "@types/lru-cache": "^5.1.0",
     "pug": "^3.0.1",

+ 1 - 1
packages/compiler-sfc/src/compileScript.ts

@@ -98,7 +98,7 @@ export interface SFCScriptCompileOptions {
   /**
    * Compile the template and inline the resulting render function
    * directly inside setup().
-   * - Only affects <script setup>
+   * - Only affects `<script setup>`
    * - This should only be used in production because it prevents the template
    * from being hot-reloaded separately from component state.
    */

+ 1 - 1
packages/compiler-sfc/src/compileStyle.ts

@@ -30,7 +30,7 @@ export interface SFCStyleCompileOptions {
   postcssOptions?: any
   postcssPlugins?: any[]
   /**
-   * @deprecated
+   * @deprecated use `inMap` instead.
    */
   map?: RawSourceMap
 }

+ 8 - 3
packages/compiler-sfc/src/parse.ts

@@ -9,7 +9,6 @@ import {
 import * as CompilerDOM from '@vue/compiler-dom'
 import { RawSourceMap, SourceMapGenerator } from 'source-map'
 import { TemplateCompiler } from './compileTemplate'
-import { Statement } from '@babel/types'
 import { parseCssVars } from './cssVars'
 import { createCache } from './cache'
 
@@ -41,8 +40,14 @@ export interface SFCScriptBlock extends SFCBlock {
   type: 'script'
   setup?: string | boolean
   bindings?: BindingMetadata
-  scriptAst?: Statement[]
-  scriptSetupAst?: Statement[]
+  /**
+   * import('\@babel/types').Statement
+   */
+  scriptAst?: any[]
+  /**
+   * import('\@babel/types').Statement
+   */
+  scriptSetupAst?: any[]
 }
 export interface SFCStyleBlock extends SFCBlock {
   type: 'style'