Coder Social home page Coder Social logo

Comments (5)

jasomimo avatar jasomimo commented on June 16, 2024 1

Hi @MurhafSousli, I experienced same issue as @konradkurylo with "strictTemplates": true option in angularCompilerOptions, tsconfig.json.

I don't think there is a need to for a new pipe, but the highlight directive should already handle if the value is null, which is possible return value from async pipe.

In the ngOnChanges of highlight.ts, there is already check for currentValue !== null.

I believe @Input('highlight') code!: string; could be changed to @Input('highlight') code!: string | null; and that should fix the error and hopefully don't break anything.

I like you package and I'm happy to open PR, if you would agree with the change.

from ngx-highlightjs.

MurhafSousli avatar MurhafSousli commented on June 16, 2024 1

@jasomimo In this case, you need to remove the bang from the variable because it means the variable will not be null, as explained here

https://stackoverflow.com/questions/42273853/in-typescript-what-is-the-exclamation-mark-bang-operator-when-dereferenci

Try to verify if this fixes the issue or if other variables need to be updated the same way!

Thanks a lot!

from ngx-highlightjs.

MurhafSousli avatar MurhafSousli commented on June 16, 2024 1

Sorry for the late, v6.1.3 has been published! please let me know if the issue is fixed!

from ngx-highlightjs.

MurhafSousli avatar MurhafSousli commented on June 16, 2024

Please add reproduction here https://stackblitz.com/edit/ngx-highlightjs! You seem to have strict type template on your end.. I don't think there is a need for another pipe

from ngx-highlightjs.

jasomimo avatar jasomimo commented on June 16, 2024

@MurhafSousli I've updated highlight.ts to accept also null as valid value. I saw there is already a test for null value, so I didn't add a new one. Change is available for a review in PR: #225

I tested ngx-highlightjs with this change in my project, where I was previously getting error and the fix worked well.

Looking forward to the feedback, if this works for you.

from ngx-highlightjs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.