Code Monkey home page Code Monkey logo

Comments (3)

Princesseuh avatar Princesseuh commented on June 6, 2024

Astro.props isn't typed (well, it's Record<string, any>) if you don't use a Props interface or cast it. As such, it's no surprise that trying to cast the destructured value will make an error, this is not a bug.

I would recommend to use the official pattern for typing, instead:
https://docs.astro.build/en/guides/typescript/#component-props

from language-tools.

tisonkun avatar tisonkun commented on June 6, 2024

@Princesseuh Interesting. I have other similar code but TS compiler doesn't complain.

LIKE https://github.com/tisonkun/dacapo/blob/084616478eee12ee33d346e922a9fe3d8099062a/src/pages/posts/%5Bslug%5D.astro#L17

https://github.com/tisonkun/dacapo/blob/084616478eee12ee33d346e922a9fe3d8099062a/src/pages/tags/%5Btag%5D.astro#L26

https://github.com/tisonkun/dacapo/blob/084616478eee12ee33d346e922a9fe3d8099062a/src/pages/categories/%5Bcategory%5D.astro#L18

Seems all involves CollectionEntry.

from language-tools.

tisonkun avatar tisonkun commented on June 6, 2024

Anyway, I use interface Props { method and all works now :D

from language-tools.

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.