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
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package fourslash_test

import (
"testing"

"github.com/microsoft/typescript-go/internal/fourslash"
"github.com/microsoft/typescript-go/internal/testutil"
)

func TestGoToImplementationInterfaceObjectLiteral(t *testing.T) {
t.Parallel()
defer testutil.RecoverAndFail(t, "Panic on fourslash test")
const content = `
// @Filename: /file1.ts
export interface MyInterface { P: number; }

// @Filename: /file2.ts
import { MyInterface } from "./file1";

const x: /*impl*/MyInterface = { P: 2 };
`
f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content)
defer done()
f.VerifyBaselineGoToImplementation(t, "impl")
}
2 changes: 1 addition & 1 deletion internal/ls/findallreferences.go
Original file line number Diff line number Diff line change
Expand Up @@ -1932,7 +1932,7 @@ func (state *refState) addImplementationReferences(refNode *ast.Node, addRef fun
}

typeHavingNode := typeNode.Parent
if typeHavingNode.Type() == typeNode && !state.seenContainingTypeReferences.AddIfAbsent(typeHavingNode) {
if typeHavingNode.Type() == typeNode && state.seenContainingTypeReferences.AddIfAbsent(typeHavingNode) {
addIfImplementation := func(e *ast.Expression) {
if isImplementationExpression(e) {
addRef(e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,23 @@
// }
// --- (line: 7) skipped ---

// === /objectPointable.ts ===
// import { Pointable } from "./pointable";
//
// let x = 0;
// let y = 0;
// const p: Pointable = [|{
// getX(): number {
// return x;
// },
// getY(): number {
// return y;
// },
// }|];
//

// === /pointable.ts ===
// export interface /*CODELENS: 1 implementation*/Pointable {
// export interface /*CODELENS: 2 implementations*/Pointable {
// getX(): number;
// getY(): number;
// }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// === goToImplementation ===
// === /file2.ts ===
// import { MyInterface } from "./file1";
//
// const x: /*GOTO IMPL*/MyInterface = [|{ P: 2 }|];
//
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@
//
// <|interface [|Baz|] extends Foo {}|>
//
// var bar: Foo = { hello: helloImpl /**0*/ };
// var baz: Foo[] = [{ hello: helloImpl /**4*/ }];
// --- (line: 9) skipped ---
// var bar: Foo = [|{ hello: helloImpl /**0*/ }|];
// var baz: Foo[] = [|[{ hello: helloImpl /**4*/ }]|];
//
// function helloImpl () {}
//
// function whatever(x: Foo = [|{ hello() {/**1*/} }|] ) {
// }
//
// class Bar {
// x: Foo = [|{ hello() {} }|]
//
// constructor(public f: Foo = [|{ hello() {/**3*/} }|] ) {}
// }

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,19 @@
//
// let x: number = 9;
//
// --- (line: 5) skipped ---
// function createFoo(): Foo {
// if (x === 2) {
// return [|{
// hello() {}
// }|];
// }
// return [|{
// hello() {}
// }|];
// }
//
// let createFoo2 = (): Foo => [|({hello() {}})|];
//
// function createFooLike() {
// return {
// --- (line: 20) skipped ---

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
// === /goToImplementationInterface_03.ts ===
// interface Fo/*GOTO IMPL*/o { hello: () => void }
//
// var x = <Foo> { hello: () => {} };
// var x = <Foo> [|{ hello: () => {} }|];

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,13 @@
// (a: number): void
// }
//
// --- (line: 5) skipped ---
// var bar: Foo = [|(a) => {/**0*/}|];
//
// function whatever(x: Foo = [|(a) => {/**1*/}|] ) {
// }
//
// class Bar {
// x: Foo = [|(a) => {/**2*/}|]
//
// constructor(public f: Foo = [|function(a) {}|] ) {}
// }

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
// (a: number): void
// }
//
// let bar2 = <Foo> function(a) {};
// let bar2 = <Foo> [|function(a) {}|];
//

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@
// new (a: number): SomeOtherType;
// }
//
// --- (line: 5) skipped ---
// interface SomeOtherType {}
//
// let x: Foo = [|class { constructor (a: number) {} }|];
// let y = <Foo> [|class { constructor (a: number) {} }|];

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@
// hello (): void;
// }
//
// --- (line: 5) skipped ---

// --- (line: 8) skipped ---
// let x1: Foo = { hello () { /**typeReference*/ } };
// let x2: () => Foo = (() => { hello () { /**functionType*/} });
// let x3: Foo | Bar = { hello () { /**unionType*/} };
// interface Bar {
// hello (): void;
// }
//
// let x1: Foo = [|{ hello () { /**typeReference*/ } }|];
// let x2: () => Foo = [|(() => { hello () { /**functionType*/} })|];
// let x3: Foo | Bar = [|{ hello () { /**unionType*/} }|];
// let x4: Foo & (Foo & Bar) = [|{ hello () { /**intersectionType*/} }|];
// let x5: [Foo] = [{ hello () { /**tupleType*/} }];
// let x6: (Foo) = { hello () { /**parenthesizedType*/} };
// let x7: (new() => Foo) = class { hello () { /**constructorType*/} };
// let x8: Foo[] = [{ hello () { /**arrayType*/} }];
// let x9: { y: Foo } = { y: { hello () { /**typeLiteral*/} } };
// let x5: [Foo] = [|[{ hello () { /**tupleType*/} }]|];
// let x6: (Foo) = [|{ hello () { /**parenthesizedType*/} }|];
// let x7: (new() => Foo) = [|class { hello () { /**constructorType*/} }|];
// let x8: Foo[] = [|[{ hello () { /**arrayType*/} }]|];
// let x9: { y: Foo } = [|{ y: { hello () { /**typeLiteral*/} } }|];
// let x10 = [|class implements Foo { hello() {} }|]
// let x11 = <|class [|C|] implements Foo { hello() {} }|>
//
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// === goToImplementation ===
// === /ref.ts ===
// import { Interface } from "./def";
// const c: I/*GOTO IMPL*/nterface = { P: 2 };
// const c: I/*GOTO IMPL*/nterface = [|{ P: 2 }|];

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
// hello() {}
// }|>
//
// var someVar1 : Foo.Bar = { hello: () => {/**1*/} };
// var someVar1 : Foo.Bar = [|{ hello: () => {/**1*/} }|];
//
// var someVar2 = <Foo.Bar> { hello: () => {/**2*/} };
// var someVar2 = <Foo.Bar> [|{ hello: () => {/**2*/} }|];
//
// function whatever(x: Foo.Ba/*GOTO IMPL*/r) {
//
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
// hello() {}
// }|>
//
// var someVar1 : Foo.Bar = { hello: () => {/**1*/} };
// var someVar1 : Foo.Bar = [|{ hello: () => {/**1*/} }|];
//
// var someVar2 = <Foo.Bar> { hello: () => {/**2*/} };
// var someVar2 = <Foo.Bar> [|{ hello: () => {/**2*/} }|];
//
// function whatever(x: Foo.Ba/*GOTO IMPL*/r) {
//
Expand Down

This file was deleted.

Loading