]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(compiler-sfc): `<script setup>` warning
authorcexbrayat <cedric@ninja-squad.com>
Wed, 15 Jul 2020 15:09:33 +0000 (17:09 +0200)
committerEvan You <yyx990803@gmail.com>
Wed, 15 Jul 2020 16:32:11 +0000 (12:32 -0400)
The warning was showing even if the component is only using a classic `<script>`

packages/compiler-sfc/__tests__/compileScript.spec.ts
packages/compiler-sfc/src/compileScript.ts

index 4015683f5fb141ef17268b0cd788b6f17f8ec76f..c4b1c5d89b39303f7678e99315a4472f5437e682 100644 (file)
@@ -457,7 +457,7 @@ describe('SFC compile <script setup>', () => {
       )
     })
 
-    test('error on duplicated defalut export', () => {
+    test('error on duplicated default export', () => {
       expect(
         parse(`
       <script>
index 6137f271558f54a990cfc4f5374c90b6ae602c69..0433d5b987385edb3d2d9c1b5724abed28fca05f 100644 (file)
@@ -40,15 +40,17 @@ export function compileScript(
   sfc: SFCDescriptor,
   options: SFCScriptCompileOptions = {}
 ): SFCScriptBlock {
-  if (__DEV__ && !__TEST__ && !hasWarned) {
+  const { script, scriptSetup, styles, source, filename } = sfc
+
+  if (__DEV__ && !__TEST__ && !hasWarned && scriptSetup) {
     hasWarned = true
-    console.log(
+    // @ts-ignore `console.info` cannot be null error
+    console[console.info ? 'info' : 'log'](
       `\n[@vue/compiler-sfc] <script setup> is still an experimental proposal.\n` +
         `Follow https://github.com/vuejs/rfcs/pull/182 for its status.\n`
     )
   }
 
-  const { script, scriptSetup, styles, source, filename } = sfc
   const hasCssVars = styles.some(s => typeof s.attrs.vars === 'string')
 
   const isTS =