diff --git a/.changeset/few-chicken-sell.md b/.changeset/few-chicken-sell.md new file mode 100644 index 000000000..e542a0f9b --- /dev/null +++ b/.changeset/few-chicken-sell.md @@ -0,0 +1,5 @@ +--- +'houdini': patch +--- + +Support projects using `experimentalDecorators: true` flag in there tsconfig.json diff --git a/packages/houdini/src/lib/parse.test.ts b/packages/houdini/src/lib/parse.test.ts index 3ed5cfcf0..9a53c33ee 100644 --- a/packages/houdini/src/lib/parse.test.ts +++ b/packages/houdini/src/lib/parse.test.ts @@ -1,6 +1,6 @@ import { test, expect, describe } from 'vitest' -import { parseJSON } from './parse' +import { parseJS, parseJSON } from './parse' describe('parse', function () { test('parseJSON without comments', async function () { @@ -72,4 +72,21 @@ describe('parse', function () { }, }) }) + + test('parseJS with decorators', async function () { + const parsed = parseJS(` + const a = 1 + const b = 2 + + @annotation + class Test {} + `) + expect(parsed).toMatchInlineSnapshot(` + const a = 1; + const b = 2; + + @annotation + class Test {} + `) + }) }) diff --git a/packages/houdini/src/lib/parse.ts b/packages/houdini/src/lib/parse.ts index bd08f9989..a8a648237 100644 --- a/packages/houdini/src/lib/parse.ts +++ b/packages/houdini/src/lib/parse.ts @@ -11,7 +11,7 @@ export type ParsedFile = Maybe<{ script: Script; start: number; end: number }> // overload definitions export function parseJS(str: string, config?: Partial): Script { const defaultConfig: ParserOptions = { - plugins: ['typescript', 'importAssertions'], + plugins: ['typescript', 'importAssertions', 'decorators'], sourceType: 'module', } // @ts-ignore: babel doesn't perfectly match recast's types (the comments don't line up)