|
| 1 | +/// <reference path="../fourslash.ts" /> |
| 2 | + |
| 3 | +// @Filename: /tsconfig.json |
| 4 | +//// { "compilerOptions": { "module": "commonjs" } } |
| 5 | + |
| 6 | +// @Filename: /package.json |
| 7 | +//// { "dependencies": { "mylib": "file:packages/mylib" } } |
| 8 | + |
| 9 | +// @Filename: /packages/mylib/package.json |
| 10 | +//// { "name": "mylib", "version": "1.0.0", "main": "index.js", "types": "index" } |
| 11 | + |
| 12 | +// @Filename: /packages/mylib/index.ts |
| 13 | +//// export * from "./mySubDir"; |
| 14 | + |
| 15 | +// @Filename: /packages/mylib/mySubDir/index.ts |
| 16 | +//// export * from "./myClass"; |
| 17 | +//// export * from "./myClass2"; |
| 18 | + |
| 19 | +// @Filename: /packages/mylib/mySubDir/myClass.ts |
| 20 | +//// export class MyClass {} |
| 21 | + |
| 22 | +// @Filename: /packages/mylib/mySubDir/myClass2.ts |
| 23 | +//// export class MyClass2 {} |
| 24 | + |
| 25 | +// @link: /packages/mylib -> /node_modules/mylib |
| 26 | + |
| 27 | +// @Filename: /src/index.ts |
| 28 | +//// |
| 29 | +//// const a = new MyClass/*1*/(); |
| 30 | +//// const b = new MyClass2/*2*/(); |
| 31 | + |
| 32 | +goTo.marker("1"); |
| 33 | +format.setOption("newLineCharacter", "\n"); |
| 34 | + |
| 35 | +verify.completions({ |
| 36 | + marker: "1", |
| 37 | + includes: [{ |
| 38 | + name: "MyClass", |
| 39 | + source: "mylib", |
| 40 | + sourceDisplay: "mylib", |
| 41 | + hasAction: true, |
| 42 | + sortText: completion.SortText.AutoImportSuggestions, |
| 43 | + }], |
| 44 | + preferences: { |
| 45 | + includeCompletionsForModuleExports: true, |
| 46 | + includeInsertTextCompletions: true, |
| 47 | + allowIncompleteCompletions: true, |
| 48 | + } |
| 49 | +}); |
| 50 | + |
| 51 | +verify.applyCodeActionFromCompletion("1", { |
| 52 | + name: "MyClass", |
| 53 | + source: "mylib", |
| 54 | + description: `Import 'MyClass' from module "mylib"`, |
| 55 | + data: { |
| 56 | + exportName: "MyClass", |
| 57 | + fileName: "/packages/mylib/index.ts", |
| 58 | + }, |
| 59 | + preferences: { |
| 60 | + includeCompletionsForModuleExports: true, |
| 61 | + includeCompletionsWithInsertText: true, |
| 62 | + allowIncompleteCompletions: true, |
| 63 | + }, |
| 64 | + newFileContent: `import { MyClass } from "mylib"; |
| 65 | +
|
| 66 | +const a = new MyClass(); |
| 67 | +const b = new MyClass2();`, |
| 68 | +}); |
0 commit comments