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

Several properties in TypeScript types for Config should be made optional #1947

Closed
cspotcode opened this issue Jul 21, 2021 · 2 comments · Fixed by #2077
Closed

Several properties in TypeScript types for Config should be made optional #1947

cspotcode opened this issue Jul 21, 2021 · 2 comments · Fixed by #2077
Assignees
Labels
Milestone

Comments

@cspotcode
Copy link
Contributor

cspotcode commented Jul 21, 2021

Describe the bug

TypeScript types for AmdConfig mark moduleId as required; should be optional.

The type is declared are required here:

moduleId: string;

It is documented as optional here:
https://swc.rs/docs/swcrc-module#amd

EDIT I believe that a few more should also be made optional:

swc/node-swc/src/types.ts

Lines 407 to 456 in ebdd04d

export interface ReactConfig {
/**
* Replace the function used when compiling JSX expressions.
*
* Defaults to `React.createElement`.
*/
pragma: string;
/**
* Replace the component used when compiling JSX fragments.
*
* Defaults to `React.Fragment`
*/
pragmaFrag: string;
/**
* Toggles whether or not to throw an error if a XML namespaced tag name is used. For example:
* `<f:image />`
*
* Though the JSX spec allows this, it is disabled by default since React's
* JSX does not currently have support for it.
*
*/
throwIfNamespace: boolean;
/**
* Toggles plugins that aid in development, such as @swc/plugin-transform-react-jsx-self
* and @swc/plugin-transform-react-jsx-source.
*
* Defaults to `false`,
*
*/
development: boolean;
/**
* Use `Object.assign()` instead of `_extends`. Defaults to false.
*/
useBuiltins: boolean;
/**
* Enable fast refresh feature for React app
*/
refresh: boolean;
/**
* jsx runtime
*/
runtime: 'automatic' | 'classic'
/**
* Declares the module specifier to be used for importing the `jsx` and `jsxs` factory functions when using `runtime` 'automatic'
*/
importSource: string
}

ReactConfig: importSource, refresh, runtime

Input code

N/A

Config

N/A

Expected behavior

Typechecking should pass when omitting moduleId from module config object.

Version
The version of @swc/core: master branch on github

@cspotcode cspotcode changed the title TypeScript types for AmdConfig moduleId should be optional Several properties in TypeScript types for Config should be made optional Jul 21, 2021
@cspotcode
Copy link
Contributor Author

I updated the title and edited the issue description to include some additional config properties which I believe should be made optional as well.

@kdy1 kdy1 added this to the v1.2.67 milestone Jul 22, 2021
@kdy1 kdy1 modified the milestones: v1.2.67, v1.2.68, v1.2.72, v1.2.73, v1.2.74, v1.2.75 Jul 31, 2021
@kdy1 kdy1 modified the milestones: v1.2.75, v1.2.76, v1.2.77, v1.2.78 Aug 8, 2021
@kdy1 kdy1 self-assigned this Aug 14, 2021
kdy1 added a commit to kdy1/swc that referenced this issue Aug 14, 2021
kdy1 added a commit that referenced this issue Aug 14, 2021
swc_ecma_visit:
 - Ensure that #1967 is wrong. (#1967)

swc:
 - Add a test for #1107. (#1107)

node:
 - Make optional fields optional. (#1947)
@swc-bot
Copy link
Collaborator

swc-bot commented Oct 22, 2022

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@swc-project swc-project locked as resolved and limited conversation to collaborators Oct 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging a pull request may close this issue.

3 participants