TypeScript/tests/cases/fourslash/declarationMapsGeneratedMapsEnableMapping.ts
Wesley Wigham 6af764c560
Declaration maps and transparent goto definition using them (#22658)
* Add compiler option to enable declaration sourcemaps

* Transparent goto definition for sourcemapped declaration files

* Post-rebase touchups

* Rename API methods

* Fix lints

* Fix typo in name XD

* Log sourcemap decode errors

* Share the cache more, but also invalidate it more

* Remove todo

* Enable mapping on go to implementation as well

* Allow fourslash to test declaration maps mroe easily

* more test

* Handle sourceRoot

* Add tests documenting current behavior with other sourcemapping flags

* Ignore inline options for declaration file maps, simplify dispatch in emitter

* Change program diagnostic

* Fix nit

* Use charCodeAt

* Rename internal methods + veriables

* Avoid filter

* span -> position

* Use character codes

* Dont parse our sourcemap names until we need to start using them

* zero-index parsed positions

* Handle sourceMappingURL comments, including base64 encoded ones

* Unittest b64 decoder, make mroe robust to handle unicode properly

* Fix lint

* declarationMaps -> declarationMap

* Even more feedback

* USE Mroe lenient combined regexp

* only match base64 characters

* Fix nit
2018-03-26 12:15:34 -07:00

33 lines
1 KiB
TypeScript

/// <reference path="fourslash.ts" />
// @BaselineFile: declarationMapsGeneratedMapsEnableMapping.baseline
// @outDir: ./dist
// @declaration: true
// @declarationMap: true
// @Filename: index.ts
// @emitThisFile: true
////export class Foo {
//// member: string;
//// /*2*/methodName(propName: SomeType): void {}
//// otherMethod() {
//// if (Math.random() > 0.5) {
//// return {x: 42};
//// }
//// return {y: "yes"};
//// }
////}
////
////export interface SomeType {
//// member: number;
////}
// @Filename: mymodule.ts
////import * as mod from "/dist/index";
////const instance = new mod.Foo();
////instance.[|/*1*/methodName|]({member: 12});
verify.baselineGetEmitOutput(/*insertResultIntoVfs*/ true);
verify.goToDefinition("1", "2"); // getDefinitionAndBoundSpan
verify.goToType("1", "2"); // getTypeDefinitionAtPosition
goTo.marker("1");
verify.goToDefinitionIs("2"); // getDefinitionAtPosition
goTo.implementation(); // getImplementationAtPosition
verify.caretAtMarker("2");