Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .changeset/run-effect-inside-effect-exit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
"@effect/language-service": patch
---

Update Effect v4 support to 4.0.5 and fix `runEffectInsideEffect`.

`Effect.runPromiseExit` and `Effect.runSyncExit` called inside an Effect are now reported, like `Effect.runPromise` and `Effect.runSync`:

```ts
export const program = Effect.gen(function*() {
yield* Effect.void
setTimeout(() => {
Effect.runPromiseExit(child)
// ^- now suggests Effect.runPromiseExitWith (v4) or Runtime.runPromiseExit (v3)
}, 0)
})
```

The v4 quick fix now inserts `yield* Effect.context<never>()` instead of the removed `Effect.services`, and reuses an existing `yield* Effect.context()` binding:

```ts
export const program = Effect.gen(function*() {
const context = yield* Effect.context<never>()
const run = () => Effect.runSyncWith(context)(Effect.succeed(1))
return [context, run()] as const
})
```
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
},
"pnpm": {
"overrides": {
"@effect/platform-node-shared": "4.0.0-rc.118"
"@effect/platform-node-shared": "4.0.5"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
runEffectInsideEffect_skipNextLine from 118 to 132
runEffectInsideEffect_skipFile from 118 to 132
runEffectInsideEffect_skipNextLine from 142 to 160
runEffectInsideEffect_skipFile from 142 to 160
runEffectInsideEffect_fix from 286 to 303
runEffectInsideEffect_skipNextLine from 286 to 303
runEffectInsideEffect_skipFile from 286 to 303
runEffectInsideEffect_fix from 315 to 336
runEffectInsideEffect_skipNextLine from 315 to 336
runEffectInsideEffect_skipFile from 315 to 336
runEffectInsideEffect_fix from 348 to 362
runEffectInsideEffect_skipNextLine from 348 to 362
runEffectInsideEffect_skipFile from 348 to 362
runEffectInsideEffect_fix from 374 to 392
runEffectInsideEffect_skipNextLine from 374 to 392
runEffectInsideEffect_skipFile from 374 to 392
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Effect.runSync
6:2 - 6:16 | 2 | `Effect.runSync` is called inside an existing Effect context. Here, the inner Effect can be used directly. effect(runEffectInsideEffect)

Effect.runSyncExit
7:2 - 7:20 | 2 | `Effect.runSyncExit` is called inside an existing Effect context. Here, the inner Effect can be used directly. effect(runEffectInsideEffect)

Effect.runPromise
14:4 - 14:21 | 2 | `Effect.runPromise` is called inside an Effect with a separate runtime invocation. In this context, run child Effects with the surrounding runtime, which can be accessed through `Effect.runtime` and `Runtime.runPromise`. effect(runEffectInsideEffect)

Effect.runPromiseExit
15:4 - 15:25 | 2 | `Effect.runPromiseExit` is called inside an Effect with a separate runtime invocation. In this context, run child Effects with the surrounding runtime, which can be accessed through `Effect.runtime` and `Runtime.runPromiseExit`. effect(runEffectInsideEffect)

Effect.runSync
16:4 - 16:18 | 2 | `Effect.runSync` is called inside an Effect with a separate runtime invocation. In this context, run child Effects with the surrounding runtime, which can be accessed through `Effect.runtime` and `Runtime.runSync`. effect(runEffectInsideEffect)

Effect.runSyncExit
17:4 - 17:22 | 2 | `Effect.runSyncExit` is called inside an Effect with a separate runtime invocation. In this context, run child Effects with the surrounding runtime, which can be accessed through `Effect.runtime` and `Runtime.runSyncExit`. effect(runEffectInsideEffect)
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// code fix runEffectInsideEffect_fix output for range 286 - 303
import { Effect } from "effect"

const child = Effect.succeed(1)

export const sameScope = Effect.gen(function*() {
Effect.runSync(child)
Effect.runSyncExit(child)
yield* Effect.void
})

export const nested = Effect.gen(function*() {
const effectRuntime = yield* Effect.runtime<never>()

yield* Effect.void
setTimeout(() => {
Runtime.runPromise(effectRuntime, child)
Effect.runPromiseExit(child)
Effect.runSync(child)
Effect.runSyncExit(child)
}, 0)
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// code fix runEffectInsideEffect_fix output for range 315 - 336
import { Effect } from "effect"

const child = Effect.succeed(1)

export const sameScope = Effect.gen(function*() {
Effect.runSync(child)
Effect.runSyncExit(child)
yield* Effect.void
})

export const nested = Effect.gen(function*() {
const effectRuntime = yield* Effect.runtime<never>()

yield* Effect.void
setTimeout(() => {
Effect.runPromise(child)
Runtime.runPromiseExit(effectRuntime, child)
Effect.runSync(child)
Effect.runSyncExit(child)
}, 0)
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// code fix runEffectInsideEffect_fix output for range 348 - 362
import { Effect } from "effect"

const child = Effect.succeed(1)

export const sameScope = Effect.gen(function*() {
Effect.runSync(child)
Effect.runSyncExit(child)
yield* Effect.void
})

export const nested = Effect.gen(function*() {
const effectRuntime = yield* Effect.runtime<never>()

yield* Effect.void
setTimeout(() => {
Effect.runPromise(child)
Effect.runPromiseExit(child)
Runtime.runSync(effectRuntime, child)
Effect.runSyncExit(child)
}, 0)
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// code fix runEffectInsideEffect_fix output for range 374 - 392
import { Effect } from "effect"

const child = Effect.succeed(1)

export const sameScope = Effect.gen(function*() {
Effect.runSync(child)
Effect.runSyncExit(child)
yield* Effect.void
})

export const nested = Effect.gen(function*() {
const effectRuntime = yield* Effect.runtime<never>()

yield* Effect.void
setTimeout(() => {
Effect.runPromise(child)
Effect.runPromiseExit(child)
Effect.runSync(child)
Runtime.runSyncExit(effectRuntime, child)
}, 0)
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Effect } from "effect"

const child = Effect.succeed(1)

export const sameScope = Effect.gen(function*() {
Effect.runSync(child)
Effect.runSyncExit(child)
yield* Effect.void
})

export const nested = Effect.gen(function*() {
yield* Effect.void
setTimeout(() => {
Effect.runPromise(child)
Effect.runPromiseExit(child)
Effect.runSync(child)
Effect.runSyncExit(child)
}, 0)
})
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,23 @@ export function functionDeclarationPlainMany<T>(value: T) {
if (value === null) return Effect.fail("Error!")
return Effect.succeed(a + b + c + d + e)
}


function
19:53 - 19:61 | 1 | No overload matches this call.
Overload 1 of 64, '(body: (this: unassigned, value: T) => Generator<Effect<never, string, never>, number, never> | (Effect<never, string, never> & Effect<...>)): <T>(value: T) => Effect<...>', gave the following error.
Argument of type '<T>(value: T) => Effect.Effect<never, string, never> | Effect.Effect<number, never, never>' is not assignable to parameter of type '(this: unassigned, value: T) => Generator<Effect<never, string, never>, number, never> | (Effect<never, string, never> & Effect<...>)'.
Type 'Effect<never, string, never> | Effect<number, never, never>' is not assignable to type 'Generator<Effect<never, string, never>, number, never> | (Effect<never, string, never> & Effect<number, any, any>)'.
Type 'Effect<number, never, never>' is not assignable to type 'Generator<Effect<never, string, never>, number, never> | (Effect<never, string, never> & Effect<number, any, any>)'.
Type 'Effect<number, never, never>' is not assignable to type 'Effect<never, string, never> & Effect<number, any, any>'.
Type 'Effect<number, never, never>' is not assignable to type 'Effect<never, string, never>'.
Type 'number' is not assignable to type 'never'.
Overload 2 of 64, '(body: (this: unknown, value: T) => Generator<Effect<never, string, never>, number, never> | (Effect<never, string, never> & Effect<number, any, any>)): <T>(this: unknown, value: T) => Effect<...>', gave the following error.
Argument of type '<T>(value: T) => Effect.Effect<never, string, never> | Effect.Effect<number, never, never>' is not assignable to parameter of type '(this: unknown, value: T) => Generator<Effect<never, string, never>, number, never> | (Effect<never, string, never> & Effect<number, any, any>)'.
Type 'Effect<never, string, never> | Effect<number, never, never>' is not assignable to type 'Generator<Effect<never, string, never>, number, never> | (Effect<never, string, never> & Effect<number, any, any>)'.
Type 'Effect<number, never, never>' is not assignable to type 'Generator<Effect<never, string, never>, number, never> | (Effect<never, string, never> & Effect<number, any, any>)'.
Type 'Effect<number, never, never>' is not assignable to type 'Effect<never, string, never> & Effect<number, any, any>'.
Type 'Effect<number, never, never>' is not assignable to type 'Effect<never, string, never>'.
Type 'number' is not assignable to type 'never'.
Overload 3 of 64, '(name: string, options?: SpanOptionsNoTrace | undefined): Traced', gave the following error.
Argument of type '<T>(value: T) => Effect.Effect<never, string, never> | Effect.Effect<number, never, never>' is not assignable to parameter of type 'string'.
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,23 @@ export const functionDeclarationPlainMany = Effect.fn(function <T>(value: T) {
if (value === null) return Effect.fail("Error!")
return Effect.succeed(a + b + c + d + e)
})


function
29:54 - 29:62 | 1 | No overload matches this call.
Overload 1 of 64, '(body: (this: unassigned, value: T) => Generator<Effect<never, string, never>, number, never> | (Effect<never, string, never> & Effect<...>)): <T>(value: T) => Effect<...>', gave the following error.
Argument of type '<T>(value: T) => Effect.Effect<never, string, never> | Effect.Effect<number, never, never>' is not assignable to parameter of type '(this: unassigned, value: T) => Generator<Effect<never, string, never>, number, never> | (Effect<never, string, never> & Effect<...>)'.
Type 'Effect<never, string, never> | Effect<number, never, never>' is not assignable to type 'Generator<Effect<never, string, never>, number, never> | (Effect<never, string, never> & Effect<number, any, any>)'.
Type 'Effect<number, never, never>' is not assignable to type 'Generator<Effect<never, string, never>, number, never> | (Effect<never, string, never> & Effect<number, any, any>)'.
Type 'Effect<number, never, never>' is not assignable to type 'Effect<never, string, never> & Effect<number, any, any>'.
Type 'Effect<number, never, never>' is not assignable to type 'Effect<never, string, never>'.
Type 'number' is not assignable to type 'never'.
Overload 2 of 64, '(body: (this: unknown, value: T) => Generator<Effect<never, string, never>, number, never> | (Effect<never, string, never> & Effect<number, any, any>)): <T>(this: unknown, value: T) => Effect<...>', gave the following error.
Argument of type '<T>(value: T) => Effect.Effect<never, string, never> | Effect.Effect<number, never, never>' is not assignable to parameter of type '(this: unknown, value: T) => Generator<Effect<never, string, never>, number, never> | (Effect<never, string, never> & Effect<number, any, any>)'.
Type 'Effect<never, string, never> | Effect<number, never, never>' is not assignable to type 'Generator<Effect<never, string, never>, number, never> | (Effect<never, string, never> & Effect<number, any, any>)'.
Type 'Effect<number, never, never>' is not assignable to type 'Generator<Effect<never, string, never>, number, never> | (Effect<never, string, never> & Effect<number, any, any>)'.
Type 'Effect<number, never, never>' is not assignable to type 'Effect<never, string, never> & Effect<number, any, any>'.
Type 'Effect<number, never, never>' is not assignable to type 'Effect<never, string, never>'.
Type 'number' is not assignable to type 'never'.
Overload 3 of 64, '(name: string, options?: SpanOptionsNoTrace | undefined): Traced', gave the following error.
Argument of type '<T>(value: T) => Effect.Effect<never, string, never> | Effect.Effect<number, never, never>' is not assignable to parameter of type 'string'.
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,21 @@ export function functionDeclarationPlainMany<T>(value: T) {
if (value === null) return Effect.fail("Error!")
return Effect.succeed(a + b + c + d + e)
}


function
19:84 - 19:92 | 1 | No overload matches this call.
Overload 1 of 63, '(body: (this: unassigned, value: T) => Generator<Effect<never, string, never>, number, never> | (Effect<never, string, never> & Effect<...>)): <T>(value: T) => Effect<...>', gave the following error.
Argument of type '<T>(value: T) => Effect.Effect<never, string, never> | Effect.Effect<number, never, never>' is not assignable to parameter of type '(this: unassigned, value: T) => Generator<Effect<never, string, never>, number, never> | (Effect<never, string, never> & Effect<...>)'.
Type 'Effect<never, string, never> | Effect<number, never, never>' is not assignable to type 'Generator<Effect<never, string, never>, number, never> | (Effect<never, string, never> & Effect<number, any, any>)'.
Type 'Effect<number, never, never>' is not assignable to type 'Generator<Effect<never, string, never>, number, never> | (Effect<never, string, never> & Effect<number, any, any>)'.
Type 'Effect<number, never, never>' is not assignable to type 'Effect<never, string, never> & Effect<number, any, any>'.
Type 'Effect<number, never, never>' is not assignable to type 'Effect<never, string, never>'.
Type 'number' is not assignable to type 'never'.
Overload 2 of 63, '(body: (this: unknown, value: T) => Generator<Effect<never, string, never>, number, never> | (Effect<never, string, never> & Effect<number, any, any>)): <T>(this: unknown, value: T) => Effect<...>', gave the following error.
Argument of type '<T>(value: T) => Effect.Effect<never, string, never> | Effect.Effect<number, never, never>' is not assignable to parameter of type '(this: unknown, value: T) => Generator<Effect<never, string, never>, number, never> | (Effect<never, string, never> & Effect<number, any, any>)'.
Type 'Effect<never, string, never> | Effect<number, never, never>' is not assignable to type 'Generator<Effect<never, string, never>, number, never> | (Effect<never, string, never> & Effect<number, any, any>)'.
Type 'Effect<number, never, never>' is not assignable to type 'Generator<Effect<never, string, never>, number, never> | (Effect<never, string, never> & Effect<number, any, any>)'.
Type 'Effect<number, never, never>' is not assignable to type 'Effect<never, string, never> & Effect<number, any, any>'.
Type 'Effect<number, never, never>' is not assignable to type 'Effect<never, string, never>'.
Type 'number' is not assignable to type 'never'.
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,21 @@ export const functionDeclarationPlainMany = Effect.fn("functionDeclarationPlainM
if (value === null) return Effect.fail("Error!")
return Effect.succeed(a + b + c + d + e)
})


function
29:86 - 29:94 | 1 | No overload matches this call.
Overload 1 of 63, '(body: (this: unassigned, value: T) => Generator<Effect<never, string, never>, number, never> | (Effect<never, string, never> & Effect<...>)): <T>(value: T) => Effect<...>', gave the following error.
Argument of type '<T>(value: T) => Effect.Effect<never, string, never> | Effect.Effect<number, never, never>' is not assignable to parameter of type '(this: unassigned, value: T) => Generator<Effect<never, string, never>, number, never> | (Effect<never, string, never> & Effect<...>)'.
Type 'Effect<never, string, never> | Effect<number, never, never>' is not assignable to type 'Generator<Effect<never, string, never>, number, never> | (Effect<never, string, never> & Effect<number, any, any>)'.
Type 'Effect<number, never, never>' is not assignable to type 'Generator<Effect<never, string, never>, number, never> | (Effect<never, string, never> & Effect<number, any, any>)'.
Type 'Effect<number, never, never>' is not assignable to type 'Effect<never, string, never> & Effect<number, any, any>'.
Type 'Effect<number, never, never>' is not assignable to type 'Effect<never, string, never>'.
Type 'number' is not assignable to type 'never'.
Overload 2 of 63, '(body: (this: unknown, value: T) => Generator<Effect<never, string, never>, number, never> | (Effect<never, string, never> & Effect<number, any, any>)): <T>(this: unknown, value: T) => Effect<...>', gave the following error.
Argument of type '<T>(value: T) => Effect.Effect<never, string, never> | Effect.Effect<number, never, never>' is not assignable to parameter of type '(this: unknown, value: T) => Generator<Effect<never, string, never>, number, never> | (Effect<never, string, never> & Effect<number, any, any>)'.
Type 'Effect<never, string, never> | Effect<number, never, never>' is not assignable to type 'Generator<Effect<never, string, never>, number, never> | (Effect<never, string, never> & Effect<number, any, any>)'.
Type 'Effect<number, never, never>' is not assignable to type 'Generator<Effect<never, string, never>, number, never> | (Effect<never, string, never> & Effect<number, any, any>)'.
Type 'Effect<number, never, never>' is not assignable to type 'Effect<never, string, never> & Effect<number, any, any>'.
Type 'Effect<number, never, never>' is not assignable to type 'Effect<never, string, never>'.
Type 'number' is not assignable to type 'never'.
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ import * as Schema from "effect/Schema"
export class User extends Schema.Class<User>("User")({ name: Schema.String }) {
public static new(readonly input: { name: string} ) { const _this = new this(input); return _this }
}


readonly input: { name: string}
7:20 - 7:51 | 1 | A parameter property is only allowed in a constructor implementation.
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ export class InvalidBecauseOfConstructor
{
b: number
}


b
9:2 - 9:3 | 1 | Property 'b' has no initializer and is not definitely assigned in the constructor.
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ export class InvalidBecauseOfConstructor
return _this
}
}


b
9:2 - 9:3 | 1 | Property 'b' has no initializer and is not definitely assigned in the constructor.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class DebuggerError extends Data.TaggedError("DebuggerError")<{
}> {}

export const program = Effect.gen(function*() {
const effectServices = yield* Effect.services<never>()
const effectContext = yield* Effect.context<never>()

const response = yield* Effect.tryPromise({
try: () => fetch("http://localhost:9229"),
Expand All @@ -22,7 +22,7 @@ const effectServices = yield* Effect.services<never>()
try: () => fetch(event.data as string),
catch: (e) => new DebuggerError({ cause: e })
})
Effect.runPromiseWith(effectServices)(check)
Effect.runPromiseWith(effectContext)(check)
// ^- no runPromise, use the current services instead
}
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
runEffectInsideEffect_fix from 150 to 164
runEffectInsideEffect_skipNextLine from 150 to 164
runEffectInsideEffect_skipFile from 150 to 164
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Effect.runSync
5:20 - 5:34 | 2 | `Effect.runSync` is called inside an Effect with a separate services invocation. In this context, child Effects run with the surrounding services, which can be accessed through `Effect.context` and `Effect.runSyncWith`. effect(runEffectInsideEffect)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// code fix runEffectInsideEffect_fix output for range 150 - 164
import { Effect } from "effect"

export const program = Effect.gen(function*() {
const context = yield* Effect.context<never>()
const run = () => Effect.runSyncWith(context)(Effect.succeed(1))
return [context, run()] as const
})
Loading
Loading