From acac035aed64a23e71ae936cea1e59a595d622d7 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Mon, 22 Jun 2020 08:46:14 -0700 Subject: [PATCH] Add missing index.ts files to user projects (#39163) This makes the language service treat .js files inside node_modules as part of the parent project, so that you can view the same errors in the editor as you see in the baselines. Also update a comment in the parser that I missed in an earlier PR. --- src/compiler/parser.ts | 2 +- tests/cases/user/acorn/index.ts | 1 + tests/cases/user/acorn/tsconfig.json | 16 +++++++++++---- tests/cases/user/adonis-framework/index.ts | 1 + .../cases/user/adonis-framework/tsconfig.json | 16 +++++++++++---- tests/cases/user/assert/index.ts | 1 + tests/cases/user/assert/tsconfig.json | 16 +++++++++++---- tests/cases/user/async/index.ts | 1 + tests/cases/user/async/tsconfig.json | 2 +- tests/cases/user/bcryptjs/index.ts | 1 + tests/cases/user/bcryptjs/tsconfig.json | 14 +++++++++---- tests/cases/user/bluebird/index.ts | 1 + tests/cases/user/bluebird/tsconfig.json | 16 +++++++++++---- tests/cases/user/clear-require/index.ts | 1 + tests/cases/user/clear-require/tsconfig.json | 16 +++++++++++---- tests/cases/user/clone/index.ts | 1 + tests/cases/user/clone/tsconfig.json | 16 +++++++++++---- tests/cases/user/content-disposition/index.ts | 1 + .../user/content-disposition/tsconfig.json | 16 +++++++++++---- tests/cases/user/debug/index.ts | 1 + tests/cases/user/debug/tsconfig.json | 2 +- tests/cases/user/enhanced-resolve/index.ts | 1 + .../cases/user/enhanced-resolve/tsconfig.json | 18 ++++++++++++----- tests/cases/user/follow-redirects/index.ts | 1 + .../cases/user/follow-redirects/tsconfig.json | 16 +++++++++++---- tests/cases/user/graceful-fs/index.ts | 1 + tests/cases/user/graceful-fs/tsconfig.json | 16 +++++++++++---- tests/cases/user/lodash/index.ts | 1 + tests/cases/user/lodash/tsconfig.json | 20 ++++++++++++++----- tests/cases/user/minimatch/index.ts | 1 + tests/cases/user/minimatch/tsconfig.json | 16 +++++++++++---- tests/cases/user/npm/index.ts | 1 + tests/cases/user/npm/tsconfig.json | 17 ++++++++++++---- tests/cases/user/npmlog/index.ts | 1 + tests/cases/user/npmlog/tsconfig.json | 16 +++++++++++---- tests/cases/user/uglify-js/index.ts | 1 + tests/cases/user/uglify-js/tsconfig.json | 16 +++++++++++---- tests/cases/user/url-search-params/index.ts | 1 + .../user/url-search-params/tsconfig.json | 16 +++++++++++---- tests/cases/user/util/index.ts | 1 + tests/cases/user/util/tsconfig.json | 16 +++++++++++---- 41 files changed, 242 insertions(+), 77 deletions(-) create mode 100644 tests/cases/user/acorn/index.ts create mode 100644 tests/cases/user/adonis-framework/index.ts create mode 100644 tests/cases/user/assert/index.ts create mode 100644 tests/cases/user/async/index.ts create mode 100644 tests/cases/user/bcryptjs/index.ts create mode 100644 tests/cases/user/bluebird/index.ts create mode 100644 tests/cases/user/clear-require/index.ts create mode 100644 tests/cases/user/clone/index.ts create mode 100644 tests/cases/user/content-disposition/index.ts create mode 100644 tests/cases/user/debug/index.ts create mode 100644 tests/cases/user/enhanced-resolve/index.ts create mode 100644 tests/cases/user/follow-redirects/index.ts create mode 100644 tests/cases/user/graceful-fs/index.ts create mode 100644 tests/cases/user/lodash/index.ts create mode 100644 tests/cases/user/minimatch/index.ts create mode 100644 tests/cases/user/npm/index.ts create mode 100644 tests/cases/user/npmlog/index.ts create mode 100644 tests/cases/user/uglify-js/index.ts create mode 100644 tests/cases/user/url-search-params/index.ts create mode 100644 tests/cases/user/util/index.ts diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index df8c34e12f8..2cf85a563f5 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -3527,7 +3527,7 @@ namespace ts { type = finishNode(factory.createJSDocNonNullableType(type), pos); break; case SyntaxKind.QuestionToken: - // If not in JSDoc and next token is start of a type we have a conditional type + // If next token is start of a type we have a conditional type if (lookAhead(nextTokenIsStartOfType)) { return type; } diff --git a/tests/cases/user/acorn/index.ts b/tests/cases/user/acorn/index.ts new file mode 100644 index 00000000000..676c628c824 --- /dev/null +++ b/tests/cases/user/acorn/index.ts @@ -0,0 +1 @@ +import x = require('acorn'); \ No newline at end of file diff --git a/tests/cases/user/acorn/tsconfig.json b/tests/cases/user/acorn/tsconfig.json index 6ef664a2c1c..f544c4b4c9c 100644 --- a/tests/cases/user/acorn/tsconfig.json +++ b/tests/cases/user/acorn/tsconfig.json @@ -7,8 +7,16 @@ "noEmit": true, "allowJs": true, "checkJs": true, - "types": ["node"], - "lib": ["esnext", "dom"], + "types": [ + "node" + ], + "lib": [ + "esnext", + "dom" + ] }, - "include": ["node_modules/acorn"] -} + "include": [ + "node_modules/acorn", + "index.ts" + ] +} \ No newline at end of file diff --git a/tests/cases/user/adonis-framework/index.ts b/tests/cases/user/adonis-framework/index.ts new file mode 100644 index 00000000000..50b1a6f99df --- /dev/null +++ b/tests/cases/user/adonis-framework/index.ts @@ -0,0 +1 @@ +import x = require('adonis-framework/src/View'); diff --git a/tests/cases/user/adonis-framework/tsconfig.json b/tests/cases/user/adonis-framework/tsconfig.json index 829e8ff0730..f33b23f1ff0 100644 --- a/tests/cases/user/adonis-framework/tsconfig.json +++ b/tests/cases/user/adonis-framework/tsconfig.json @@ -7,8 +7,16 @@ "noEmit": true, "allowJs": true, "checkJs": true, - "types": ["node"], - "lib": ["esnext", "dom"], + "types": [ + "node" + ], + "lib": [ + "esnext", + "dom" + ] }, - "include": ["node_modules/adonis-framework"] -} + "include": [ + "node_modules/adonis-framework", + "index.ts" + ] +} \ No newline at end of file diff --git a/tests/cases/user/assert/index.ts b/tests/cases/user/assert/index.ts new file mode 100644 index 00000000000..315f4ace3b2 --- /dev/null +++ b/tests/cases/user/assert/index.ts @@ -0,0 +1 @@ +import x = require('assert'); \ No newline at end of file diff --git a/tests/cases/user/assert/tsconfig.json b/tests/cases/user/assert/tsconfig.json index 4c344cc1590..b3a8f2146af 100644 --- a/tests/cases/user/assert/tsconfig.json +++ b/tests/cases/user/assert/tsconfig.json @@ -7,8 +7,16 @@ "noEmit": true, "allowJs": true, "checkJs": true, - "types": ["node"], - "lib": ["esnext", "dom"], + "types": [ + "node" + ], + "lib": [ + "esnext", + "dom" + ] }, - "include": ["node_modules/assert"] -} + "include": [ + "node_modules/assert", + "index.ts" + ] +} \ No newline at end of file diff --git a/tests/cases/user/async/index.ts b/tests/cases/user/async/index.ts new file mode 100644 index 00000000000..0c1603b5169 --- /dev/null +++ b/tests/cases/user/async/index.ts @@ -0,0 +1 @@ +import async_ = require('async'); diff --git a/tests/cases/user/async/tsconfig.json b/tests/cases/user/async/tsconfig.json index b79170484bc..07bd8bd0765 100644 --- a/tests/cases/user/async/tsconfig.json +++ b/tests/cases/user/async/tsconfig.json @@ -10,5 +10,5 @@ "types": ["node"], "lib": ["esnext", "dom"], }, - "include": ["node_modules/async"] + "include": ["index.ts", "node_modules/async"] } diff --git a/tests/cases/user/bcryptjs/index.ts b/tests/cases/user/bcryptjs/index.ts new file mode 100644 index 00000000000..7f0cf7e269f --- /dev/null +++ b/tests/cases/user/bcryptjs/index.ts @@ -0,0 +1 @@ +import x = require('bcryptjs'); \ No newline at end of file diff --git a/tests/cases/user/bcryptjs/tsconfig.json b/tests/cases/user/bcryptjs/tsconfig.json index 032e5b5655e..6dde4d4051b 100644 --- a/tests/cases/user/bcryptjs/tsconfig.json +++ b/tests/cases/user/bcryptjs/tsconfig.json @@ -7,12 +7,18 @@ "noEmit": true, "allowJs": true, "checkJs": true, - "types": ["node"], - "lib": ["esnext", "dom"], + "types": [ + "node" + ], + "lib": [ + "esnext", + "dom" + ] }, "include": [ "node_modules/bcryptjs/scripts", "node_modules/bcryptjs/src", - "node_modules/bcryptjs/tests" + "node_modules/bcryptjs/tests", + "index.ts" ] -} +} \ No newline at end of file diff --git a/tests/cases/user/bluebird/index.ts b/tests/cases/user/bluebird/index.ts new file mode 100644 index 00000000000..d1aa6c2caef --- /dev/null +++ b/tests/cases/user/bluebird/index.ts @@ -0,0 +1 @@ +import x = require('bluebird'); \ No newline at end of file diff --git a/tests/cases/user/bluebird/tsconfig.json b/tests/cases/user/bluebird/tsconfig.json index b54158015a1..d482a57edb5 100644 --- a/tests/cases/user/bluebird/tsconfig.json +++ b/tests/cases/user/bluebird/tsconfig.json @@ -7,8 +7,16 @@ "noEmit": true, "allowJs": true, "checkJs": true, - "types": ["node"], - "lib": ["esnext", "dom"], + "types": [ + "node" + ], + "lib": [ + "esnext", + "dom" + ] }, - "include": ["node_modules/bluebird/js/release"] -} + "include": [ + "node_modules/bluebird/js/release", + "index.ts" + ] +} \ No newline at end of file diff --git a/tests/cases/user/clear-require/index.ts b/tests/cases/user/clear-require/index.ts new file mode 100644 index 00000000000..9cc48aaa2fe --- /dev/null +++ b/tests/cases/user/clear-require/index.ts @@ -0,0 +1 @@ +import x = require('clear-require'); \ No newline at end of file diff --git a/tests/cases/user/clear-require/tsconfig.json b/tests/cases/user/clear-require/tsconfig.json index 010d8edac98..862669ea89a 100644 --- a/tests/cases/user/clear-require/tsconfig.json +++ b/tests/cases/user/clear-require/tsconfig.json @@ -7,8 +7,16 @@ "noEmit": true, "allowJs": true, "checkJs": true, - "lib": ["esnext", "dom"], - "types": ["node"] + "lib": [ + "esnext", + "dom" + ], + "types": [ + "node" + ] }, - "include": ["node_modules/clear-require"] -} + "include": [ + "node_modules/clear-require", + "index.ts" + ] +} \ No newline at end of file diff --git a/tests/cases/user/clone/index.ts b/tests/cases/user/clone/index.ts new file mode 100644 index 00000000000..bc8deb71f9f --- /dev/null +++ b/tests/cases/user/clone/index.ts @@ -0,0 +1 @@ +import x = require('clone'); \ No newline at end of file diff --git a/tests/cases/user/clone/tsconfig.json b/tests/cases/user/clone/tsconfig.json index 569cb09985e..564efe47ce7 100644 --- a/tests/cases/user/clone/tsconfig.json +++ b/tests/cases/user/clone/tsconfig.json @@ -7,8 +7,16 @@ "noEmit": true, "allowJs": true, "checkJs": true, - "types": ["node"], - "lib": ["esnext", "dom"], + "types": [ + "node" + ], + "lib": [ + "esnext", + "dom" + ] }, - "include": ["node_modules/clone"] -} + "include": [ + "node_modules/clone", + "index.ts" + ] +} \ No newline at end of file diff --git a/tests/cases/user/content-disposition/index.ts b/tests/cases/user/content-disposition/index.ts new file mode 100644 index 00000000000..7181342cfb3 --- /dev/null +++ b/tests/cases/user/content-disposition/index.ts @@ -0,0 +1 @@ +import x = require('content-disposition'); \ No newline at end of file diff --git a/tests/cases/user/content-disposition/tsconfig.json b/tests/cases/user/content-disposition/tsconfig.json index d597d933d8a..c7e71839c70 100644 --- a/tests/cases/user/content-disposition/tsconfig.json +++ b/tests/cases/user/content-disposition/tsconfig.json @@ -7,8 +7,16 @@ "noEmit": true, "allowJs": true, "checkJs": true, - "types": ["node"], - "lib": ["esnext", "dom"], + "types": [ + "node" + ], + "lib": [ + "esnext", + "dom" + ] }, - "include": ["node_modules/content-disposition"] -} + "include": [ + "node_modules/content-disposition", + "index.ts" + ] +} \ No newline at end of file diff --git a/tests/cases/user/debug/index.ts b/tests/cases/user/debug/index.ts new file mode 100644 index 00000000000..24274f8f602 --- /dev/null +++ b/tests/cases/user/debug/index.ts @@ -0,0 +1 @@ +import debug = require('debug'); diff --git a/tests/cases/user/debug/tsconfig.json b/tests/cases/user/debug/tsconfig.json index 168535d6eb1..b8f2be327f8 100644 --- a/tests/cases/user/debug/tsconfig.json +++ b/tests/cases/user/debug/tsconfig.json @@ -10,5 +10,5 @@ "types": ["node"], "lib": ["esnext", "dom"], }, - "include": ["node_modules/debug"] + "include": ["index.ts", "node_modules/debug"] } diff --git a/tests/cases/user/enhanced-resolve/index.ts b/tests/cases/user/enhanced-resolve/index.ts new file mode 100644 index 00000000000..a138e9f0370 --- /dev/null +++ b/tests/cases/user/enhanced-resolve/index.ts @@ -0,0 +1 @@ +import x = require('enhanced-resolve'); \ No newline at end of file diff --git a/tests/cases/user/enhanced-resolve/tsconfig.json b/tests/cases/user/enhanced-resolve/tsconfig.json index 74226d5a6be..79ff04d24c2 100644 --- a/tests/cases/user/enhanced-resolve/tsconfig.json +++ b/tests/cases/user/enhanced-resolve/tsconfig.json @@ -7,10 +7,18 @@ "noEmit": true, "allowJs": true, "checkJs": true, - "types": ["node"], - "lib": ["esnext", "dom"], + "types": [ + "node" + ], + "lib": [ + "esnext", + "dom" + ], "module": "CommonJS", - "target": "esnext", + "target": "esnext" }, - "include": ["node_modules/enhanced-resolve"] -} + "include": [ + "node_modules/enhanced-resolve", + "index.ts" + ] +} \ No newline at end of file diff --git a/tests/cases/user/follow-redirects/index.ts b/tests/cases/user/follow-redirects/index.ts new file mode 100644 index 00000000000..3b9bd996729 --- /dev/null +++ b/tests/cases/user/follow-redirects/index.ts @@ -0,0 +1 @@ +import x = require('follow-redirects'); \ No newline at end of file diff --git a/tests/cases/user/follow-redirects/tsconfig.json b/tests/cases/user/follow-redirects/tsconfig.json index 2631eb02ac4..0693f0936c6 100644 --- a/tests/cases/user/follow-redirects/tsconfig.json +++ b/tests/cases/user/follow-redirects/tsconfig.json @@ -7,8 +7,16 @@ "noEmit": true, "allowJs": true, "checkJs": true, - "types": ["node"], - "lib": ["esnext", "dom"], + "types": [ + "node" + ], + "lib": [ + "esnext", + "dom" + ] }, - "include": ["node_modules/follow-redirects"] -} + "include": [ + "node_modules/follow-redirects", + "index.ts" + ] +} \ No newline at end of file diff --git a/tests/cases/user/graceful-fs/index.ts b/tests/cases/user/graceful-fs/index.ts new file mode 100644 index 00000000000..66e27087ada --- /dev/null +++ b/tests/cases/user/graceful-fs/index.ts @@ -0,0 +1 @@ +import x = require('graceful-fs'); \ No newline at end of file diff --git a/tests/cases/user/graceful-fs/tsconfig.json b/tests/cases/user/graceful-fs/tsconfig.json index 4a4435d0274..d055c1a785a 100644 --- a/tests/cases/user/graceful-fs/tsconfig.json +++ b/tests/cases/user/graceful-fs/tsconfig.json @@ -7,8 +7,16 @@ "noEmit": true, "allowJs": true, "checkJs": true, - "types": ["node"], - "lib": ["esnext", "dom"], + "types": [ + "node" + ], + "lib": [ + "esnext", + "dom" + ] }, - "include": ["node_modules/graceful-fs"] -} + "include": [ + "node_modules/graceful-fs", + "index.ts" + ] +} \ No newline at end of file diff --git a/tests/cases/user/lodash/index.ts b/tests/cases/user/lodash/index.ts new file mode 100644 index 00000000000..dc7787aeb9a --- /dev/null +++ b/tests/cases/user/lodash/index.ts @@ -0,0 +1 @@ +import x = require('lodash'); \ No newline at end of file diff --git a/tests/cases/user/lodash/tsconfig.json b/tests/cases/user/lodash/tsconfig.json index a50a9a85374..dfde145a90d 100644 --- a/tests/cases/user/lodash/tsconfig.json +++ b/tests/cases/user/lodash/tsconfig.json @@ -7,9 +7,19 @@ "noEmit": true, "allowJs": true, "checkJs": true, - "types": ["node"], - "lib": ["esnext", "dom"], + "types": [ + "node" + ], + "lib": [ + "esnext", + "dom" + ] }, - "include": ["node_modules/lodash"], - "exclude": ["node_modules/lodash/lodash.js"] -} + "include": [ + "node_modules/lodash", + "index.ts" + ], + "exclude": [ + "node_modules/lodash/lodash.js" + ] +} \ No newline at end of file diff --git a/tests/cases/user/minimatch/index.ts b/tests/cases/user/minimatch/index.ts new file mode 100644 index 00000000000..a09b6875a6e --- /dev/null +++ b/tests/cases/user/minimatch/index.ts @@ -0,0 +1 @@ +import x = require('minimatch'); \ No newline at end of file diff --git a/tests/cases/user/minimatch/tsconfig.json b/tests/cases/user/minimatch/tsconfig.json index a78270eceac..3e19afb37c0 100644 --- a/tests/cases/user/minimatch/tsconfig.json +++ b/tests/cases/user/minimatch/tsconfig.json @@ -7,8 +7,16 @@ "noEmit": true, "allowJs": true, "checkJs": true, - "types": ["node"], - "lib": ["esnext", "dom"], + "types": [ + "node" + ], + "lib": [ + "esnext", + "dom" + ] }, - "include": ["node_modules/minimatch"] -} + "include": [ + "node_modules/minimatch", + "index.ts" + ] +} \ No newline at end of file diff --git a/tests/cases/user/npm/index.ts b/tests/cases/user/npm/index.ts new file mode 100644 index 00000000000..15de2c13626 --- /dev/null +++ b/tests/cases/user/npm/index.ts @@ -0,0 +1 @@ +import x = require('npm'); \ No newline at end of file diff --git a/tests/cases/user/npm/tsconfig.json b/tests/cases/user/npm/tsconfig.json index a57d3622164..f1bfac4f0d3 100644 --- a/tests/cases/user/npm/tsconfig.json +++ b/tests/cases/user/npm/tsconfig.json @@ -7,8 +7,17 @@ "noEmit": true, "allowJs": true, "checkJs": true, - "types": ["node"], - "lib": ["esnext", "dom", "scripthost"], + "types": [ + "node" + ], + "lib": [ + "esnext", + "dom", + "scripthost" + ] }, - "include": ["node_modules/npm"] -} + "include": [ + "node_modules/npm", + "index.ts" + ] +} \ No newline at end of file diff --git a/tests/cases/user/npmlog/index.ts b/tests/cases/user/npmlog/index.ts new file mode 100644 index 00000000000..1f7d2d807bc --- /dev/null +++ b/tests/cases/user/npmlog/index.ts @@ -0,0 +1 @@ +import x = require('npmlog'); \ No newline at end of file diff --git a/tests/cases/user/npmlog/tsconfig.json b/tests/cases/user/npmlog/tsconfig.json index e41cb272df3..f79a3582acf 100644 --- a/tests/cases/user/npmlog/tsconfig.json +++ b/tests/cases/user/npmlog/tsconfig.json @@ -7,8 +7,16 @@ "noEmit": true, "allowJs": true, "checkJs": true, - "types": ["node"], - "lib": ["esnext", "dom"], + "types": [ + "node" + ], + "lib": [ + "esnext", + "dom" + ] }, - "include": ["node_modules/npmlog"] -} + "include": [ + "node_modules/npmlog", + "index.ts" + ] +} \ No newline at end of file diff --git a/tests/cases/user/uglify-js/index.ts b/tests/cases/user/uglify-js/index.ts new file mode 100644 index 00000000000..cbc12203230 --- /dev/null +++ b/tests/cases/user/uglify-js/index.ts @@ -0,0 +1 @@ +import x = require('uglify-js'); \ No newline at end of file diff --git a/tests/cases/user/uglify-js/tsconfig.json b/tests/cases/user/uglify-js/tsconfig.json index 3c4dfc18abd..a27b4936d71 100644 --- a/tests/cases/user/uglify-js/tsconfig.json +++ b/tests/cases/user/uglify-js/tsconfig.json @@ -7,8 +7,16 @@ "noEmit": true, "allowJs": true, "checkJs": true, - "types": ["node"], - "lib": ["esnext", "dom"], + "types": [ + "node" + ], + "lib": [ + "esnext", + "dom" + ] }, - "include": ["node_modules/uglify-js"] -} + "include": [ + "node_modules/uglify-js", + "index.ts" + ] +} \ No newline at end of file diff --git a/tests/cases/user/url-search-params/index.ts b/tests/cases/user/url-search-params/index.ts new file mode 100644 index 00000000000..2be6170acac --- /dev/null +++ b/tests/cases/user/url-search-params/index.ts @@ -0,0 +1 @@ +import x = require('url-search-params'); \ No newline at end of file diff --git a/tests/cases/user/url-search-params/tsconfig.json b/tests/cases/user/url-search-params/tsconfig.json index 113a87b9e4a..3b6e76f7611 100644 --- a/tests/cases/user/url-search-params/tsconfig.json +++ b/tests/cases/user/url-search-params/tsconfig.json @@ -7,8 +7,16 @@ "noEmit": true, "allowJs": true, "checkJs": true, - "types": ["node"], - "lib": ["esnext", "dom"], + "types": [ + "node" + ], + "lib": [ + "esnext", + "dom" + ] }, - "include": ["node_modules/url-search-params/build/url-search-params.node.js"] -} + "include": [ + "node_modules/url-search-params/build/url-search-params.node.js", + "index.ts" + ] +} \ No newline at end of file diff --git a/tests/cases/user/util/index.ts b/tests/cases/user/util/index.ts new file mode 100644 index 00000000000..dfb94ec3900 --- /dev/null +++ b/tests/cases/user/util/index.ts @@ -0,0 +1 @@ +import x = require('util'); \ No newline at end of file diff --git a/tests/cases/user/util/tsconfig.json b/tests/cases/user/util/tsconfig.json index ca58940aa02..66b5f11df2b 100644 --- a/tests/cases/user/util/tsconfig.json +++ b/tests/cases/user/util/tsconfig.json @@ -7,8 +7,16 @@ "noEmit": true, "allowJs": true, "checkJs": true, - "types": ["node"], - "lib": ["esnext", "dom"], + "types": [ + "node" + ], + "lib": [ + "esnext", + "dom" + ] }, - "include": ["node_modules/util"] -} + "include": [ + "node_modules/util", + "index.ts" + ] +} \ No newline at end of file