Skip to content

Commit

Permalink
feat: add nullish coalescing & optional chaining
Browse files Browse the repository at this point in the history
  • Loading branch information
buschtoens committed Feb 26, 2020
1 parent d5e65aa commit ed65923
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ module.exports = {
use: {
loader: 'babel-loader-8',
options: {
plugins: [
// Transpile new syntax, which is apparently not yet handled by
// `@babel/preset-env`.
// @see https://github.com/typed-ember/ember-cli-typescript/blob/b2e75abc98beefe635b6cfd8808c887813acb44e/ts/addon.ts#L89-L94
require.resolve('@babel/plugin-proposal-optional-chaining'),
require.resolve(
'@babel/plugin-proposal-nullish-coalescing-operator'
)
],
presets: [
// Transpile TypeScript
require.resolve('@babel/preset-typescript'),
Expand Down
2 changes: 2 additions & 0 deletions src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
"lint:js": "eslint --ext ts,js ."
},
"dependencies": {
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.8.3",
"@babel/plugin-proposal-optional-chaining": "^7.8.3",
"@babel/preset-env": "^7.8.4",
"@babel/preset-typescript": "^7.8.3"
},
Expand Down
4 changes: 3 additions & 1 deletion tests/ts-module-b/some/nested-file.ts
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export const works = () => true;
const foo = { bar: { baz: undefined } };

export const works = foo.bar?.baz ?? (() => true);

0 comments on commit ed65923

Please sign in to comment.