-
Notifications
You must be signed in to change notification settings - Fork 16
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
[1.1.0] TS2345: Argument of type 'any' is not assignable to parameter of type 'never' #16
Comments
anyone willing to help? I'm bad at TS and I wished latest changes would do the right thing ... apparently that wasn't the case ... if putting back |
@WebReflection I don't see a reason why not using |
@andrew-pyle as we introduced a regression here ... do you have any idea what should be done to fix it? I am tempted to add |
Since I created on the Typescript definitions in @efstathiosntonas @WebReflection The Structured Clone Algorithm cannot actually accept The type definitions in That said, the built-in Typescript DOM lib types // lib.dom.d.ts
declare function structuredClone(value: any, options?: StructuredSerializeOptions): any; |
Now about the bug. @efstathiosntonas Does your I'm not the most experienced This is because the accepted types union includes |
@efstathiosntonas I am actually having trouble reproducing the error today, although I've seen it before. Could you share a minimal example which exhibits the error? Maybe a link to https://www.typescriptlang.org/play? |
that kinda seals the deal to me ... as types are useful only for TS users so any less friction in using this library might e desirable? I kinda like that types in here are spcific for what the module exposes but at the same time I wonder if those types are harder to deal with when the source is actually unknown ... would it make sense to add |
@WebReflection I agree that creating a more specific type leaves us with more potential for friction in using the package. So I'd be OK with using any. But I think having the types reflect the limitations of the module would be best, if you think it's worth the work. The drawback for |
that's what I wanted to avoid ... but how would one narrow down the type then? would an export of |
@WebReflection I'm not sure I am following your thought. Sorry! Are you are thinking of the return type for // index.d.ts
export default function <T extends any>(
any: T,
options?: {
transfer: Transferable[]; // Standard
json: boolean; // Nonstandard
lossy: boolean; // Nonstandard
}
): T;
// app.ts
const s = 'this is a test';
const clone: string = structuredClone(s);
// All good. clone is of type string
// Or more complex
type AppType = { id: number; date: Date; data: string }
const appData: AppType = { id: 25, date: new Date(), data: "data" }
const clone: AppType = structuredClone(appData);
// All good. clone is of type AppType |
@andrew-pyle that also seems to work nicely ... doesn't it? |
@WebReflection It would work well, I think. The only issue is that TS would accept arguments which aren't supported by the underlying JS implementation: Blob, File, FileList, etc. from the README. No red squiggles for the unsupported arguments. |
@andrew-pyle it’s an Apollo cache query and the Tomorrow I’ll create a codesandbox with a minimal repro. This is the query just to get an idea: const messages = client.readQuery({
query: GetChatChannelMessagesDocument,
variables: {
chat_channel_id: channelId
}
}); |
honestly I don't care ... the README documentation when the polyfill is used is clear and I can't spend every day here addressing every single person that uses export type Cloneable = Exclude<any, NotSupportedYet>; ??? |
OK, for the time being I have rolled back to |
@WebReflection You are right—I don't think there is a way to have a "not" type.
Just had this thought: Maybe you'd prefer to spin the types out of your repository entirely, and have them go into the DefinitelyTyped repository for third-party type definitions? The type definitions here are just Type definitions on DefinitelyTyped repository can release independently of this module, so it would reduce your responsibility, too. What do you think? |
I have zero time for this ... already spent more than needed and not a single improvement landed in this project, only regressions, so I'll keep it as is and if anyone wants to submit in that repo I'd be more than happy but that person won't be me because so far all this story gave me only troubles ... 2 issues filed after something that supposed to be better? not my cup of tea, sorry. the other issue #17 |
@WebReflection I just looked at @types/ungap__structured_clone on NPM. Looks like I owe you an apology. There are already third-party types for your module on DefinitelyTyped. 🥴. I should have checked there before contributing the type definitions here. I can submit a PR removing the |
After upgrading to
1.1.0
it throws this error:TS2345: Argument of type 'any' is not assignable to parameter of type 'never'
On previous versions it worked just fine. Casting with
as
does not fix it.The text was updated successfully, but these errors were encountered: