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

Property 'change' in type 'Toggle' is not assignable to the same property in base type 'Checkbox'. #1343

Closed
huineng opened this issue Jun 14, 2020 · 6 comments · Fixed by #1647
Assignees
Labels
bug Something isn't working component: Checkbox For Checkbox issues component: Toggle For Toggle issues released on @latest
Projects

Comments

@huineng
Copy link

huineng commented Jun 14, 2020

Typescript error

angular 10
typescript : 3.9.5
carbon: 10.13.0

Detailed description

ERROR in node_modules/carbon-components-angular/toggle/toggle.component.d.ts:96:5 - 
error TS2416: Property 'change' in type 'Toggle' is not assignable to the same property 
in base type 'Checkbox'.
@cal-smith cal-smith added bug Something isn't working component: Checkbox For Checkbox issues component: Toggle For Toggle issues labels Jun 22, 2020
@huineng
Copy link
Author

huineng commented Aug 24, 2020

some more details

./node_modules/carbon-components-angular/toggle/toggle.component.d.ts:95:5 
    TS2416: Property 'change' in type 'Toggle' is not assignable to the same property in base type 'Checkbox'.
  Type 'EventEmitter<ToggleChange>' is not assignable to type 'EventEmitter<CheckboxChange>'.
    Types of property 'observers' are incompatible.
      Type 'Observer<ToggleChange>[]' is not assignable to type 'Observer<CheckboxChange>[]'.
        Type 'Observer<ToggleChange>' is not assignable to type 'Observer<CheckboxChange>'.
          Type 'CheckboxChange' is not assignable to type 'ToggleChange'.

@WilliamMilne
Copy link

@cal-smith this is the issue that we're experiencing. Do you think downgrading to an older version might help? I feel like I saw something about that fixing an issue with Angular 10?

Thanks again for all of your help!

@mattgills
Copy link

@cal-smith @WilliamMilne It looks like this was more of a TypeScript error. Our previous tsconfig.json was

{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "importHelpers": true,
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "module": "es2020",
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "strict": true,
    "strictPropertyInitialization": false,
    "allowSyntheticDefaultImports": true,
    "target": "es2015",
    "typeRoots": ["node_modules/@types"],
    "lib": ["es2017", "dom", "esnext.asynciterable"]
  }
}

We needed to add the following line to compilerOptions:

"strictFunctionTypes": false,

I worked off this response in a TypeScript issue thread.

@cal-smith cal-smith removed the Hacktoberfest The smell of pumpkin and hacking is in the air! label Nov 4, 2020
@cal-smith
Copy link
Contributor

Ah interesting 🤔 I think the issue we're having may come from how we're doing inheritance in this case, and the base types not being generic enough. I think the full solution here would be to fully decouple Checkbox and Toggle so we don't end up with these weird types

We might be able to introduce a generic base class that keeps the shared sections, though I'm not sure how much of there there is.

@cal-smith cal-smith added this to ToDos in Q4 - 2020 via automation Nov 6, 2020
@cal-smith cal-smith removed this from ToDos in Q4 - 2020 Jan 6, 2021
@cal-smith cal-smith added this to ToDos in Q1-2021 Jan 6, 2021
@cal-smith cal-smith self-assigned this Jan 6, 2021
@cal-smith cal-smith moved this from ToDos to In progress in Q1-2021 Jan 6, 2021
Q1-2021 automation moved this from In progress to Closed Jan 6, 2021
@carbon-bot
Copy link
Contributor

🎉 This issue has been resolved in version 4.34.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@huineng
Copy link
Author

huineng commented Jan 7, 2021

great !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working component: Checkbox For Checkbox issues component: Toggle For Toggle issues released on @latest
Projects
No open projects
Q1-2021
Closed
Development

Successfully merging a pull request may close this issue.

5 participants