Skip to content

Optional chaining / nullish coalescing with typescipt #1450

Closed
@prbxr

Description

@prbxr

preact-cli 3.03

question / feature request

How to add optional chaining while using typescript?

I am using the default babel-loader config

Added this preact.config.js

    let { rule } = helpers.getLoadersByName(config, 'babel-loader')[0]
    let babelConfig = rule.options
    babelConfig.plugins.push(require.resolve('@babel/plugin-proposal-optional-chaining'))
    babelConfig.overrides[0].plugins.push(require.resolve('@babel/plugin-proposal-optional-chaining'))

but this is the result:

uild failed!

✖ ERROR ./components/Drawer/Drawer.tsx 31:24
Module parse failed: Unexpected token (31:24)
File was processed with these loaders:
* ../node_modules/@prefresh/webpack/src/loader/index.js
* ../node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
|   const dialog = useDialogState();
|
>   let _Body = children ?? Body;
|
|   return h(Fragment, null, h(DialogDisclosure, dialog, Trigger), h(Dialog, _extends({}, dialog, {
@ ./components/panels/Products/productsPanel.stories.tsx 3:0-52 46:5-11
@ ./app/App.tsx
@ ./index.ts
@ ../node_modules/preact-cli/lib/lib/entry.js
@ multi ../node_modules/@prefresh/core/src/index.js ../node_modules/preact-cli/lib/lib/entry

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions