rollup-plugin-ts icon indicating copy to clipboard operation
rollup-plugin-ts copied to clipboard

Decorators throw `Unexpected token '@'`.

Open selfagency opened this issue 3 years ago • 0 comments

Hi! Am I missing something/doing something wrong that the plugin treats decorators as invalid syntax? Thanks!

Here's my config:

import tsConfigPaths from 'rollup-plugin-tsconfig-paths';
import {nodeResolve} from '@rollup/plugin-node-resolve';
import ts from 'rollup-plugin-ts';

export default {
  input: 'lib/index.ts',
  output: {
    dir: 'dist',
    format: 'cjs',
  },
  plugins: [
    tsConfigPaths(),
    nodeResolve({extensions: ['.tsx', '.ts', '.jsx', '.js', '.json']}),
    ts({
      transpiler: 'swc',
      browserslist: false,
      swcConfig: {
        minify: true,
      },
    }),
  ],
};

And here's the output:

lib/index.ts → dist...
[!] (plugin Typescript) Error: 
  × Unexpected token `@`. Expected identifier, string literal, numeric literal or [ for the computed key
    ╭─[/Users/daniel/code/unstoppable-domains-website/backend/lib/entities/FastlyCachableModel.ts:79:3]
 79 │ @AfterInsert()
    · ─
    ╰────

Caused by:
    0: failed to process input file
    1: Syntax Error


lib/entities/FastlyCachableModel.ts
Error: 
  × Unexpected token `@`. Expected identifier, string literal, numeric literal or [ for the computed key
    ╭─[/Users/daniel/code/unstoppable-domains-website/backend/lib/entities/FastlyCachableModel.ts:79:3]
 79 │ @AfterInsert()
    · ─
    ╰────

Caused by:
    0: failed to process input file
    1: Syntax Error

selfagency avatar Aug 22 '22 17:08 selfagency