1namespace ts { 2 describe("unittests:: tsbuild:: inferredTypeFromTransitiveModule::", () => { 3 let projFs: vfs.FileSystem; 4 before(() => { 5 projFs = loadProjectFromDisk("tests/projects/inferredTypeFromTransitiveModule"); 6 }); 7 after(() => { 8 projFs = undefined!; 9 }); 10 11 verifyTscWithEdits({ 12 scenario: "inferredTypeFromTransitiveModule", 13 subScenario: "inferred type from transitive module", 14 fs: () => projFs, 15 commandLineArgs: ["--b", "/src", "--verbose"], 16 edits: [ 17 { 18 subScenario: "incremental-declaration-changes", 19 modifyFs: changeBarParam, 20 }, 21 { 22 subScenario: "incremental-declaration-changes", 23 modifyFs: changeBarParamBack, 24 }, 25 ], 26 }); 27 28 verifyTscWithEdits({ 29 subScenario: "inferred type from transitive module with isolatedModules", 30 fs: () => projFs, 31 scenario: "inferredTypeFromTransitiveModule", 32 commandLineArgs: ["--b", "/src", "--verbose"], 33 modifyFs: changeToIsolatedModules, 34 edits: [ 35 { 36 subScenario: "incremental-declaration-changes", 37 modifyFs: changeBarParam 38 }, 39 { 40 subScenario: "incremental-declaration-changes", 41 modifyFs: changeBarParamBack, 42 }, 43 ] 44 }); 45 46 verifyTscWithEdits({ 47 scenario: "inferredTypeFromTransitiveModule", 48 subScenario: "reports errors in files affected by change in signature with isolatedModules", 49 fs: () => projFs, 50 commandLineArgs: ["--b", "/src", "--verbose"], 51 modifyFs: fs => { 52 changeToIsolatedModules(fs); 53 appendText(fs, "/src/lazyIndex.ts", ` 54import { default as bar } from './bar'; 55bar("hello");`); 56 }, 57 edits: [ 58 { 59 subScenario: "incremental-declaration-changes", 60 modifyFs: changeBarParam 61 }, 62 { 63 subScenario: "incremental-declaration-changes", 64 modifyFs: changeBarParamBack, 65 }, 66 { 67 subScenario: "incremental-declaration-changes", 68 modifyFs: changeBarParam 69 }, 70 { 71 subScenario: "Fix Error", 72 modifyFs: fs => replaceText(fs, "/src/lazyIndex.ts", `bar("hello")`, "bar()") 73 }, 74 ] 75 }); 76 }); 77 78 function changeToIsolatedModules(fs: vfs.FileSystem) { 79 replaceText(fs, "/src/tsconfig.json", `"incremental": true`, `"incremental": true, "isolatedModules": true`); 80 } 81 82 function changeBarParam(fs: vfs.FileSystem) { 83 replaceText(fs, "/src/bar.ts", "param: string", ""); 84 } 85 86 function changeBarParamBack(fs: vfs.FileSystem) { 87 replaceText(fs, "/src/bar.ts", "foobar()", "foobar(param: string)"); 88 } 89} 90