diff --git a/effect/src/index.ts b/effect/src/index.ts index aa96af82c06b7..2ad565fa5aa4a 100644 --- a/effect/src/index.ts +++ b/effect/src/index.ts @@ -2,12 +2,12 @@ import { Effect } from "./prelude.js"; import { Maybe } from "./prelude.js"; export const isPositive = (n: number) => - n > 0 ? Maybe.just("positive") : Maybe.nothing() + n > 0 ? Maybe.just("positive") : Maybe.nothing(); export const isPositiveEff = (n: number) => - n > 0 ? Effect("positive") : Effect.fail("negative") + n > 0 ? Effect("positive") : Effect.fail("negative"); -export const resultEither = isPositive(0).match(() => "nope", () => "yeah") +export const resultEither = isPositive(0).match(() => "nope", () => "yeah"); export const prog = Effect.do .bind("a", () => Effect(0)) @@ -15,10 +15,10 @@ export const prog = Effect.do .bind("c", () => Effect(2)) .bind("d", () => Effect(4) + Effect(5)) .map(({ a, b, c, d: { tuple: [e, f] } }) => `result: ${a + b + c} ${e} ${f}`) - .flatMap((s) => Effect(console.log(s))) + .flatMap((s) => Effect(console.log(s))); -export const result = prog | Effect.fail("error") +export const result = prog | Effect.fail("error"); prog.unsafeRunPromise() -export const xxx = pipe(0, n => n + 1, n => `hello: ${n}`) \ No newline at end of file +export const xxx = pipe(0, n => n + 1, n => `hello: ${n}`) diff --git a/src/services/goToDefinition.ts b/src/services/goToDefinition.ts index a7fdff1a8db21..1635184a9c193 100644 --- a/src/services/goToDefinition.ts +++ b/src/services/goToDefinition.ts @@ -49,12 +49,28 @@ namespace ts.GoToDefinition { const staticSymbol = typeChecker.getStaticExtension(type, name); if(staticSymbol && !isCallExpression(parent.parent)) { const declaration = staticSymbol.patched.valueDeclaration!; + let start: number; + let length: number; + if(declaration.original && isNamedDeclaration(declaration.original)) { + start = declaration.original.name.getStart(); + length = declaration.original.getWidth(); + } + else if(isNamedDeclaration(declaration)) { + start = declaration.name.getStart(); + length = declaration.getWidth(); + } + else { + start = declaration.getStart(); + length = declaration.getWidth(); + } + + if(start === -1 || length === -1) { + return undefined; + } + return [{ fileName: staticSymbol.definition.fileName, - textSpan: { - start: declaration.pos + 1, - length: declaration.end - declaration.pos - }, + textSpan: { start, length }, kind: SymbolDisplay.getSymbolKind(typeChecker, staticSymbol.patched, node), name: typeChecker.symbolToString(staticSymbol.patched), containerKind: undefined!,