From e831b6b1fad1f82f425f8e9af19fb460b4ec21e3 Mon Sep 17 00:00:00 2001 From: Ian Sutherland Date: Tue, 21 May 2019 10:32:52 -0600 Subject: [PATCH] Add test to make sure .d.ts files are ignored when checking for TypeScript project (#6858) --- test/fixtures/issue-5947-not-typescript/index.test.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/fixtures/issue-5947-not-typescript/index.test.js b/test/fixtures/issue-5947-not-typescript/index.test.js index c0d38261f6f..aacc783152c 100644 --- a/test/fixtures/issue-5947-not-typescript/index.test.js +++ b/test/fixtures/issue-5947-not-typescript/index.test.js @@ -16,6 +16,7 @@ test('Ignores node_modules when detecting TypeScript', async () => { 'package', 'index.ts', ]; + const dtsSrcPath = [testSetup.testDirectory, 'src', 'types', 'index.d.ts']; const tsSrcPath = path.join(testSetup.testDirectory, 'src', 'index.ts'); // Step 1. @@ -28,6 +29,13 @@ test('Ignores node_modules when detecting TypeScript', async () => { await testSetup.scripts.build(); expect(fs.existsSync(tsConfigPath)).toBe(false); + // Step 1b. + // See if src/types/index.d.ts is treated as a JS project + fs.mkdirSync(path.join(...dtsSrcPath.slice(0, 3))); + fs.writeFileSync(path.join(...dtsSrcPath)); + await testSetup.scripts.build(); + expect(fs.existsSync(tsConfigPath)).toBe(false); + // Step 2. // Add TS and ensure tsconfig.json is generated fs.writeFileSync(tsSrcPath);