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

Add types reference also to the exports part to fix #1629 #1632

Merged
merged 3 commits into from Jun 7, 2022

Conversation

ulrichb
Copy link
Contributor

@ulrichb ulrichb commented May 30, 2022

Description / Type of change

Bugfix for #1629

See https://www.typescriptlang.org/docs/handbook/esm-node.html#packagejson-exports-imports-and-self-referencing for the TypeScript docs of the used exports change.

Note that I didn't change the "./types" exports entry because this seems to be only a workaround for some ESLint error, see 8ddeba2.

How Has This Been Tested?

When running npx tsc -p . in the repro sample (see #1629 (comment)) before the fix:

$npx tsc -p .
test.ts:1:27 - error TS7016: Could not find a declaration file for module 'telegraf'. 'C:/_work/3rdP/telegraf/lib/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/telegraf` if it exists or add a new declaration (.d.ts) file containing `declare module 'telegraf';`

1 import * as telegraf from "telegraf"
                            ~~~~~~~~~~


Found 1 error in test.ts:1

... and after the fix it compiles fine.

Checklist:

  • I have performed a self-review of my own code
  • n/a I have made corresponding changes to the documentation
  • n/a My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
    • Nope only a manual test, see above

@MKRhere
Copy link
Member

MKRhere commented May 31, 2022

Does this continue working with current target modules that are not Node16 / NodeNext? And does this increase required TS version to 4.7.2? If so, is there a backwards-compatible way to make this change?

@ulrichb
Copy link
Contributor Author

ulrichb commented May 31, 2022

@MKRhere Very good question! As I've understood the docs, in "module": "commonjs" mode the exports field isn't used at all (instead the "older" top-level main and types is used). And therefore it should be backwards compatible.

But to go 100% sure, I've tested this PR change also with "module": "commonjs" with TS 3.9, 4.2, and 4.7 and it works fine 🙌.

Copy link
Member

@wojpawlik wojpawlik left a comment

Choose a reason for hiding this comment

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

Consider adding "./scenes".

package.json Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
ulrichb and others added 2 commits June 4, 2022 23:12
Co-authored-by: Wojciech Pawlik <woj.pawlik@gmail.com>
Signed-off-by: Muthu Kumar <muthukumar@thefeathers.in>
@MKRhere
Copy link
Member

MKRhere commented Jun 7, 2022

I didn't change the "./types" exports

Hope you don't mind that I went ahead and added this so we can unblock the PR. Thanks for the effort, cheers!

@MKRhere MKRhere merged commit dbf5dbb into telegraf:v4 Jun 7, 2022
@ulrichb
Copy link
Contributor Author

ulrichb commented Jun 7, 2022

@MKRhere Many thanks!

@ulrichb ulrichb deleted the Fix1629 branch June 7, 2022 21:50
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.

None yet

3 participants