veliovgroup / flow-router

🚦 Carefully extended flow-router for Meteor
https://packosphere.com/ostrio/flow-router-extra
BSD 3-Clause "New" or "Revised" License
202 stars 29 forks source link

Errors in types.d.ts #97

Closed perbergland closed 8 months ago

perbergland commented 1 year ago

I'm having an issue:

.meteor/local/types/node_modules/package-types/ostrio_flow-router-extra/package/web.cordova/types.d.ts (5,62): String literal expected. .meteor/local/types/node_modules/package-types/ostrio_flow-router-extra/package/web.cordova/types.d.ts (16,7): Cannot find namespace 'Meteor'. .meteor/local/types/node_modules/package-types/ostrio_flow-router-extra/package/web.cordova/types.d.ts (17,7): Cannot find namespace 'Tracker'. .meteor/local/types/node_modules/package-types/ostrio_flow-router-extra/package/web.cordova/types.d.ts (18,13): Cannot find namespace 'Tracker'. .meteor/local/types/node_modules/package-types/ostrio_flow-router-extra/package/web.cordova/types.d.ts (20,37): Cannot find namespace 'Meteor'. .meteor/local/types/node_modules/package-types/ostrio_flow-router-extra/package/web.cordova/types.d.ts (30,48): Cannot find namespace 'Mongo'.

This line is syntactically incorrect:

type DynamicImport<T extends string> = Promise<typeof import(T)>;

Metor, Tracker and Mongo packages need to be imported

Here are manual modifications that make the compilation errors go away but the DynamicImport type function can probably not be implemented at all.

import { Meteor } from "meteor/meteor";
import { Mongo } from "meteor/mongo";
import { Tracker } from "meteor/tracker";

type Trigger = (context: ReturnType<Router["current"]>, redirect: Router["go"], stop: () => void, data: any) => void;

type TriggerFilterParam = { only: string[] } | { except: string[] };

// @ts-ignore
type DynamicImport<T extends string> = Promise<typeof import(T)>;
dr-dimitru commented 1 year ago

@perbergland would it get solved by adding Tracker and Mongo as {weak: true} dependencies?

dr-dimitru commented 1 year ago

@timsun28 would you be able to help with this one?

timsun28 commented 1 year ago

I believe I have solved both issues in this pr. I have added meteor types to flowrouter so they can be imported and it now recognizes them when using the package. I have also changed the DynamicImport to now only accept a string and solved the issue it was initially giving.

I hope this helps your problems!

dr-dimitru commented 1 year ago

@timsun28 @perbergland I left a comment in the PR

dr-dimitru commented 8 months ago

Should be solved in the latest release Feel free to reopen it in case if the issue is still persists on your end.