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

Typescript - Support const modifier for options and key #2007

Merged
merged 2 commits into from Jul 29, 2023

Conversation

pedrodurek
Copy link
Member

Closes #1929, #1950

Checklist

  • only relevant code is changed (make a diff before you submit the PR)
  • run tests npm run test
  • tests are included
  • commit message and code follows the Developer's Certification of Origin

Checklist (for documentation change)

  • only relevant documentation part is changed (make a diff before you submit the PR)
  • motivation/reason is provided
  • commit message and code follows the Developer's Certification of Origin

@coveralls
Copy link

Coverage Status

coverage: 92.36%. remained the same when pulling 046b7a0 on pedrodurek:typescript/support-const into 549ada8 on i18next:master.

@pedrodurek
Copy link
Member Author

Hey @adrai, in order to support users with typescript 5+ and older versions, I had to place the types in different files, and now we have two versions of the types for t function (t.d.ts, t.v5.d.ts), please review carefully and let me know if you agree with how I split the resources and if you want me to make any changes.

@pedrodurek pedrodurek requested a review from adrai July 28, 2023 22:50
@adrai adrai merged commit 151ec0d into i18next:master Jul 29, 2023
5 checks passed
@adrai
Copy link
Member

adrai commented Jul 29, 2023

included in 23.4.0

@adrai adrai mentioned this pull request Jul 29, 2023
7 tasks
@efstathiosntonas
Copy link

Hey folks, after this change I get this:

TS2614: Module  "i18next"  has no exported member  TFunction . Did you mean to use  import TFunction from "i18next"  instead?

Screenshot 2023-07-29 at 12 00 20

@abhi-works
Copy link

@pedrodurek @adrai Facing below issues while building with "tsc" after this PR got approved.
node_modules/i18next/index.d.ts:2:34 - error TS2307: Cannot find module 'typescript/helpers' or its corresponding type declarations.

2 import type { $Dictionary } from 'typescript/helpers';
~~~~~~~~~~~~~~~~~~~~

node_modules/i18next/index.d.ts:14:8 - error TS2307: Cannot find module 'typescript/options' or its corresponding type declarations.

14 } from 'typescript/options';
~~~~~~~~~~~~~~~~~~~~

node_modules/i18next/index.d.ts:16:43 - error TS2307: Cannot find module 'typescript/t' or its corresponding type declarations.

16 import type { KeyPrefix, TFunction } from 'typescript/t';
~~~~~~~~~~~~~~

node_modules/i18next/index.d.ts:497:1 - error TS1383: Only named exports may use 'export type'.

497 export type * from 'typescript/options';
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/i18next/index.d.ts:497:20 - error TS2307: Cannot find module 'typescript/options' or its corresponding type declarations.

497 export type * from 'typescript/options';
~~~~~~~~~~~~~~~~~~~~

node_modules/i18next/index.d.ts:498:1 - error TS1383: Only named exports may use 'export type'.

498 export type * from 'typescript/t';
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/i18next/index.d.ts:498:20 - error TS2307: Cannot find module 'typescript/t' or its corresponding type declarations.

498 export type * from 'typescript/t';
~~~~~~~~~~~~~~

@adrai
Copy link
Member

adrai commented Jul 29, 2023

@efstathiosntonas @abhi-works sorry, please try with v23.4.1

@efstathiosntonas
Copy link

@adrai thanks, it works as a charm now.

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.

Utilize TypeScript 5.0 const Type Parameters
5 participants