Skip to content

Commit ed65923

Browse files
committed
feat: add nullish coalescing & optional chaining
1 parent d5e65aa commit ed65923

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

src/index.js

+9
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@ module.exports = {
2929
use: {
3030
loader: 'babel-loader-8',
3131
options: {
32+
plugins: [
33+
// Transpile new syntax, which is apparently not yet handled by
34+
// `@babel/preset-env`.
35+
// @see https://github.com/typed-ember/ember-cli-typescript/blob/b2e75abc98beefe635b6cfd8808c887813acb44e/ts/addon.ts#L89-L94
36+
require.resolve('@babel/plugin-proposal-optional-chaining'),
37+
require.resolve(
38+
'@babel/plugin-proposal-nullish-coalescing-operator'
39+
)
40+
],
3241
presets: [
3342
// Transpile TypeScript
3443
require.resolve('@babel/preset-typescript'),

src/package.json

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
"lint:js": "eslint --ext ts,js ."
1717
},
1818
"dependencies": {
19+
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.8.3",
20+
"@babel/plugin-proposal-optional-chaining": "^7.8.3",
1921
"@babel/preset-env": "^7.8.4",
2022
"@babel/preset-typescript": "^7.8.3"
2123
},

tests/ts-module-b/some/nested-file.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
export const works = () => true;
1+
const foo = { bar: { baz: undefined } };
2+
3+
export const works = foo.bar?.baz ?? (() => true);

0 commit comments

Comments
 (0)