Closed Magiczne closed 1 year ago
Probably related to https://github.com/primefaces/primevue/pull/3728
I have the same
Same thing happens for icons when using the constants described here
The problem currently is that with the current implementation, TypeScript applications expect you to use the enum FilterMatchModeOptions. However, this does not exist in the .js files. Using FilterMatchModeOptions will cause your build to fail.
Additionally, my solution in https://github.com/primefaces/primevue/pull/3728 was the correct one, but this was changed after it was merged.
Should be a simple quick fix to revert back to @JeffreyNijs solution which as far as I can tell is working perfectly.
To add this also means the docs are out of line with the implementation currently.
I had the same problem with filters after updating to version 3.25.0, had to install previous version 3.20.0 to get rid of this issue.
Thanks a lot for the reports! I made some changes in JeffreyNijs' fix. Setting a value for the interface
confused me a bit. So using the enum
seemed more correct. Of course, I hadn't noticed that the enum was set to a value below. Sorry for the confusion!
If ok for everyone, I can release a patch version asap.
If ok for everyone, I can release a patch version asap.
Yes all good!
In order to resolve the typing issue with the new version, I have to change my tsconfig because of this error:
error TS2748: Cannot access ambient const enums when the '--isolatedModules' flag is provided.
42 value: '', matchMode: FilterMatchMode.STARTS_WITH,
~~~~~~~~~~~~~~~
I am using the default Vite config, so isolatedModules
is false. Vite recommends using true but also it says in its docs:
However, some libraries (e.g. [vue](https://github.com/vuejs/core/issues/1228)) don't work well with "isolatedModules": true. You can use "skipLibCheck": true to temporarily suppress the errors until it is fixed upstream.
Yes, that should be the case. File that provides const enums should not be ambient, but all the types in the primevue are done manually in the ambient context. Probably the solution would be to use TS from the ground up, but that's probably not happenning.
Probably using normal enum is enough, as this is only ambient context informing of types, not actually exporting them. @mertsincan could you address this as well in this ticket, or should we make another one?
Thanks a lot for the update! I know but I made an edit based on the following usage; runtime-core.d.ts in Vue
// line 853
export declare const enum ErrorCodes {
SETUP_FUNCTION = 0,
RENDER_FUNCTION = 1,
WATCH_GETTER = 2,
WATCH_CALLBACK = 3,
WATCH_CLEANUP = 4,
NATIVE_EVENT_HANDLER = 5,
COMPONENT_EVENT_HANDLER = 6,
VNODE_HOOK = 7,
DIRECTIVE_HOOK = 8,
TRANSITION_HOOK = 9,
APP_ERROR_HANDLER = 10,
APP_WARN_HANDLER = 11,
FUNCTION_REF = 12,
ASYNC_COMPONENT_LOADER = 13,
SCHEDULER = 14
}
declare type ErrorTypes = LifecycleHooks | ErrorCodes;
There are many such uses in itself. I have no idea how to overcome this problem if we continue with enum for now. I guess the best way is to add the interface
and properties string
option that uses it. Exp;
...
export interface DataTableFilterMetaData {
/**
* Filter value
*/
value: any;
/**
* Filter match mode
*/
matchMode: string | 'startsWith' | 'contains' | 'notContains' | 'endsWith' | 'equals' | 'notEquals' | 'in' | 'lt' | 'lte' | 'gt' | 'gte' | 'between' | 'dateIs' | 'dateIsNot' | 'dateBefore' | 'dateAfter' | undefined;
}
..
export declare interface FilterMatchModeOptions {
STARTS_WITH: string;
...
}
export const FilterMatchMode: FilterMatchModeOptions;
...
WDYT?
Yea, vue have the same kind of problem with const enums.
Basically option https://github.com/primefaces/primevue/pull/3728/files was the working one, but since that, normal enum could be working correctly, it's an ambient context, so it's not gonna be imported int o the app - the .js
file will be.
Yea, vue have the same kind of problem with const enums.
Basically option https://github.com/primefaces/primevue/pull/3728/files was the working one, but since that, normal enum could be working correctly, it's an ambient context, so it's not gonna be imported int o the app - the
.js
file will be.
Can confirm, a const enum error persists in 3.26.0. Maybe make a new issue for this?
Yes. Issue exists with PrimeVue 3.26 and isolatedModules
flag - https://stackblitz.com/edit/vitejs-vite-jyp3fb?file=package.json,vite.config.ts,src%2FApp.vue&terminal=dev
I've made a test locally with replacing const enum
with normal enum
and it is working perfectly fine. As I said before - typings in PrimeVue are always included in ambient context files, which means that enum
/ const enum
differente will not apply here, as it will be taken from the JS file. So either rollbacking to your solution or replacing every const enum
with enum
will be a solution.
Due to limitations, it has been fixed as in https://github.com/primefaces/primevue/issues/3806
Describe the bug
The
Api.d.ts
file exposes:FilterMatchMode
andFilterMatchModeOptions
. After updating to 3.25.0 theFilterMatchMode
started behaving like a string, not like an enum, so we tried to switch toFilterMatchModeOptions
which is exactly the same.Unformtunately this error comes up:
Which is perfectly correct because when you look into
api.esm.js
file the only export is aFilterMatchMode
The same problem occurs for
ToastSeverity
in the same file.Reproducer
none
PrimeVue version
3.25.0
Vue version
3.x
Language
TypeScript
Build / Runtime
Vite
Browser(s)
No response
Steps to reproduce the behavior
No response
Expected behavior
Types should be declared explicitely as enums, not as a variables typed as enums.
There should be only this in case of
FilterMatchMode
- preferably asconst enum