Skip to content

怎么改变 Typescript 的默认生成的函数格式? #740

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

Closed
Shawn211 opened this issue Sep 24, 2021 · 1 comment
Closed

怎么改变 Typescript 的默认生成的函数格式? #740

Shawn211 opened this issue Sep 24, 2021 · 1 comment

Comments

@Shawn211
Copy link

Shawn211 commented Sep 24, 2021

Before you submit an question we recommend you to check out the DOCUMENT first.

You can also find more information in:

💬 Questions and Help

Please outline the questions.

点击 Code Now 按钮,会生成默认格式的文件。

...
function twoSum(nums: number[], target: number): number[] {

};
...

怎么改变他的默认生成的函数像这样的格式?

...
export function twoSum(nums: number[], target: number): number[] {

}
...

谢谢

@Shawn211 Shawn211 changed the title how to change the default function format of typescript 怎么改变 Typescript 的默认生成的函数格式? Sep 24, 2021
@Shawn211
Copy link
Author

不能这样,函数添加了 export 后,力扣会不能校验你的程序

(node:41) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `nodejs run --trace-warnings ...` to show where the warning was created)
Line 51 in prog_joined.js
export function reverseKGroup(head, k) {
^^^^^^
SyntaxError: Unexpected token 'export'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant