Effect.Schema does not provide type assistance in Effect.flatMap
I am new to Effect and to Effect's schema, so I would be very grateful if you could explain why the Effect schema does not provide type assistance here.
Here is my schema:
I use it like this:
If I annotate function here, than everything works:
I don't understand what is the problem, here are my tsconfigs:
tsconfig.json
tsconfig.settings.json
Here is my schema:
export const getNodeSchema = Schema.Struct({
id: PRIMITIVES.nodeId,
ownerId: PRIMITIVES.nodeId,
docType: PRIMITIVES.docType,
createdAt: PRIMITIVES.timestamp,
modifiedAt: PRIMITIVES.timestamp
})
export type GetNodeData = typeof getNodeSchema.Typeexport const getNodeSchema = Schema.Struct({
id: PRIMITIVES.nodeId,
ownerId: PRIMITIVES.nodeId,
docType: PRIMITIVES.docType,
createdAt: PRIMITIVES.timestamp,
modifiedAt: PRIMITIVES.timestamp
})
export type GetNodeData = typeof getNodeSchema.TypeI use it like this:
Effect.flatMap(Repository, (repository) => {
const node = repository.getNode("testNodeId")
return node // My IDE shows type here Effect.Effect<GetNodeData, never, never>
}).pipe(
Effect.andThen((node) => { // Here type is any
expect(node).toBeTruthy();
}));Effect.flatMap(Repository, (repository) => {
const node = repository.getNode("testNodeId")
return node // My IDE shows type here Effect.Effect<GetNodeData, never, never>
}).pipe(
Effect.andThen((node) => { // Here type is any
expect(node).toBeTruthy();
}));If I annotate function here, than everything works:
Effect.flatMap(Repository, (repository): Effect.Effect<GetNodeData, never, never> => {Effect.flatMap(Repository, (repository): Effect.Effect<GetNodeData, never, never> => {I don't understand what is the problem, here are my tsconfigs:
tsconfig.json
{
"extends": "../../tsconfig.settings.json",
"compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
"composite": true,
"baseUrl": ".",
"paths": {
"@/*": ["src/*"]
}
}
}{
"extends": "../../tsconfig.settings.json",
"compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
"composite": true,
"baseUrl": ".",
"paths": {
"@/*": ["src/*"]
}
}
}tsconfig.settings.json
{
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext",
"skipLibCheck": true,
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"isolatedModules": true,
"moduleDetection": "force",
"noEmit": true,
"jsx": "react-jsx",
"strict": true,
"noUnusedLocals": true,
"strictNullChecks": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedSideEffectImports": true,
"noImplicitAny": true,
"allowUmdGlobalAccess": true,
"exactOptionalPropertyTypes": true
}
}{
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext",
"skipLibCheck": true,
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"isolatedModules": true,
"moduleDetection": "force",
"noEmit": true,
"jsx": "react-jsx",
"strict": true,
"noUnusedLocals": true,
"strictNullChecks": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedSideEffectImports": true,
"noImplicitAny": true,
"allowUmdGlobalAccess": true,
"exactOptionalPropertyTypes": true
}
}