-
-
Notifications
You must be signed in to change notification settings - Fork 10
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
Typescript types problems #63
Comments
Hi @spech66, apologies for the delay and thanks for the feedback! I managed to reproduce the type resolution issue - it seems to only occur specifically when the Regarding the actual Resource class type issues, unfortunately TypeScript still doesn't seem to understand the concept of inherited class static methods, and since the static As a workaround to the above, I have made the ingress/egress methods of the import SCIMMY, {Resources} from "scimmy";
import type {Schema} from "scimmy/types";
type UserWithEnterpriseUser = Schema.Extended<SCIMMY.Schemas.User, typeof SCIMMY.Schemas.EnterpriseUser>;
Resources.declare(Resources.User)
.extend(SCIMMY.Schemas.EnterpriseUser)
.ingress<UserWithEnterpriseUser>(async (resource, data, ctx) => { ... })
.egress<UserWithEnterpriseUser>(async (resource, ctx) => { ... });
/* or */
User.extend(SCIMMY.Schemas.EnterpriseUser)
.ingress<UserWithEnterpriseUser>(async (resource, data, ctx) => { ... })
.egress<UserWithEnterpriseUser>(async (resource, ctx) => { ... }); This workaround should hopefully address issues in TypeScript with handler argument/return value type inference for extended schemas, whilst also making it easier overall to customise the shape of the handler value types (e.g. marking attributes as required, or omitting them entirely). Finally, I wasn't able to reproduce the issue with the As mentioned above, these changes will be included in the next release, v1.3.2, which should happen imminently! Thanks, |
@sleelin thank you very much for the very detailed explanation and your help with this issues! This looks really promising and I'm looking forward for the next release 🙏 👍 |
Hi @spech66, Thanks, |
First things I found is that the export require to be default exports.
|
Could you please send through a copy of your tsconfig.json? It seems like the TypeScript compiler is running a complete type check on the type declarations for SCIMMY, which I'm pretty sure it shouldn't be doing? As far as I'm aware, because it's an external module it shouldn't be complaining about mismatched module target syntax - unless you copied the new declaration file into your project? Thanks, |
{
"extends": "@tsconfig/node20/tsconfig.json",
"compilerOptions": {
// add dom, needs to repeat es2023 here as array values of extended config are overwritten, not merged
// See: https://miyoon.medium.com/array-parameters-in-tsconfig-json-are-always-overwritten-11c80bb514e1
"lib": [ "es2023", "dom"],
"types": ["reflect-metadata"],
"outDir": "dist",
"rootDir": "src",
"incremental": true,
// needed for typeorm and DI decorators
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"sourceMap": true,
// pedantic settings
"alwaysStrict": false,
"noImplicitAny": true,
"skipLibCheck": false, // revert default of extended config
},
"references": [
{ "path": "../api-shared" }
],
"exclude": [
"node_modules",
"!node_modules/@types"
],
"include": [
"src/**/*"
]
} And the @tsconfig/node20/tsconfig.json {
"$schema": "https://json.schemastore.org/tsconfig",
"_version": "20.1.0",
"compilerOptions": {
"lib": ["es2023"],
"module": "node16",
"target": "es2022",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"moduleResolution": "node16"
}
} |
Thanks @spech66, I was able to reproduce the issue using the supplied tsconfig.json! Let me know if this properly resolves the issue! Thanks, |
This looks very promising. Thanks again! |
We upgraded to the latest version (1.3.1). However there are still some issues trying to use the types.
Import won't use the right file
if we import using
import { Resources } from "scimmy";
orimport SCIMMY from "scimmy";
After copying the type file to a modules declarations file and making a few adjustments some types are working. However we a running in the following problems:
Resource as any
or
Will show the ingress/egress/... resource/data as any type.
Enterprise Types
Getting a valid Enterprise User might need something like the above typing.
Group degress handler
The degress handler of Groups won't allow for promises as the method always require a void return instead of Promise.
The text was updated successfully, but these errors were encountered: