From 1ff5960971a0a9bb75449d48a7c361d2f98ee401 Mon Sep 17 00:00:00 2001 From: Evan You Date: Fri, 13 Nov 2020 17:38:28 -0500 Subject: [PATCH] wip: useOptions -> defineOptions --- .../__snapshots__/compileScript.spec.ts.snap | 78 +++++++++---------- .../__tests__/compileScript.spec.ts | 70 ++++++++--------- packages/compiler-sfc/src/compileScript.ts | 66 ++++++++-------- .../useOptions.ts => apiDefineOptions.ts} | 21 +++-- packages/runtime-core/src/index.ts | 2 +- ...ions.test-d.ts => defineOptions.test-d.ts} | 10 +-- 6 files changed, 123 insertions(+), 124 deletions(-) rename packages/runtime-core/src/{helpers/useOptions.ts => apiDefineOptions.ts} (85%) rename test-dts/{useOptions.test-d.ts => defineOptions.test-d.ts} (85%) diff --git a/packages/compiler-sfc/__tests__/__snapshots__/compileScript.spec.ts.snap b/packages/compiler-sfc/__tests__/__snapshots__/compileScript.spec.ts.snap index c48e1ff4..a6db4207 100644 --- a/packages/compiler-sfc/__tests__/__snapshots__/compileScript.spec.ts.snap +++ b/packages/compiler-sfc/__tests__/__snapshots__/compileScript.spec.ts.snap @@ -56,7 +56,25 @@ return { color } }" `; -exports[`SFC compile @@ -302,11 +302,11 @@ const { props, emit } = useOptions({ expect(content).toMatch(`emits: ["foo", "bar"] as unknown as undefined`) }) - test('useOptions w/ type / extract emits (union)', () => { + test('defineOptions w/ type / extract emits (union)', () => { const { content } = compile(` @@ -633,21 +633,21 @@ const { props, emit } = useOptions({ ).toThrow(`ref: statements can only contain assignment expressions`) }) - test('useOptions() w/ both type and non-type args', () => { + test('defineOptions() w/ both type and non-type args', () => { expect(() => { compile(``) }).toThrow(`cannot accept both type and non-type arguments`) }) - test('useOptions() referencing local var', () => { + test('defineOptions() referencing local var', () => { expect(() => compile(``) ).toThrow(`cannot reference locally declared variables`) }) - test('should allow useOptions() referencing scope var', () => { + test('should allow defineOptions() referencing scope var', () => { assertCode( compile(`