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

Compile Fails When Called Method Has Deep Destructed inputs. #2232

Closed
hkd987 opened this issue Sep 10, 2021 · 9 comments · Fixed by #2249
Closed

Compile Fails When Called Method Has Deep Destructed inputs. #2232

hkd987 opened this issue Sep 10, 2021 · 9 comments · Fixed by #2249
Labels
Milestone

Comments

@hkd987
Copy link

hkd987 commented Sep 10, 2021

Describe the bug
When calling a method that has multiple object inputs as separate inputs. SWC fails to compile when the objects are deconstructed deeply. To give context this is a graphql resolver that is being called.
Input code

async sendSomeMessage(
			_parent: unknown,
			{ input: { toNumber, messageBody, ...all  } }: SendSomeMessageInput,
			{ dataSources }: Context,
		): Promise<boolean> 

When changing the called method below the code compiles

async sendSomeMessage(
			_parent: unknown,
			{ input }: SendSomeMessageInput,
			{ dataSources }: Context,
		): Promise<boolean> 

Error Message

sendSomeMessage (_parent, _param, _param) {

SyntaxError: Duplicate parameter name not allowed in this context

Config

{
	"test": ".*.ts$",
	"sourceMaps": true,
	"jsc": {
		"target": "es2017",
		"externalHelpers": true,
		"loose": true,
		"parser": {
			"syntax": "typescript",
			"tsx": false,
			"decorators": true,
			"dynamicImport": false
		}
	},
	"module": {
		"type": "commonjs",
		"strict": false,
		"strictMode": true,
		"lazy": false,
		"noInterop": false
	}
}

Expected behavior
Expect that when calling a method with multiple object inputs deep object destructing will work.

Version
The version of @swc/core: ^1.2.85

@hkd987 hkd987 added the C-bug label Sep 10, 2021
@kdy1 kdy1 modified the milestones: v1.2.87, v1.2.88 Sep 13, 2021
@kdy1
Copy link
Member

kdy1 commented Sep 15, 2021

Are you using wasm?
I can't reproduce this using @swc/core

@kdy1 kdy1 removed this from the v1.2.88 milestone Sep 15, 2021
kdy1 added a commit to kdy1/swc that referenced this issue Sep 15, 2021
@kdy1 kdy1 modified the milestones: v1.2.87, v1.2.88 Sep 15, 2021
kdy1 added a commit that referenced this issue Sep 15, 2021
swc_ecma_transforms_compat:
 - Fix `this` in class properties. (#2228)

swc_ecma_transforms_typescript:
 - Handle `import =` correctly. (#2234)
 - Ensure that #1653 is not the case anymore. (#1653)

swc:
 - Ensure that #2232 is not the case. (#2232)
@hkd987
Copy link
Author

hkd987 commented Sep 15, 2021

@kdy1, I am not using WASM but using typescript however looks like you were able to find and resolve the issue. Thanks.

@kdy1
Copy link
Member

kdy1 commented Sep 15, 2021

I think I closed it after testing your input, not fixing bug.

@hkd987
Copy link
Author

hkd987 commented Sep 15, 2021

Wonder if it makes any difference that the method that was having this issue was on an object similar to below....

const resolver = {
  async sendSomeMessage(
			_parent: unknown,
			{ input: { toNumber, messageBody, ...all  } }: SendSomeMessageInput,
			{ dataSources }: Context,
		): Promise<boolean> 
}

export default resolver

@kdy1 kdy1 reopened this Sep 15, 2021
@kdy1 kdy1 modified the milestones: v1.2.88, v1.2.89 Sep 16, 2021
@kdy1
Copy link
Member

kdy1 commented Sep 16, 2021

@hkd987 The input you provided is wrong, because there's no body.

kdy1 added a commit to kdy1/swc that referenced this issue Sep 16, 2021
@kdy1
Copy link
Member

kdy1 commented Sep 16, 2021

And I verified that swc works well with your input

@kdy1 kdy1 closed this as completed Sep 16, 2021
@kdy1 kdy1 modified the milestones: v1.2.89, v1.2.87 Sep 16, 2021
@hkd987
Copy link
Author

hkd987 commented Sep 16, 2021

I did not provide the method body for brevity sake so that we could focus on the issue at hand only.

@hkd987
Copy link
Author

hkd987 commented Sep 16, 2021

Something around this is blocking compile, I just cant put my finger on the exact issue. This is when using https://www.npmjs.com/package/@swc/jest

@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