Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(typescript): Add test for optional chaining #207

Merged
merged 2 commits into from
Feb 13, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/typescript/test/fixtures/optional-chaining/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
interface OC {
a: number;
b?: {
c?: number;
};
}
const o = { a: 1 } as OC;
export default o.b?.c ?? 'NOT FOUND';
10 changes: 10 additions & 0 deletions packages/typescript/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,16 @@ test('supports CommonJS imports when the output format is CommonJS', async (t) =
t.is(output, 'exported from commonjs');
});

test('supports optional chaining', async (t) => {
const bundle = await rollup({
input: 'fixtures/optional-chaining/main.ts',
plugins: [typescript({ module: 'esnext', target: 'esnext' })],
onwarn
});
const output = await evaluateBundle(bundle);
t.is(output, 'NOT FOUND');
});

function fakeTypescript(custom) {
return Object.assign(
{
Expand Down