Skip to content

Commit e8ef842

Browse files
Provide better error message when allowDeclareFields is enabled (#15847)
Co-authored-by: Nicolò Ribaudo <hello@nicr.dev>
1 parent dd496c7 commit e8ef842

3 files changed

Lines changed: 9 additions & 0 deletions

File tree

packages/babel-preset-typescript/src/normalize-options.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ export default function normalizeOptions(options: Options = {}) {
3434
};
3535

3636
if (process.env.BABEL_8_BREAKING) {
37+
v.invariant(
38+
!("allowDeclareFields" in options),
39+
"The .allowDeclareFields option has been removed and it's now always enabled. Please remove it from your config.",
40+
);
3741
v.invariant(
3842
!("allExtensions" in options) && !("isTSX" in options),
3943
"The .allExtensions and .isTSX options have been removed.\n" +

packages/babel-preset-typescript/test/fixtures/opts/allowDeclareFields/input.ts

Whitespace-only changes.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"BABEL_8_BREAKING": true,
3+
"presets": [["typescript", { "allowDeclareFields": true }]],
4+
"throws": "The .allowDeclareFields option has been removed and it's now always enabled. Please remove it from your config."
5+
}

0 commit comments

Comments
 (0)