Skip to content

Commit 2ff8e9f

Browse files
author
Tim Roes
authored
Make babel understand TypeScript 3.7 syntax (#50772) (#50802)
* Use correct babel plugins * Make one change using new operator * Fix i18n babel config
1 parent 88558f4 commit 2ff8e9f

File tree

5 files changed

+50
-2
lines changed

5 files changed

+50
-2
lines changed

packages/kbn-babel-preset/common_preset.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ const plugins = [
2727
//
2828
// See https://github.com/babel/proposals/issues/12 for progress
2929
require.resolve('@babel/plugin-proposal-class-properties'),
30+
31+
// Optional Chaining proposal is stage 3 (https://github.com/tc39/proposal-optional-chaining)
32+
// Need this since we are using TypeScript 3.7+
33+
require.resolve('@babel/plugin-proposal-optional-chaining'),
34+
// Nullish coalescing proposal is stage 3 (https://github.com/tc39/proposal-nullish-coalescing)
35+
// Need this since we are using TypeScript 3.7+
36+
require.resolve('@babel/plugin-proposal-nullish-coalescing-operator'),
3037
];
3138
const isTestEnv = process.env.BABEL_ENV === 'test' || process.env.NODE_ENV === 'test';
3239

packages/kbn-babel-preset/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
"license": "Apache-2.0",
66
"dependencies": {
77
"@babel/plugin-proposal-class-properties": "^7.5.1",
8+
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.4.4",
9+
"@babel/plugin-proposal-optional-chaining": "^7.6.0",
810
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
911
"@babel/plugin-transform-modules-commonjs": "^7.5.0",
1012
"@babel/preset-env": "^7.5.5",

src/dev/i18n/extractors/code.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,16 @@ export function* extractCodeMessages(buffer, reporter) {
6767
try {
6868
ast = parse(buffer.toString(), {
6969
sourceType: 'module',
70-
plugins: ['jsx', 'typescript', 'objectRestSpread', 'classProperties', 'asyncGenerators', 'dynamicImport'],
70+
plugins: [
71+
'jsx',
72+
'typescript',
73+
'objectRestSpread',
74+
'classProperties',
75+
'asyncGenerators',
76+
'dynamicImport',
77+
'nullishCoalescingOperator',
78+
'optionalChaining',
79+
],
7180
});
7281
} catch (error) {
7382
if (error instanceof SyntaxError) {

src/plugins/inspector/public/adapters/request/request_adapter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class RequestAdapter extends EventEmitter {
5454
name,
5555
startTime: Date.now(),
5656
status: RequestStatus.PENDING,
57-
id: _.get(params, 'id', uuid()),
57+
id: params.id ?? uuid(),
5858
};
5959
this.requests.set(req.id, req);
6060
this._onChange();

yarn.lock

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,14 @@
346346
"@babel/helper-plugin-utils" "^7.0.0"
347347
"@babel/plugin-syntax-json-strings" "^7.2.0"
348348

349+
"@babel/plugin-proposal-nullish-coalescing-operator@^7.4.4":
350+
version "7.4.4"
351+
resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-nullish-coalescing-operator/-/plugin-proposal-nullish-coalescing-operator-7.4.4.tgz#41c360d59481d88e0ce3a3f837df10121a769b39"
352+
integrity sha512-Amph7Epui1Dh/xxUxS2+K22/MUi6+6JVTvy3P58tja3B6yKTSjwwx0/d83rF7551D6PVSSoplQb8GCwqec7HRw==
353+
dependencies:
354+
"@babel/helper-plugin-utils" "^7.0.0"
355+
"@babel/plugin-syntax-nullish-coalescing-operator" "^7.2.0"
356+
349357
"@babel/[email protected]", "@babel/plugin-proposal-object-rest-spread@^7.3.2", "@babel/plugin-proposal-object-rest-spread@^7.5.5":
350358
version "7.5.5"
351359
resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-object-rest-spread/-/plugin-proposal-object-rest-spread-7.5.5.tgz#61939744f71ba76a3ae46b5eea18a54c16d22e58"
@@ -362,6 +370,14 @@
362370
"@babel/helper-plugin-utils" "^7.0.0"
363371
"@babel/plugin-syntax-optional-catch-binding" "^7.2.0"
364372

373+
"@babel/plugin-proposal-optional-chaining@^7.6.0":
374+
version "7.6.0"
375+
resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-optional-chaining/-/plugin-proposal-optional-chaining-7.6.0.tgz#e9bf1f9b9ba10c77c033082da75f068389041af8"
376+
integrity sha512-kj4gkZ6qUggkprRq3Uh5KP8XnE1MdIO0J7MhdDX8+rAbB6dJ2UrensGIS+0NPZAaaJ1Vr0PN6oLUgXMU1uMcSg==
377+
dependencies:
378+
"@babel/helper-plugin-utils" "^7.0.0"
379+
"@babel/plugin-syntax-optional-chaining" "^7.2.0"
380+
365381
"@babel/plugin-proposal-unicode-property-regex@^7.4.4":
366382
version "7.4.4"
367383
resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-unicode-property-regex/-/plugin-proposal-unicode-property-regex-7.4.4.tgz#501ffd9826c0b91da22690720722ac7cb1ca9c78"
@@ -413,6 +429,13 @@
413429
dependencies:
414430
"@babel/helper-plugin-utils" "^7.0.0"
415431

432+
"@babel/plugin-syntax-nullish-coalescing-operator@^7.2.0":
433+
version "7.2.0"
434+
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-nullish-coalescing-operator/-/plugin-syntax-nullish-coalescing-operator-7.2.0.tgz#f75083dfd5ade73e783db729bbd87e7b9efb7624"
435+
integrity sha512-lRCEaKE+LTxDQtgbYajI04ddt6WW0WJq57xqkAZ+s11h4YgfRHhVA/Y2VhfPzzFD4qeLHWg32DMp9HooY4Kqlg==
436+
dependencies:
437+
"@babel/helper-plugin-utils" "^7.0.0"
438+
416439
"@babel/plugin-syntax-object-rest-spread@^7.0.0", "@babel/plugin-syntax-object-rest-spread@^7.2.0":
417440
version "7.2.0"
418441
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-object-rest-spread/-/plugin-syntax-object-rest-spread-7.2.0.tgz#3b7a3e733510c57e820b9142a6579ac8b0dfad2e"
@@ -427,6 +450,13 @@
427450
dependencies:
428451
"@babel/helper-plugin-utils" "^7.0.0"
429452

453+
"@babel/plugin-syntax-optional-chaining@^7.2.0":
454+
version "7.2.0"
455+
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-optional-chaining/-/plugin-syntax-optional-chaining-7.2.0.tgz#a59d6ae8c167e7608eaa443fda9fa8fa6bf21dff"
456+
integrity sha512-HtGCtvp5Uq/jH/WNUPkK6b7rufnCPLLlDAFN7cmACoIjaOOiXxUt3SswU5loHqrhtqTsa/WoLQ1OQ1AGuZqaWA==
457+
dependencies:
458+
"@babel/helper-plugin-utils" "^7.0.0"
459+
430460
"@babel/plugin-syntax-typescript@^7.2.0":
431461
version "7.3.3"
432462
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.3.3.tgz#a7cc3f66119a9f7ebe2de5383cce193473d65991"

0 commit comments

Comments
 (0)