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

Invalid Typescript Types in lib/index.d.ts since 7.6.0 #10403

Closed
adamdbradley opened this issue Sep 6, 2019 · 10 comments
Closed

Invalid Typescript Types in lib/index.d.ts since 7.6.0 #10403

adamdbradley opened this issue Sep 6, 2019 · 10 comments
Labels
Has PR i: bug i: regression outdated A closed issue/PR that is archived due to age. Recommended to make a new issue

Comments

@adamdbradley
Copy link

Bug Report

Current Behavior
node_modules/@babel/types/lib/index.d.ts has invalid typescript since the 7.6.0 release: https://unpkg.com/browse/@babel/types@7.6.0/lib/index.d.ts line 2098

export function isNode(node: ?object): boolean

Environment

  • Babel version(s): 7.6.0

Possible Solution
Move the ? before the :

@babel-bot
Copy link
Collaborator

Hey @adamdbradley! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite.

@matt-forster
Copy link
Contributor

We can't move the ? unless you move the argument order, since the affected arguments are before others that are not optional.

@milesj
Copy link

milesj commented Sep 6, 2019

@forstermatth Not sure what you mean. The ?<type> is invalid TS and is crashing any TS apps using Babel 7.6. This PR caused the issue: #10098

@tanhauhau

@matt-forster
Copy link
Contributor

matt-forster commented Sep 6, 2019

Yes - the possible solution offered in the issue report body would be incorrect. See my PR #10404

@trs
Copy link

trs commented Sep 6, 2019

@milesj It looks like the ?<type> syntax is a flow maybe type.
Changing these to a typescript optional type would fail in cases such as export function isPlaceholderType(placeholderType: ?string, targetType: string): boolean since non-optional types cannot follow an optional type.
If null or undefined are also explicitly allowed, then #10404 would be correct.

@starksds
Copy link

starksds commented Sep 6, 2019

fyi, I reverted back to 7.5.5 and the error went away

@JLHwung JLHwung added the Has PR label Sep 6, 2019
@lancegliser
Copy link

Just for clarity. If you're going move back to 7.5.5, you should declare the @babel/types dependency directly. I had devDependencies for @babel/cli, @babel/core, @babel/preset-env, all pointing at 7.5.5. but they all allowed the upgraded version causing this issue.

@dantehemerson
Copy link

I have the same error using Nestjs

@cperryk
Copy link

cperryk commented Sep 6, 2019

For reference/searchability, the precise error on compiling is this: node_modules/@babel/types/lib/index.d.ts:2098:30 - error TS8020: JSDoc types can only be used inside documentation comments.

@nicolo-ribaudo
Copy link
Member

Fixes in @babel/types 7.6.1. Thanks @forstermatth!

@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Dec 6, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Dec 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Has PR i: bug i: regression outdated A closed issue/PR that is archived due to age. Recommended to make a new issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.