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

Fix type errors in i18n #3027

Closed
tmarkley opened this issue Dec 4, 2022 · 8 comments · Fixed by #3629
Closed

Fix type errors in i18n #3027

tmarkley opened this issue Dec 4, 2022 · 8 comments · Fixed by #3629
Labels
good first issue Good for newcomers help wanted Community development is encouraged technical debt If not paid, jeapardizes long-term success and maintainability of the repository. typescript

Comments

@tmarkley
Copy link
Contributor

tmarkley commented Dec 4, 2022

Task for #1660

(inherited from previous project)

$tsc --noEmit
...

src/dev/i18n/utils/verify_icu_message.ts:43:15 - error TS2351: This expression is not constructable.
  Type 'Error' has no construct signatures.

43     throw new parser.SyntaxError(
                 ~~~~~~~~~~~~~~~~~~

src/dev/i18n/utils/verify_icu_message.ts:54:19 - error TS2351: This expression is not constructable.
  Type 'Error' has no construct signatures.

54         throw new parser.SyntaxError(
                     ~~~~~~~~~~~~~~~~~~

src/dev/run_i18n_check.ts:92:23 - error TS2322: Type 'Listr<{ reporter: ErrorReporter; }>' is not assignable to type 'void | ListrTaskResult<{ config: I18nConfig; }>'.
  Type 'Listr<{ reporter: ErrorReporter; }>' is not assignable to type 'Listr<{ config: I18nConfig; }>'.
    Types of property 'tasks' are incompatible.
      Type 'readonly ListrTaskWrapper<{ reporter: ErrorReporter; }>[]' is not assignable to type 'readonly ListrTaskWrapper<{ config: I18nConfig; }>[]'.
        Type 'ListrTaskWrapper<{ reporter: ErrorReporter; }>' is not assignable to type 'ListrTaskWrapper<{ config: I18nConfig; }>'.
          Type '{ reporter: ErrorReporter; }' is not assignable to type '{ config: I18nConfig; }'.

92           task: () => new Listr(checkConfigs(includeConfig), { exitOnError: true }),
                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  node_modules/@types/listr/index.d.ts:33:15
    33         task: (ctx: Ctx, task: ListrTaskWrapper<Ctx>) => void | ListrTaskResult<Ctx>;
                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    The expected type comes from the return type of this signature.
  src/dev/run_i18n_check.ts:92:17
    92           task: () => new Listr(checkConfigs(includeConfig), { exitOnError: true }),
                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Did you mean to mark this function as 'async'?

src/dev/run_i18n_check.ts:96:23 - error TS2322: Type 'Listr<{ reporter: ErrorReporter; config?: I18nConfig | undefined; }>' is not assignable to type 'void | ListrTaskResult<{ config: I18nConfig; }>'.
  Type 'Listr<{ reporter: ErrorReporter; config?: I18nConfig | undefined; }>' is not assignable to type 'Listr<{ config: I18nConfig; }>'.
    Types of property 'tasks' are incompatible.
      Type 'readonly ListrTaskWrapper<{ reporter: ErrorReporter; config?: I18nConfig | undefined; }>[]' is not assignable to type 'readonly ListrTaskWrapper<{ config: I18nConfig; }>[]'.
        Type 'ListrTaskWrapper<{ reporter: ErrorReporter; config?: I18nConfig | undefined; }>' is not assignable to type 'ListrTaskWrapper<{ config: I18nConfig; }>'.
          Type '{ reporter: ErrorReporter; config?: I18nConfig | undefined; }' is not assignable to type '{ config: I18nConfig; }'.

96           task: () => new Listr(mergeConfigs(includeConfig), { exitOnError: true }),
                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  node_modules/@types/listr/index.d.ts:33:15
    33         task: (ctx: Ctx, task: ListrTaskWrapper<Ctx>) => void | ListrTaskResult<Ctx>;
                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    The expected type comes from the return type of this signature.
  src/dev/run_i18n_check.ts:96:17
    96           task: () => new Listr(mergeConfigs(includeConfig), { exitOnError: true }),
                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Did you mean to mark this function as 'async'?

src/dev/run_i18n_check.ts:103:13 - error TS2322: Type 'Listr<{ reporter: ErrorReporter; config: I18nConfig; }>' is not assignable to type 'void | ListrTaskResult<{ config: I18nConfig; }>'.
  Type 'Listr<{ reporter: ErrorReporter; config: I18nConfig; }>' is not assignable to type 'Listr<{ config: I18nConfig; }>'.
    Types of property 'setRenderer' are incompatible.
      Type '(value: ListrRendererValue<{ reporter: ErrorReporter; config: I18nConfig; }>) => void' is not assignable to type '(value: ListrRendererValue<{ config: I18nConfig; }>) => void'.
        Types of parameters 'value' and 'value' are incompatible.
          Type 'ListrRendererValue<{ config: I18nConfig; }>' is not assignable to type 'ListrRendererValue<{ reporter: ErrorReporter; config: I18nConfig; }>'.
            Type 'ListrRendererClass<{ config: I18nConfig; }>' is not assignable to type 'ListrRendererValue<{ reporter: ErrorReporter; config: I18nConfig; }>'.
              Type 'ListrRendererClass<{ config: I18nConfig; }>' is not assignable to type 'ListrRendererClass<{ reporter: ErrorReporter; config: I18nConfig; }>'.
                Types of parameters 'tasks' and 'tasks' are incompatible.
                  Type 'readonly ListrTaskObject<{ reporter: ErrorReporter; config: I18nConfig; }>[]' is not assignable to type 'readonly ListrTaskObject<{ config: I18nConfig; }>[]'.
                    Type 'ListrTaskObject<{ reporter: ErrorReporter; config: I18nConfig; }>' is not assignable to type 'ListrTaskObject<{ config: I18nConfig; }>'.
                      Types of property 'task' are incompatible.
                        Type '(ctx: { reporter: ErrorReporter; config: I18nConfig; }, task: ListrTaskWrapper<{ reporter: ErrorReporter; config: I18nConfig; }>) => void | ListrTaskResult<{ reporter: ErrorReporter; config: I18nConfig; }>' is not assignable to type '(ctx: { config: I18nConfig; }, task: ListrTaskWrapper<{ config: I18nConfig; }>) => void | ListrTaskResult<{ config: I18nConfig; }>'.
                          Types of parameters 'ctx' and 'ctx' are incompatible.
                            Type '{ config: I18nConfig; }' is not assignable to type '{ reporter: ErrorReporter; config: I18nConfig; }'.

103             new Listr(extractUntrackedMessages(srcPaths), { exitOnError: true }),
                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  node_modules/@types/listr/index.d.ts:33:15
    33         task: (ctx: Ctx, task: ListrTaskWrapper<Ctx>) => void | ListrTaskResult<Ctx>;
                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    The expected type comes from the return type of this signature.
  src/dev/run_i18n_check.ts:102:17
    102           task: ({ config }) =>
                        ~~~~~~~~~~~~~~~
    103             new Listr(extractUntrackedMessages(srcPaths), { exitOnError: true }),
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Did you mean to mark this function as 'async'?

src/dev/run_i18n_check.ts:109:13 - error TS2322: Type 'Listr<{ messages: Map<string, { message: string; }>; reporter: ErrorReporter; }>' is not assignable to type 'void | ListrTaskResult<{ config: I18nConfig; }>'.
  Type 'Listr<{ messages: Map<string, { message: string; }>; reporter: ErrorReporter; }>' is not assignable to type 'Listr<{ config: I18nConfig; }>'.
    Types of property 'tasks' are incompatible.
      Type 'readonly ListrTaskWrapper<{ messages: Map<string, { message: string; }>; reporter: ErrorReporter; }>[]' is not assignable to type 'readonly ListrTaskWrapper<{ config: I18nConfig; }>[]'.
        Type 'ListrTaskWrapper<{ messages: Map<string, { message: string; }>; reporter: ErrorReporter; }>' is not assignable to type 'ListrTaskWrapper<{ config: I18nConfig; }>'.
          Type '{ messages: Map<string, { message: string; }>; reporter: ErrorReporter; }' is not assignable to type '{ config: I18nConfig; }'.

109             new Listr(extractDefaultMessages(config, srcPaths), { exitOnError: true }),
                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  node_modules/@types/listr/index.d.ts:33:15
    33         task: (ctx: Ctx, task: ListrTaskWrapper<Ctx>) => void | ListrTaskResult<Ctx>;
                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    The expected type comes from the return type of this signature.
  src/dev/run_i18n_check.ts:108:17
    108           task: ({ config }) =>
                        ~~~~~~~~~~~~~~~
    109             new Listr(extractDefaultMessages(config, srcPaths), { exitOnError: true }),
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Did you mean to mark this function as 'async'?

src/dev/run_i18n_check.ts:115:13 - error TS2322: Type 'Listr<{ messages: Map<string, { message: string; }>; }>' is not assignable to type 'void | ListrTaskResult<{ config: I18nConfig; }>'.
  Type 'Listr<{ messages: Map<string, { message: string; }>; }>' is not assignable to type 'Listr<{ config: I18nConfig; }>'.
    Types of property 'tasks' are incompatible.
      Type 'readonly ListrTaskWrapper<{ messages: Map<string, { message: string; }>; }>[]' is not assignable to type 'readonly ListrTaskWrapper<{ config: I18nConfig; }>[]'.
        Type 'ListrTaskWrapper<{ messages: Map<string, { message: string; }>; }>' is not assignable to type 'ListrTaskWrapper<{ config: I18nConfig; }>'.
          Type '{ messages: Map<string, { message: string; }>; }' is not assignable to type '{ config: I18nConfig; }'.

115             new Listr(
                ~~~~~~~~~~
116               checkCompatibility(
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
... 
127               { exitOnError: true }
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
128             ),
    ~~~~~~~~~~~~~

  node_modules/@types/listr/index.d.ts:33:15
    33         task: (ctx: Ctx, task: ListrTaskWrapper<Ctx>) => void | ListrTaskResult<Ctx>;
                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    The expected type comes from the return type of this signature.
  src/dev/run_i18n_check.ts:114:17
    114           task: ({ config }) =>
                        ~~~~~~~~~~~~~~~
    115             new Listr(
        ~~~~~~~~~~~~~~~~~~~~~~
    ... 
    127               { exitOnError: true }
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    128             ),
        ~~~~~~~~~~~~~
    Did you mean to mark this function as 'async'?

src/dev/run_i18n_check.ts:140:24 - error TS2345: Argument of type '{ messages: Map<string, { message: string; }>; reporter: any; }' is not assignable to parameter of type '{ config: I18nConfig; }'.
  Object literal may only specify known properties, and 'messages' does not exist in type '{ config: I18nConfig; }'.

140       await list.run({ messages, reporter });
                           ~~~~~~~~

src/dev/run_i18n_extract.ts:62:18 - error TS2769: No overload matches this call.
  Overload 1 of 2, '(tasks?: readonly ListrTask<{ reporter: ErrorReporter; config?: I18nConfig | undefined; }>[] | undefined, options?: ListrOptions<{ reporter: ErrorReporter; config?: I18nConfig | undefined; }> | undefined): Listr<...>', gave the following error.
    Type 'Listr<{ messages: Map<string, { message: string; }>; reporter: ErrorReporter; }>' is not assignable to type 'void | ListrTaskResult<{ reporter: ErrorReporter; config?: I18nConfig | undefined; }>'.
      Type 'Listr<{ messages: Map<string, { message: string; }>; reporter: ErrorReporter; }>' is not assignable to type 'Listr<{ reporter: ErrorReporter; config?: I18nConfig | undefined; }>'.
        Types of property 'setRenderer' are incompatible.
          Type '(value: ListrRendererValue<{ messages: Map<string, { message: string; }>; reporter: ErrorReporter; }>) => void' is not assignable to type '(value: ListrRendererValue<{ reporter: ErrorReporter; config?: I18nConfig | undefined; }>) => void'.
            Types of parameters 'value' and 'value' are incompatible.
              Type 'ListrRendererValue<{ reporter: ErrorReporter; config?: I18nConfig | undefined; }>' is not assignable to type 'ListrRendererValue<{ messages: Map<string, { message: string; }>; reporter: ErrorReporter; }>'.
                Type 'ListrRendererClass<{ reporter: ErrorReporter; config?: I18nConfig | undefined; }>' is not assignable to type 'ListrRendererValue<{ messages: Map<string, { message: string; }>; reporter: ErrorReporter; }>'.
                  Type 'ListrRendererClass<{ reporter: ErrorReporter; config?: I18nConfig | undefined; }>' is not assignable to type 'ListrRendererClass<{ messages: Map<string, { message: string; }>; reporter: ErrorReporter; }>'.
                    Types of parameters 'tasks' and 'tasks' are incompatible.
                      Type 'readonly ListrTaskObject<{ messages: Map<string, { message: string; }>; reporter: ErrorReporter; }>[]' is not assignable to type 'readonly ListrTaskObject<{ reporter: ErrorReporter; config?: I18nConfig | undefined; }>[]'.
                        Type 'ListrTaskObject<{ messages: Map<string, { message: string; }>; reporter: ErrorReporter; }>' is not assignable to type 'ListrTaskObject<{ reporter: ErrorReporter; config?: I18nConfig | undefined; }>'.
                          Types of property 'task' are incompatible.
                            Type '(ctx: { messages: Map<string, { message: string; }>; reporter: ErrorReporter; }, task: ListrTaskWrapper<{ messages: Map<string, { message: string; }>; reporter: ErrorReporter; }>) => void | ListrTaskResult<...>' is not assignable to type '(ctx: { reporter: ErrorReporter; config?: I18nConfig | undefined; }, task: ListrTaskWrapper<{ reporter: ErrorReporter; config?: I18nConfig | undefined; }>) => void | ListrTaskResult<...>'.
                              Types of parameters 'ctx' and 'ctx' are incompatible.
                                Type '{ reporter: ErrorReporter; config?: I18nConfig | undefined; }' is not assignable to type '{ messages: Map<string, { message: string; }>; reporter: ErrorReporter; }'.
  Overload 2 of 2, '(options?: ListrOptions<any> | undefined): Listr<any>', gave the following error.
    Type '({ title: string; task: () => Listr<{ reporter: ErrorReporter; config?: I18nConfig | undefined; }>; } | { title: string; task: ({ config }: { reporter: ErrorReporter; config?: I18nConfig | undefined; }) => Listr<...>; } | { ...; })[]' has no properties in common with type 'ListrOptions<any>'.

 62     const list = new Listr([
                     ~~~~~~~~~~~
 63       {
    ~~~~~~~
... 
 86       },
    ~~~~~~~~
 87     ]);
    ~~~~~~

  node_modules/@types/listr/index.d.ts:33:15
    33         task: (ctx: Ctx, task: ListrTaskWrapper<Ctx>) => void | ListrTaskResult<Ctx>;
                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    The expected type comes from the return type of this signature.
  src/dev/run_i18n_extract.ts:69:15
    69         task: ({ config }) =>
                     ~~~~~~~~~~~~~~~
    70           new Listr(extractDefaultMessages(config, srcPaths), { exitOnError: true }),
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Did you mean to mark this function as 'async'?

src/dev/run_i18n_extract.ts:70:44 - error TS2345: Argument of type 'I18nConfig | undefined' is not assignable to parameter of type 'I18nConfig'.
  Type 'undefined' is not assignable to type 'I18nConfig'.

70           new Listr(extractDefaultMessages(config, srcPaths), { exitOnError: true }),
                                              ~~~~~~

src/dev/run_i18n_extract.ts:74:44 - error TS2339: Property 'messages' does not exist on type '{ reporter: ErrorReporter; config?: I18nConfig | undefined; }'.

74         enabled: (ctx) => outputDir && ctx.messages.size,
                                              ~~~~~~~~

src/dev/run_i18n_extract.ts:76:42 - error TS2339: Property 'messages' does not exist on type '{ reporter: ErrorReporter; config?: I18nConfig | undefined; }'.

76           const sortedMessages = [...ctx.messages].sort(([key1], [key2]) =>
                                            ~~~~~~~~

src/dev/run_i18n_extract.ts:92:24 - error TS2345: Argument of type '{ messages: Map<string, { message: string; }>; reporter: any; }' is not assignable to parameter of type '{ reporter: ErrorReporter; config?: I18nConfig | undefined; }'.
  Object literal may only specify known properties, and 'messages' does not exist in type '{ reporter: ErrorReporter; config?: I18nConfig | undefined; }'.

92       await list.run({ messages, reporter });
                          ~~~~~~~~

src/dev/run_i18n_integrate.ts:93:18 - error TS2769: No overload matches this call.
  Overload 1 of 2, '(tasks?: readonly ListrTask<{ reporter: ErrorReporter; config?: I18nConfig | undefined; }>[] | undefined, options?: ListrOptions<{ reporter: ErrorReporter; config?: I18nConfig | undefined; }> | undefined): Listr<...>', gave the following error.
    Type 'Listr<{ messages: Map<string, { message: string; }>; reporter: ErrorReporter; }>' is not assignable to type 'void | ListrTaskResult<{ reporter: ErrorReporter; config?: I18nConfig | undefined; }>'.
  Overload 2 of 2, '(options?: ListrOptions<any> | undefined): Listr<any>', gave the following error.
    Type '({ title: string; task: () => Listr<{ reporter: ErrorReporter; config?: I18nConfig | undefined; }>; } | { title: string; task: ({ config }: { reporter: ErrorReporter; config?: I18nConfig | undefined; }) => Listr<...>; } | { ...; })[]' has no properties in common with type 'ListrOptions<any>'.

 93     const list = new Listr([
                     ~~~~~~~~~~~
 94       {
    ~~~~~~~
... 
118       },
    ~~~~~~~~
119     ]);
    ~~~~~~

  node_modules/@types/listr/index.d.ts:33:15
    33         task: (ctx: Ctx, task: ListrTaskWrapper<Ctx>) => void | ListrTaskResult<Ctx>;
                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    The expected type comes from the return type of this signature.
  src/dev/run_i18n_integrate.ts:100:15
    100         task: ({ config }) =>
                      ~~~~~~~~~~~~~~~
    101           new Listr(extractDefaultMessages(config, srcPaths), { exitOnError: true }),
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Did you mean to mark this function as 'async'?

src/dev/run_i18n_integrate.ts:101:44 - error TS2345: Argument of type 'I18nConfig | undefined' is not assignable to parameter of type 'I18nConfig'.
  Type 'undefined' is not assignable to type 'I18nConfig'.

101           new Listr(extractDefaultMessages(config, srcPaths), { exitOnError: true }),
                                               ~~~~~~

src/dev/run_i18n_integrate.ts:105:24 - error TS2339: Property 'messages' does not exist on type '{ reporter: ErrorReporter; config?: I18nConfig | undefined; }'.

105         task: async ({ messages, config }) => {
                           ~~~~~~~~

src/dev/run_i18n_integrate.ts:114:13 - error TS2322: Type 'I18nConfig | undefined' is not assignable to type 'I18nConfig'.
  Type 'undefined' is not assignable to type 'I18nConfig'.

114             config,
                ~~~~~~

  src/dev/i18n/integrate_locale_files.ts:59:3
    59   config: I18nConfig;
         ~~~~~~
    The expected type comes from property 'config' which is declared here on type 'IntegrateOptions'

src/dev/run_i18n_integrate.ts:124:24 - error TS2345: Argument of type '{ messages: Map<string, { message: string; }>; reporter: any; }' is not assignable to parameter of type '{ reporter: ErrorReporter; config?: I18nConfig | undefined; }'.
  Object literal may only specify known properties, and 'messages' does not exist in type '{ reporter: ErrorReporter; config?: I18nConfig | undefined; }'.

124       await list.run({ messages, reporter });


@joshuarrrr joshuarrrr added untriaged help wanted Community development is encouraged technical debt If not paid, jeapardizes long-term success and maintainability of the repository. typescript good first issue Good for newcomers and removed untriaged labels Dec 5, 2022
@ashwin-pc
Copy link
Member

ashwin-pc commented Mar 9, 2023

The issue here seems to be just a case of bad typing. Listr is a npm library that renders lists in the terminal that lets the user know about the status of the task (pending, successful, failed). To do this it can accept a context value when intialized or during execution that can be used by the task to correctly report the status. Whats happened here is that we dont declare the context type when we create the list like new Listr<ListrContext>.

In this particular file the context has 3 values:

export interface ListrContext {
  config?: I18nConfig;
  reporter: ErrorReporter;
  messages: Map<string, { message: string }>;
}

setting the type of the context for each of the helper functions and the list itself should resolve this issue: e.g.

    const list = new Listr<ListrContext>(
  return configPaths.map((configPath) => ({
    task: async (context: ListrContext) => {
      try {

@Nicksqain
Copy link
Contributor

Nicksqain commented Mar 10, 2023

Did I get that right?

  • handling the lack of a configuration
    e.g
    изображение

@Nicksqain
Copy link
Contributor

Also, when fixing it, I found that the error instance is split into several lines, which is not allowed for Error. parser.SyntaxError itself is not callable, it is just described by the Error interface.
I suggest a few solutions:

  1. combine the error output into a single template string ${}.
  2. add a really custom SyntaxError, so that we can output

But a question: Where can I create a class
SyntaxError extends Error?
So that it can be imported into a .d.ts file and used

node_modules\intl-messageformat-parser
Can you tell me what needs to be in these folders: dist | lib | src

изображение
изображение

@ashwin-pc
Copy link
Member

Did I get that right?

  • handling the lack of a configuration
    e.g
    изображение

Yes, but a few comments:

  1. If the task isnt async, dont add async now. None of these tasks need to be async.
  2. Move the config check into the extractUntrackedMessages function. All the helper functions right now use the wrong type for context which is showing up in this file. They need to be updated with the correct context type, whicj will remove the errors in src/dev/run_i18n_check.ts

@ashwin-pc
Copy link
Member

Also, when fixing it, I found that the error instance is split into several lines, which is not allowed for Error. parser.SyntaxError itself is not callable, it is just described by the Error interface. I suggest a few solutions:

  1. combine the error output into a single template string ${}.
  2. add a really custom SyntaxError, so that we can output

But a question: Where can I create a class SyntaxError extends Error? So that it can be imported into a .d.ts file and used

node_modules\intl-messageformat-parser Can you tell me what needs to be in these folders: dist | lib | src

изображение изображение

Which file is this in?

@Nicksqain
Copy link
Contributor

Also, when fixing it, I found that the error instance is split into several lines, which is not allowed for Error. parser.SyntaxError itself is not callable, it is just described by the Error interface. I suggest a few solutions:

  1. combine the error output into a single template string ${}.
  2. add a really custom SyntaxError, so that we can output

But a question: Where can I create a class SyntaxError extends Error? So that it can be imported into a .d.ts file and used
node_modules\intl-messageformat-parser Can you tell me what needs to be in these folders: dist | lib | src
изображение изображение

Which file is this in?

src\dev\i18n\utils\verify_icu_message.ts

@Nicksqain
Copy link
Contributor

Did I get that right?

  • handling the lack of a configuration
    e.g
    изображение

Yes, but a few comments:

1. If the task isnt async, dont add async now. None of these tasks need to be async.

2. Move the config check into the `extractUntrackedMessages` function. All the helper functions right now use the wrong type for context which is showing up in this file. They need to be updated with the correct context type, whicj will remove the errors in `src/dev/run_i18n_check.ts`

I have no idea yet, because the function itself is asynchronous. But I was only able to rewrite it into the callback
изображение

@ashwin-pc
Copy link
Member

Hmm, I see your point. Looks like each of these errors have to be handled separately.

  1. For parser.SyntaxError in src/dev/i18n/utils/verify_icu_message.ts. The package has been deprecated, so we need to update it to https://www.npmjs.com/package/@formatjs/icu-messageformat-parser. I would not club that upgrade with this issue. Can you create a new issue for that and link it to this issue?
  2. For the src/dev/run_i18n_check.ts errors. Its fine if the function is already asynchronous, but by defining the function as async, you are changing the type signature. Unfortunately, the task property allows for the type Promise<any>. This means that when you add async to the function, even if there is a type mismatch (because the context type is wrong), it is ignored because it matches the Promise<any> type. So the better option is not to change the function, but just add the correct types like I outlined here: Fix type errors in i18n #3027 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Community development is encouraged technical debt If not paid, jeapardizes long-term success and maintainability of the repository. typescript
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants