Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[babel 8] fix properties name for function-like TS nodes#13709

Merged
nicolo-ribaudo merged 6 commits intobabel:mainfrom
sosukesuzuki:fix-9231
Jan 10, 2022
Merged

[babel 8] fix properties name for function-like TS nodes#13709
nicolo-ribaudo merged 6 commits intobabel:mainfrom
sosukesuzuki:fix-9231

Conversation

@sosukesuzuki
Copy link
Contributor

@sosukesuzuki sosukesuzuki commented Aug 28, 2021

Q                       A
Fixed Issues? Fixes #9231
Major: Breaking Change? Y
Tests Added + Pass? Yes
Documents Link babel/website#2765
License MIT

This PR contains many test changes. It is recommended that you review each commit.

Change parameters and typeAnnotation to params and returnType in the following 5 function-like nodes

  • TSCallSignatureDeclaration
  • TSMethodSignature
  • TSConstructSignatureDeclaration
  • TSFunctionType
  • TSConstructorType

Code examples:

interface Foo {
  // TSCallSignatureDeclaration
  <T>(): string;

  // TSMethodSignature
  foo<T>(): string;

  // TSConstructSignatureDeclaration
  new <T>(): string;
}

// TSFunctionType
type Bar = <T>() => string;

// TSConstructorType
type Baz = new <T>() => string;

@codesandbox-ci
Copy link

codesandbox-ci bot commented Aug 28, 2021

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 0851d5d:

Sandbox Source
babel-repl-custom-plugin Configuration
babel-plugin-multi-config Configuration

@babel-bot
Copy link
Collaborator

babel-bot commented Aug 28, 2021

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/50646/

@fedeci fedeci added this to the Babel 8.0 milestone Sep 3, 2021
Comment on lines +238 to +240
if (!returnType) {
console.log(node);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!returnType) {
console.log(node);
}

typeParameters: validateOptionalType("TSTypeParameterDeclaration"),
parameters: validateArrayOfType(["Identifier", "RestElement"]),
typeAnnotation: validateOptionalType("TSTypeAnnotation"),
[process.env.BABEL_8_BREAKING ? "params" : "parameters"]: validateArrayOfType(
Copy link
Member

@fedeci fedeci Sep 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q: don't we use BABEL_TYPES_8_BREAKING in babel-types?
/cc @JLHwung @nicolo-ribaudo

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I didn't know BABEL_TYPES_8_BREAKING environment variables.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer BABEL_8_BREAKING here. BABEL_TYPES_8_BREAKING can be used by @babel/types consumers to opt-in into stricter validation that we will have in Babel 8. However, opting-in into this AST change makes it impossible to use @babel/types with @babel/parser and @babel/generator.

@sosukesuzuki
Copy link
Contributor Author

@JLHwung Could you review this?

@JLHwung JLHwung mentioned this pull request Jan 10, 2022
34 tasks
@nicolo-ribaudo nicolo-ribaudo merged commit 69246b6 into babel:main Jan 10, 2022
@sosukesuzuki sosukesuzuki deleted the fix-9231 branch January 11, 2022 16:14
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Apr 13, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 13, 2022
@JLHwung JLHwung added PR: Breaking Change 💥 A type of pull request used for our changelog categories for next major release and removed babel 8 labels Aug 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area: typescript outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: generator pkg: parser pkg: types PR: Breaking Change 💥 A type of pull request used for our changelog categories for next major release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Typescript: Inconsistent properties in TS function like nodes [parser, estree]

5 participants