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

Skip to content

fix(sucrase): use bare specifier to obtain SucraseOptions type #1185

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

Merged
merged 2 commits into from
May 14, 2022

Conversation

kherock
Copy link
Contributor

@kherock kherock commented May 10, 2022

Rollup Plugin Name: sucrase

This PR contains:

  • bugfix
  • feature
  • refactor
  • documentation
  • other

Are tests included?

  • yes
  • no (existing tests break after updating sucrase to 3.21.0)

Breaking Changes?

  • yes (breaking changes will not be merged unless absolutely necessary)
  • no

If yes, then include "BREAKING CHANGES:" in the first commit message body, followed by a description of what is breaking.

List any relevant issue numbers:

Description

When typechecking a TS project importing this plugin with skipLibCheck: false, a type error is thrown:

.yarn/__virtual__/@rollup-plugin-sucrase-virtual-7e2c8dc7a4/0/cache/@rollup-plugin-sucrase-npm-4.0.3-5d2d589
3b4-0f8a729c1b.zip/node_modules/@rollup/plugin-sucrase/types/index.d.ts:3:43 - error TS7016: Could not find 
a declaration file for module 'sucrase/dist/Options'. '/Users/.../.yarn/cache/sucrase-npm-3.21.0-78b7f0f024-
d686f255af.zip/node_modules/sucrase/dist/Options.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/sucrase` if it exists or add a new declaration (.d.ts) file containing `decla
re module 'sucrase/dist/Options';`

3 import { Options as SucraseOptions } from 'sucrase/dist/Options';
                                            ~~~~~~~~~~~~~~~~~~~~~~

Sucrase v3.21.0 refactored its internal structure so that types are located apart from dist. I'm not sure why this specifier was chosen since Sucrase has always had this export available from the root specifier: @alangpierce/sucrase@ce0ec25...a2956ca (diff)

@kherock kherock requested a review from shellscape as a code owner May 10, 2022 13:53
@shellscape
Copy link
Collaborator

Thanks for the PR. Could you please add a types test similar to this: https://github.com/rollup/plugins/blob/master/packages/inject/test/types.ts

package.json will need to be updated like so:

"test:ts": "tsc index.d.ts test/types.ts --noEmit"

"ci:test": "pnpm test -- --verbose && pnpm test:ts",

Copy link
Collaborator

@shellscape shellscape left a comment

Choose a reason for hiding this comment

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

thanks!

@shellscape shellscape merged commit 19975ca into rollup:master May 14, 2022
@kherock kherock deleted the fix-sucrase-types branch May 14, 2022 23:59
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

Successfully merging this pull request may close these issues.

2 participants