-
-
Notifications
You must be signed in to change notification settings - Fork 599
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
Optional Chaining Causes Build to Fail #205
Comments
I was able to reproduce with this test: 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');
}); fixtures/optional-chaining/main.ts: interface OC {
a: number;
b?: {
c?: number;
};
}
const o = { a: 1 } as OC;
export default o.b?.c ?? 'NOT FOUND';
|
related to this should work I think, use case on our end is that we have a |
/cc @NotWoods |
I might not be able to contribute the fix, but if it's alright with you, may I open a PR with the tests (for maintainers to finish up?) |
Yes, that would be great! |
I've done some investigation and I think that Rollup/acorn is having trouble parsing the new optional chaining syntax. If you set |
I was unable to reproduce this. I tried setting typescript({ target: 'ES2020' }), |
In that case it should start working in the next major version. I've been working on another rewrite to support .d.ts and I have optional chaining working there. |
Fixed in version 4.0.0 of the typescript plugin |
I use v4.0.0 and problem still exist :( |
i found the solution, in tsconfig i change: target esnext -> es2019 For some reason optional chaining does not work with 2020, esnext targets. |
@numfin please combine multiple successive replies so we keep the notifications down. |
Rollup does not appear to support optional chaining (`foo?.bar`). Work around this by lowering the esbuild target to ES2019 Related: rollup/plugins#205
@numfin this seems to have been fixed in rollup/rollup#3582 |
Isn't this expected behavior? The optional chaining operator is part of ES 2020, hence it doesn't need to be downcompiled. |
@rollup/plugin-typescript
How Do We Reproduce?
Expected Behavior
Compiles
Actual Behavior
Fails with
I now present the relevant contents of said repro repo
package.json
rollup.config.js
index.ts
tsconfig.json
The text was updated successfully, but these errors were encountered: