TypeScript/tests/cases/fourslash/server/declarationMapsGeneratedMapsEnableMapping.ts
Andy 794f3a5e76
goToTypeDefinition: Go to function return type (#25952)
* goToTypeDefinition: Go to function return type

* Add more tests

* If a function returns 'void' or some other type with no definition, just return the function definition.
2018-08-07 12:54:19 -07:00

82 lines
2.3 KiB
TypeScript

/// <reference path="../fourslash.ts" />
// @Filename: /tsconfig.json
////{
//// "compilerOptions": {
//// "outDir": "./dist",
//// "declaration": true,
//// "declarationMap": true,
//// "newLine": "lf",
//// },
//// "files": ["/index.ts"],
////}
// @Filename: /index.ts
// @emitThisFile: true
////export class Foo {
//// member: string;
//// /*2*/methodName(propName: SomeType): SomeType { return propName; }
//// otherMethod() {
//// if (Math.random() > 0.5) {
//// return {x: 42};
//// }
//// return {y: "yes"};
//// }
////}
////
////export interface /*SomeType*/SomeType {
//// member: number;
////}
// @Filename: /mymodule.ts
////import * as mod from "/dist/index";
////const instance = new mod.Foo();
////instance.[|/*1*/methodName|]({member: 12});
// @Filename: /dist/index.js
////"use strict";
////exports.__esModule = true;
////var Foo = /** @class */ (function () {
//// function Foo() {
//// }
//// Foo.prototype.methodName = function (propName) { return propName; };
//// Foo.prototype.otherMethod = function () {
//// if (Math.random() > 0.5) {
//// return { x: 42 };
//// }
//// return { y: "yes" };
//// };
//// return Foo;
////}());
////exports.Foo = Foo;
////
// @Filename: /dist/index.d.ts.map
////{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,qBAAa,GAAG;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,QAAQ,EAAE,QAAQ,GAAG,QAAQ;IACxC,WAAW;;;;;;;CAMd;AAED,MAAM,WAAW,QAAQ;IACrB,MAAM,EAAE,MAAM,CAAC;CAClB"}
// @Filename: /dist/index.d.ts
////export declare class Foo {
//// member: string;
//// methodName(propName: SomeType): SomeType;
//// otherMethod(): {
//// x: number;
//// y?: undefined;
//// } | {
//// y: string;
//// x?: undefined;
//// };
////}
////export interface SomeType {
//// member: number;
////}
//////# sourceMappingURL=index.d.ts.map
goTo.file("/index.ts");
verify.getEmitOutput(["/dist/index.js", "/dist/index.d.ts.map", "/dist/index.d.ts"]);
verify.goToDefinition("1", "2"); // getDefinitionAndBoundSpan
verify.goToType("1", "SomeType"); // getTypeDefinitionAtPosition
goTo.marker("1");
verify.goToDefinitionIs("2"); // getDefinitionAtPosition
goTo.implementation(); // getImplementationAtPosition
verify.caretAtMarker("2");