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

A DRY-er syntax for jsdoc types imports #26352

Closed
4 tasks done
nojvek opened this issue Aug 10, 2018 · 5 comments
Closed
4 tasks done

A DRY-er syntax for jsdoc types imports #26352

nojvek opened this issue Aug 10, 2018 · 5 comments
Labels
checkJs Relates to checking JavaScript using TypeScript Domain: JavaScript The issue relates to JavaScript specifically Domain: JSDoc Relates to JSDoc parsing and type generation Duplicate An existing issue was already created Suggestion An idea for TypeScript

Comments

@nojvek
Copy link
Contributor

nojvek commented Aug 10, 2018

Suggestion

So the current way of importing things in JS land for types declared in .d.ts is kind of really redundant

/** @typedef { import('./my-types').Foo } Foo */
/** @typedef { import('./my-types').Bar } Bar */
/** @typedef { import('./my-types').Hello } Hello */
/** @typedef { import('./my-types').World } World */

This violates the DRY principle and kind of looks awful.

Can we have a similar import syntax to the .ts and normal .js versions ?

/** @import {Foo, Bar, Hello, World} from './my-types' **/

Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript / JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. new expression-level syntax)
@nojvek nojvek changed the title A slightly nicer syntax for jsdoc types imports A DRY-er syntax for jsdoc types imports Aug 10, 2018
@ghost ghost added Suggestion An idea for TypeScript Domain: JavaScript The issue relates to JavaScript specifically Domain: JSDoc Relates to JSDoc parsing and type generation Salsa checkJs Relates to checking JavaScript using TypeScript labels Aug 10, 2018
@DanielRosenwasser
Copy link
Member

Duplicate of #22160?

@DanielRosenwasser DanielRosenwasser added the Duplicate An existing issue was already created label Aug 10, 2018
@nojvek
Copy link
Contributor Author

nojvek commented Aug 10, 2018

Yeah but the other issue is closed right?

I’ve started campaigning for typed js at my current workplace however the redundant type import syntax makes everyone 🤮 at my PRs

@ghost
Copy link

ghost commented Aug 10, 2018

The other issue is open.

@nojvek
Copy link
Contributor Author

nojvek commented Nov 6, 2018

@weswigham is this actually fixed now? I’m not sure why it’s being closed without a reason.

@weswigham
Copy link
Member

Because it does sufficiently duplicate #22160 which is actually open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
checkJs Relates to checking JavaScript using TypeScript Domain: JavaScript The issue relates to JavaScript specifically Domain: JSDoc Relates to JSDoc parsing and type generation Duplicate An existing issue was already created Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

3 participants