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

Toolbox: TypeScript throws compilation errors when adding a new toolbox subitem #5866

Closed
3 tasks
JaneSjs opened this issue Sep 9, 2024 · 0 comments · Fixed by #5871
Closed
3 tasks

Toolbox: TypeScript throws compilation errors when adding a new toolbox subitem #5866

JaneSjs opened this issue Sep 9, 2024 · 0 comments · Fixed by #5871
Assignees
Labels
bug user issue An issue or bug reported by users.
Milestone

Comments

@JaneSjs
Copy link
Contributor

JaneSjs commented Sep 9, 2024

T19740 - TS compilation errors for an IQuestionToolboxItem object passed to the addSubitem function
https://surveyjs.answerdesk.io/internal/ticket/details/T19740


creator-angular.zip

import { IQuestionToolboxItem } from "survey-creator-core";

const textItem: IQuestionToolboxItem = creator.toolbox.getItemByName("text");
const textItemConfig: IQuestionToolboxItem = {
        name: "postalCode",
        title: "Postcode",
        json: {
            type: "text",
            autocomplete: "postal-code",
            hideNumber: true,
            maxLength: 0,
            maskType: "pattern",
            maskSettings: {
                pattern: "9999 AA",
            },
            placeholder: "1234 AB",
        },
}

textItem.addSubitem(textItemConfig);

The following compilation errors occur:

  • ...is missing the following properties from type 'IQuestionToolboxItem': iconName, className
Error: src/app/survey-creator/survey-creator.component.ts:35:11 - error TS2739: Type '{ name: string; title: string; json: { type: string; autocomplete: string; hideNumber: boolean; maxLength: number; maskType: string; maskSettings: { pattern: string; }; placeholder: string; }; }' is missing the following properties from type 'IQuestionToolboxItem': iconName, className
  • An argument for 'index' was not provided.
 node_modules/survey-creator-core/typings/toolbox.d.ts:75:48
    75     addSubitem?(subitem: IQuestionToolboxItem, index: number): void;
                                                      ~~~~~~~~~~~~~
    An argument for 'index' was not provided.
  • Cannot invoke an object which is possibly 'undefined'
TS2722: Cannot invoke an object which is possibly 'undefined'.
@JaneSjs JaneSjs added bug user issue An issue or bug reported by users. labels Sep 9, 2024
OlgaLarina pushed a commit that referenced this issue Sep 10, 2024
OlgaLarina pushed a commit that referenced this issue Sep 10, 2024
@RomanTsukanov RomanTsukanov changed the title TS compilation errors when adding a new sub-item configuration using the addSubitem function Toolbox: TypeScript throws compilation errors when adding a new toolbox subitem Sep 10, 2024
@OlgaLarina OlgaLarina added this to the v1.12.1 milestone Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug user issue An issue or bug reported by users.
Projects
None yet
3 participants