From 001f8ce99386054c2bea0e3d248f50e1fb4c38bc Mon Sep 17 00:00:00 2001 From: Evan You Date: Thu, 12 Nov 2020 22:51:40 -0500 Subject: [PATCH] wip: defineContext -> useOptions --- .../__snapshots__/compileScript.spec.ts.snap | 78 +++++++-------- .../__tests__/compileScript.spec.ts | 70 ++++++------- packages/compiler-sfc/src/compileScript.ts | 97 +++++++++---------- .../useOptions.ts} | 12 ++- packages/runtime-core/src/index.ts | 2 +- 5 files changed, 131 insertions(+), 128 deletions(-) rename packages/runtime-core/src/{apiDefineContext.ts => helpers/useOptions.ts} (58%) diff --git a/packages/compiler-sfc/__tests__/__snapshots__/compileScript.spec.ts.snap b/packages/compiler-sfc/__tests__/__snapshots__/compileScript.spec.ts.snap index 6b95ef42..c48e1ff4 100644 --- a/packages/compiler-sfc/__tests__/__snapshots__/compileScript.spec.ts.snap +++ b/packages/compiler-sfc/__tests__/__snapshots__/compileScript.spec.ts.snap @@ -56,25 +56,7 @@ return { color } }" `; -exports[`SFC compile @@ -302,11 +302,11 @@ const { props, emit } = defineContext({ expect(content).toMatch(`emits: ["foo", "bar"] as unknown as undefined`) }) - test('defineContext w/ type / extract emits (union)', () => { + test('useOptions w/ type / extract emits (union)', () => { const { content } = compile(` @@ -633,21 +633,21 @@ const { props, emit } = defineContext({ ).toThrow(`ref: statements can only contain assignment expressions`) }) - test('defineContext() w/ both type and non-type args', () => { + test('useOptions() w/ both type and non-type args', () => { expect(() => { compile(``) }).toThrow(`cannot accept both type and non-type arguments`) }) - test('defineContext() referencing local var', () => { + test('useOptions() referencing local var', () => { expect(() => compile(``) ).toThrow(`cannot reference locally declared variables`) }) - test('should allow defineContext() referencing scope var', () => { + test('should allow useOptions() referencing scope var', () => { assertCode( compile(`