forked from babel/babel
-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
typescript.ts
23 lines (22 loc) · 835 Bytes
/
typescript.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import type { NodePath } from "@babel/traverse";
import type * as t from "@babel/types";
export function assertFieldTransformed(
path: NodePath<t.ClassProperty | t.ClassDeclaration>,
) {
if (
path.node.declare ||
(process.env.BABEL_8_BREAKING
? path.isClassProperty({ definite: true })
: false)
) {
throw path.buildCodeFrameError(
`TypeScript 'declare' fields must first be transformed by ` +
`@babel/plugin-transform-typescript.\n` +
`If you have already enabled that plugin (or '@babel/preset-typescript'), make sure ` +
`that it runs before any plugin related to additional class features:\n` +
` - @babel/plugin-transform-class-properties\n` +
` - @babel/plugin-transform-private-methods\n` +
` - @babel/plugin-proposal-decorators`,
);
}
}