Git Product home page Git Product logo

Comments (9)

marwie avatar marwie commented on May 25, 2024 2

We'll add a fix for this in the next update by supporting both the old and the new decorator syntax:

_propertyKey: string | { name: string }

a call to toString() in this case doesn't make sense since we need the decorated field/property name here. The new method argument (ClassFieldDecoratorContext) has that inside the name property so we have to properly handle both types and extract the information necessary.

That being said our package will continue using experimentalDecorators as long as it's officially supported by typescript to not break backwards compatibility - according to their announcement it won't be removed anytime soon.

from needle-engine-support.

marwie avatar marwie commented on May 25, 2024

Hey, which version of typescript are you using?

from needle-engine-support.

krisrok avatar krisrok commented on May 25, 2024

Oh is this a fault on my end only? Sorry, I'm new to this whole ecosystem.

Anyway, this is what i found:

> npm ls typscript
[email protected]
├─┬ @needle-tools/[email protected]
│ └─┬ @needle-tools/[email protected]
│   └── [email protected]
└── [email protected]

from needle-engine-support.

marwie avatar marwie commented on May 25, 2024

Thanks, I havent tested it with typescript 5 yet.

Can you try if changing the type to string | symbol works for you as well?
https://devblogs.microsoft.com/typescript/announcing-typescript-5-0/#more-accurate-type-checking-for-parameter-decorators-in-constructors-under-experimentaldecorators

from needle-engine-support.

krisrok avatar krisrok commented on May 25, 2024

Thanks, I havent tested it with typescript 5 yet.

Oh? That's what gets installed automatically using the exporter though? I did not (knowingly) deviate from the defaults.

Can you try if changing the type to string | symbol works for you as well? https://devblogs.microsoft.com/typescript/announcing-typescript-5-0/#more-accurate-type-checking-for-parameter-decorators-in-constructors-under-experimentaldecorators

Nope:
image

from needle-engine-support.

marwie avatar marwie commented on May 25, 2024

Ah sorry I wasnt aware that it was updated in the vite template. So that can't be it

What do you get when you change it to any to make typescript happy and if(typeof _propertyKey !== "string") console.log(typeof _propertyKey, _propertyKey) ?

from needle-engine-support.

krisrok avatar krisrok commented on May 25, 2024

Interesting: Does not log anything. I can set a breakpoint there and it hits (after un-ingoring the file). Is there some magic going on?

from needle-engine-support.

marwie avatar marwie commented on May 25, 2024

Ah you need to edit the file in lib/engine (the .js file) and not in src/engine

from needle-engine-support.

hybridherbst avatar hybridherbst commented on May 25, 2024

Looks like in TS5 this parameter is a ClassFieldDecoratorContext instead of a string. My understanding would be that there's different TS versions conflicting, one with a config of experimentalDecorators (like we're using, with the string parameter) and one without.

This issue would likely go away if we switch to TS5 entirely and drop support for experimentalDecorators, instead using the non-experimental ones with that context.

I'm not sure if we can use ClassFieldDecoratorContext as alternative type or if that's just not available in TS4, which would make it seem like "any" and casting to string is the right way for now...

image

Here are some decorator usage notes for TS5:
https://devblogs.microsoft.com/typescript/announcing-typescript-5-2-beta/#decorator-metadata

https://github.com/microsoft/TypeScript/blob/3ade5022d7f287fdaf61c9e6deed32a3ffb60bc4/src/lib/decorators.d.ts#L326

And the info in the PR that added it is much better than the current docs:
microsoft/TypeScript#50820

from needle-engine-support.

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.