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

Remove Unused Imports #3483

Closed
wants to merge 1 commit into from
Closed

Remove Unused Imports #3483

wants to merge 1 commit into from

Conversation

adamaveray
Copy link
Contributor

A follow-up to #2246, removing some new imports that are causing tsc errors when the library is used in a project with --noUnusedLocals enabled.

Some example error output from `tsc`
node_modules/@reduxjs/toolkit/src/query/core/buildInitiate.ts:8:1 - error TS6192: All imports in import declaration are unused.

8 import { DefinitionType, isQueryDefinition } from '../endpointDefinitions'
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@reduxjs/toolkit/src/query/core/buildInitiate.ts:11:36 - error TS6196: 'RootState' is declared but never used.

11 import type { SubscriptionOptions, RootState } from './apiState'

[...]

@codesandbox
Copy link

codesandbox bot commented May 28, 2023

CodeSandbox logoCodeSandbox logo  Open in CodeSandbox Web Editor | VS Code | VS Code Insiders | Preview

@codesandbox-ci
Copy link

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 7328234:

Sandbox Source
Vanilla Configuration
Vanilla Typescript Configuration
rsk-github-issues-example Configuration
@examples-query-react/basic Configuration
@examples-query-react/advanced Configuration
@examples-action-listener/counter Configuration

@netlify
Copy link

netlify bot commented May 28, 2023

Deploy Preview for redux-starter-kit-docs ready!

Name Link
🔨 Latest commit 7328234
🔍 Latest deploy log https://app.netlify.com/sites/redux-starter-kit-docs/deploys/64735e7308366d0008f2e2db
😎 Deploy Preview https://deploy-preview-3483--redux-starter-kit-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@adamaveray
Copy link
Contributor Author

An update: These errors are being caused by directly importing files from within @reduxjs/toolkit/src/..., which is being auto-imported by my IDE instead of those within dist. Ensuring all imports use the dist subdirectory instead of src correctly prevents tsc from flagging issues with this library (maybe it would be worth only shipping the dist subdirectory in the bundled module to prevent the source files being referenced instead of the proper dist versions).

@phryneas
Copy link
Member

It's a bit of a tradeoff - if we ship the source, people can accidentally import it (but it seems rather rare); if we don't, people can't directly look up source code. Especially since VSCode now supports to jump directly to the uncompiled source of a library (if it ships it), it's usually worth shipping the sources.

@markerikson
Copy link
Collaborator

Seems like this is an end-user linting issue?

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.

3 participants