diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 532c25277cfc3..ae33a2bda5c0d 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -2806,10 +2806,10 @@ namespace ts { return symbol; }); if (symbol) { - const flags = isClassExpression(node.right) ? - SymbolFlags.Property | SymbolFlags.ExportValue | SymbolFlags.Class : - SymbolFlags.Property | SymbolFlags.ExportValue; - declareSymbol(symbol.exports!, symbol, node.left, flags, SymbolFlags.None); + const isAlias = isAliasableExpression(node.right) && (isExportsIdentifier(node.left.expression) || isModuleExportsAccessExpression(node.left.expression)); + const flags = isAlias ? SymbolFlags.Alias : SymbolFlags.Property | SymbolFlags.ExportValue; + const excludeFlags = isAlias ? SymbolFlags.AliasExcludes : SymbolFlags.None; + declareSymbol(symbol.exports!, symbol, node.left, flags, excludeFlags); } } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index d17f444f165d2..766ddc027090a 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -5507,6 +5507,7 @@ namespace ts { export const enum AssignmentDeclarationKind { None, /// exports.name = expr + /// module.exports.name = expr ExportsProperty, /// module.exports = expr ModuleExports, diff --git a/tests/baselines/reference/commonJSImportClassExpression.js b/tests/baselines/reference/commonJSImportClassExpression.js new file mode 100644 index 0000000000000..327fced006e3c --- /dev/null +++ b/tests/baselines/reference/commonJSImportClassExpression.js @@ -0,0 +1,40 @@ +//// [tests/cases/conformance/salsa/commonJSImportClassExpression.ts] //// + +//// [main.js] +const { K } = require("./mod1"); +/** @param {K} k */ +function f(k) { + k.values() +} + +//// [mod1.js] +exports.K = class K { + values() { + } +}; + + +//// [mod1.js] +"use strict"; +exports.K = /** @class */ (function () { + function K() { + } + K.prototype.values = function () { + }; + return K; +}()); +//// [main.js] +"use strict"; +var K = require("./mod1").K; +/** @param {K} k */ +function f(k) { + k.values(); +} + + +//// [mod1.d.ts] +export class K { + values(): void; +} +//// [main.d.ts] +export {}; diff --git a/tests/baselines/reference/commonJSImportClassExpression.symbols b/tests/baselines/reference/commonJSImportClassExpression.symbols new file mode 100644 index 0000000000000..25f9f440bfb65 --- /dev/null +++ b/tests/baselines/reference/commonJSImportClassExpression.symbols @@ -0,0 +1,29 @@ +=== tests/cases/conformance/salsa/main.js === +const { K } = require("./mod1"); +>K : Symbol(K, Decl(main.js, 0, 7)) +>require : Symbol(require) +>"./mod1" : Symbol("tests/cases/conformance/salsa/mod1", Decl(mod1.js, 0, 0)) + +/** @param {K} k */ +function f(k) { +>f : Symbol(f, Decl(main.js, 0, 32)) +>k : Symbol(k, Decl(main.js, 2, 11)) + + k.values() +>k.values : Symbol(K.values, Decl(mod1.js, 0, 21)) +>k : Symbol(k, Decl(main.js, 2, 11)) +>values : Symbol(K.values, Decl(mod1.js, 0, 21)) +} + +=== tests/cases/conformance/salsa/mod1.js === +exports.K = class K { +>exports.K : Symbol(K, Decl(mod1.js, 0, 0)) +>exports : Symbol(K, Decl(mod1.js, 0, 0)) +>K : Symbol(K, Decl(mod1.js, 0, 0)) +>K : Symbol(K, Decl(mod1.js, 0, 11)) + + values() { +>values : Symbol(K.values, Decl(mod1.js, 0, 21)) + } +}; + diff --git a/tests/baselines/reference/commonJSImportClassExpression.types b/tests/baselines/reference/commonJSImportClassExpression.types new file mode 100644 index 0000000000000..f7c5b90541e2a --- /dev/null +++ b/tests/baselines/reference/commonJSImportClassExpression.types @@ -0,0 +1,33 @@ +=== tests/cases/conformance/salsa/main.js === +const { K } = require("./mod1"); +>K : typeof K +>require("./mod1") : typeof import("tests/cases/conformance/salsa/mod1") +>require : any +>"./mod1" : "./mod1" + +/** @param {K} k */ +function f(k) { +>f : (k: K) => void +>k : K + + k.values() +>k.values() : void +>k.values : () => void +>k : K +>values : () => void +} + +=== tests/cases/conformance/salsa/mod1.js === +exports.K = class K { +>exports.K = class K { values() { }} : typeof K +>exports.K : typeof K +>exports : typeof import("tests/cases/conformance/salsa/mod1") +>K : typeof K +>class K { values() { }} : typeof K +>K : typeof K + + values() { +>values : () => void + } +}; + diff --git a/tests/baselines/reference/commonJSImportClassTypeReference.js b/tests/baselines/reference/commonJSImportClassTypeReference.js new file mode 100644 index 0000000000000..3d860455301df --- /dev/null +++ b/tests/baselines/reference/commonJSImportClassTypeReference.js @@ -0,0 +1,44 @@ +//// [tests/cases/conformance/salsa/commonJSImportClassTypeReference.ts] //// + +//// [main.js] +const { K } = require("./mod1"); +/** @param {K} k */ +function f(k) { + k.values() +} + +//// [mod1.js] +class K { + values() { + return new K() + } +} +exports.K = K; + + +//// [mod1.js] +"use strict"; +var K = /** @class */ (function () { + function K() { + } + K.prototype.values = function () { + return new K(); + }; + return K; +}()); +exports.K = K; +//// [main.js] +"use strict"; +var K = require("./mod1").K; +/** @param {K} k */ +function f(k) { + k.values(); +} + + +//// [mod1.d.ts] +export class K { + values(): K; +} +//// [main.d.ts] +export {}; diff --git a/tests/baselines/reference/commonJSImportClassTypeReference.symbols b/tests/baselines/reference/commonJSImportClassTypeReference.symbols new file mode 100644 index 0000000000000..f0d1198c71a16 --- /dev/null +++ b/tests/baselines/reference/commonJSImportClassTypeReference.symbols @@ -0,0 +1,34 @@ +=== tests/cases/conformance/salsa/main.js === +const { K } = require("./mod1"); +>K : Symbol(K, Decl(main.js, 0, 7)) +>require : Symbol(require) +>"./mod1" : Symbol("tests/cases/conformance/salsa/mod1", Decl(mod1.js, 0, 0)) + +/** @param {K} k */ +function f(k) { +>f : Symbol(f, Decl(main.js, 0, 32)) +>k : Symbol(k, Decl(main.js, 2, 11)) + + k.values() +>k.values : Symbol(K.values, Decl(mod1.js, 0, 9)) +>k : Symbol(k, Decl(main.js, 2, 11)) +>values : Symbol(K.values, Decl(mod1.js, 0, 9)) +} + +=== tests/cases/conformance/salsa/mod1.js === +class K { +>K : Symbol(K, Decl(mod1.js, 0, 0)) + + values() { +>values : Symbol(K.values, Decl(mod1.js, 0, 9)) + + return new K() +>K : Symbol(K, Decl(mod1.js, 0, 0)) + } +} +exports.K = K; +>exports.K : Symbol(K, Decl(mod1.js, 4, 1)) +>exports : Symbol(K, Decl(mod1.js, 4, 1)) +>K : Symbol(K, Decl(mod1.js, 4, 1)) +>K : Symbol(K, Decl(mod1.js, 0, 0)) + diff --git a/tests/baselines/reference/commonJSImportClassTypeReference.types b/tests/baselines/reference/commonJSImportClassTypeReference.types new file mode 100644 index 0000000000000..edbd688f01f3f --- /dev/null +++ b/tests/baselines/reference/commonJSImportClassTypeReference.types @@ -0,0 +1,38 @@ +=== tests/cases/conformance/salsa/main.js === +const { K } = require("./mod1"); +>K : typeof K +>require("./mod1") : typeof import("tests/cases/conformance/salsa/mod1") +>require : any +>"./mod1" : "./mod1" + +/** @param {K} k */ +function f(k) { +>f : (k: K) => void +>k : K + + k.values() +>k.values() : K +>k.values : () => K +>k : K +>values : () => K +} + +=== tests/cases/conformance/salsa/mod1.js === +class K { +>K : K + + values() { +>values : () => K + + return new K() +>new K() : K +>K : typeof K + } +} +exports.K = K; +>exports.K = K : typeof K +>exports.K : typeof K +>exports : typeof import("tests/cases/conformance/salsa/mod1") +>K : typeof K +>K : typeof K + diff --git a/tests/baselines/reference/commonJSImportNestedClassTypeReference.js b/tests/baselines/reference/commonJSImportNestedClassTypeReference.js new file mode 100644 index 0000000000000..24dc221a727b7 --- /dev/null +++ b/tests/baselines/reference/commonJSImportNestedClassTypeReference.js @@ -0,0 +1,48 @@ +//// [tests/cases/conformance/salsa/commonJSImportNestedClassTypeReference.ts] //// + +//// [main.js] +const { K } = require("./mod1"); +/** @param {K} k */ +function f(k) { + k.values() +} + +//// [mod1.js] +var NS = {} +NS.K =class { + values() { + return new NS.K() + } +} +exports.K = NS.K; + + +//// [mod1.js] +"use strict"; +var NS = {}; +NS.K = /** @class */ (function () { + function K() { + } + K.prototype.values = function () { + return new NS.K(); + }; + return K; +}()); +exports.K = NS.K; +//// [main.js] +"use strict"; +var K = require("./mod1").K; +/** @param {K} k */ +function f(k) { + k.values(); +} + + +//// [mod1.d.ts] +export var K: { + new (): { + values(): any; + }; +}; +//// [main.d.ts] +export {}; diff --git a/tests/baselines/reference/commonJSImportNestedClassTypeReference.symbols b/tests/baselines/reference/commonJSImportNestedClassTypeReference.symbols new file mode 100644 index 0000000000000..fe96f34558a18 --- /dev/null +++ b/tests/baselines/reference/commonJSImportNestedClassTypeReference.symbols @@ -0,0 +1,43 @@ +=== tests/cases/conformance/salsa/main.js === +const { K } = require("./mod1"); +>K : Symbol(K, Decl(main.js, 0, 7)) +>require : Symbol(require) +>"./mod1" : Symbol("tests/cases/conformance/salsa/mod1", Decl(mod1.js, 0, 0)) + +/** @param {K} k */ +function f(k) { +>f : Symbol(f, Decl(main.js, 0, 32)) +>k : Symbol(k, Decl(main.js, 2, 11)) + + k.values() +>k.values : Symbol(K.values, Decl(mod1.js, 1, 13)) +>k : Symbol(k, Decl(main.js, 2, 11)) +>values : Symbol(K.values, Decl(mod1.js, 1, 13)) +} + +=== tests/cases/conformance/salsa/mod1.js === +var NS = {} +>NS : Symbol(NS, Decl(mod1.js, 0, 3), Decl(mod1.js, 0, 11)) + +NS.K =class { +>NS.K : Symbol(K, Decl(mod1.js, 0, 11)) +>NS : Symbol(NS, Decl(mod1.js, 0, 3), Decl(mod1.js, 0, 11)) +>K : Symbol(K, Decl(mod1.js, 0, 11)) + + values() { +>values : Symbol(K.values, Decl(mod1.js, 1, 13)) + + return new NS.K() +>NS.K : Symbol(K, Decl(mod1.js, 0, 11)) +>NS : Symbol(NS, Decl(mod1.js, 0, 3), Decl(mod1.js, 0, 11)) +>K : Symbol(K, Decl(mod1.js, 0, 11)) + } +} +exports.K = NS.K; +>exports.K : Symbol(K, Decl(mod1.js, 5, 1)) +>exports : Symbol(K, Decl(mod1.js, 5, 1)) +>K : Symbol(K, Decl(mod1.js, 5, 1)) +>NS.K : Symbol(K, Decl(mod1.js, 0, 11)) +>NS : Symbol(NS, Decl(mod1.js, 0, 3), Decl(mod1.js, 0, 11)) +>K : Symbol(K, Decl(mod1.js, 0, 11)) + diff --git a/tests/baselines/reference/commonJSImportNestedClassTypeReference.types b/tests/baselines/reference/commonJSImportNestedClassTypeReference.types new file mode 100644 index 0000000000000..f5b746cbd9f50 --- /dev/null +++ b/tests/baselines/reference/commonJSImportNestedClassTypeReference.types @@ -0,0 +1,50 @@ +=== tests/cases/conformance/salsa/main.js === +const { K } = require("./mod1"); +>K : typeof K +>require("./mod1") : typeof import("tests/cases/conformance/salsa/mod1") +>require : any +>"./mod1" : "./mod1" + +/** @param {K} k */ +function f(k) { +>f : (k: K) => void +>k : K + + k.values() +>k.values() : K +>k.values : () => K +>k : K +>values : () => K +} + +=== tests/cases/conformance/salsa/mod1.js === +var NS = {} +>NS : typeof NS +>{} : {} + +NS.K =class { +>NS.K =class { values() { return new NS.K() }} : typeof K +>NS.K : typeof K +>NS : typeof NS +>K : typeof K +>class { values() { return new NS.K() }} : typeof K + + values() { +>values : () => K + + return new NS.K() +>new NS.K() : K +>NS.K : typeof K +>NS : typeof NS +>K : typeof K + } +} +exports.K = NS.K; +>exports.K = NS.K : typeof K +>exports.K : typeof K +>exports : typeof import("tests/cases/conformance/salsa/mod1") +>K : typeof K +>NS.K : typeof K +>NS : typeof NS +>K : typeof K + diff --git a/tests/baselines/reference/exportNestedNamespaces.symbols b/tests/baselines/reference/exportNestedNamespaces.symbols index 9afe4840f3414..a63a81c7545d1 100644 --- a/tests/baselines/reference/exportNestedNamespaces.symbols +++ b/tests/baselines/reference/exportNestedNamespaces.symbols @@ -66,9 +66,9 @@ function f(c, classic) { >x : Symbol(K.x, Decl(mod.js, 1, 27)) classic.p ->classic.p : Symbol(Classic.p, Decl(mod.js, 5, 19)) +>classic.p : Symbol(s.Classic.p, Decl(mod.js, 5, 19)) >classic : Symbol(classic, Decl(use.js, 9, 13)) ->p : Symbol(Classic.p, Decl(mod.js, 5, 19)) +>p : Symbol(s.Classic.p, Decl(mod.js, 5, 19)) } diff --git a/tests/baselines/reference/exportNestedNamespaces.types b/tests/baselines/reference/exportNestedNamespaces.types index 28cb0a5fad3dc..a6a6467a637c2 100644 --- a/tests/baselines/reference/exportNestedNamespaces.types +++ b/tests/baselines/reference/exportNestedNamespaces.types @@ -58,11 +58,11 @@ k.x >x : number var classic = new s.Classic() ->classic : Classic ->new s.Classic() : Classic ->s.Classic : typeof Classic +>classic : s.Classic +>new s.Classic() : s.Classic +>s.Classic : typeof s.Classic >s : typeof s ->Classic : typeof Classic +>Classic : typeof s.Classic /** @param {s.n.K} c @@ -70,7 +70,7 @@ var classic = new s.Classic() function f(c, classic) { >f : (c: K, classic: s.Classic) => void >c : K ->classic : Classic +>classic : s.Classic c.x >c.x : number @@ -79,7 +79,7 @@ function f(c, classic) { classic.p >classic.p : number ->classic : Classic +>classic : s.Classic >p : number } diff --git a/tests/baselines/reference/findAllRefsCommonJsRequire2.baseline.jsonc b/tests/baselines/reference/findAllRefsCommonJsRequire2.baseline.jsonc index f7b3b0ca60b74..e647bf183db75 100644 --- a/tests/baselines/reference/findAllRefsCommonJsRequire2.baseline.jsonc +++ b/tests/baselines/reference/findAllRefsCommonJsRequire2.baseline.jsonc @@ -13,7 +13,7 @@ "containerName": "", "fileName": "/b.js", "kind": "alias", - "name": "(alias) (property) f: () => void\nimport f", + "name": "(alias) function f(): void\nimport f", "textSpan": { "start": 8, "length": 1 @@ -36,16 +36,8 @@ "kind": "space" }, { - "text": "(", - "kind": "punctuation" - }, - { - "text": "property", - "kind": "text" - }, - { - "text": ")", - "kind": "punctuation" + "text": "function", + "kind": "keyword" }, { "text": " ", @@ -55,14 +47,6 @@ "text": "f", "kind": "aliasName" }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, { "text": "(", "kind": "punctuation" @@ -72,11 +56,7 @@ "kind": "punctuation" }, { - "text": " ", - "kind": "space" - }, - { - "text": "=>", + "text": ":", "kind": "punctuation" }, { diff --git a/tests/baselines/reference/jsDeclarationsExportDoubleAssignmentInClosure.js b/tests/baselines/reference/jsDeclarationsExportDoubleAssignmentInClosure.js index bb5a076f1bcb4..c66ea97d9ca19 100644 --- a/tests/baselines/reference/jsDeclarationsExportDoubleAssignmentInClosure.js +++ b/tests/baselines/reference/jsDeclarationsExportDoubleAssignmentInClosure.js @@ -4,8 +4,12 @@ function foo() { module.exports = exports = function (o) { return (o == null) ? create(base) : defineProperties(Object(o), descriptors); }; - exports.methods = methods; -} + const m = function () { + // I have no idea what to put here + } + exports.methods = m; +} + //// [index.js] // @ts-nocheck @@ -13,13 +17,17 @@ function foo() { module.exports = exports = function (o) { return (o == null) ? create(base) : defineProperties(Object(o), descriptors); }; - exports.methods = methods; + var m = function () { + // I have no idea what to put here + }; + exports.methods = m; } //// [index.d.ts] declare function _exports(o: any): any; declare namespace _exports { - const methods: any; + export { m as methods }; } export = _exports; +declare function m(): void; diff --git a/tests/baselines/reference/jsDeclarationsExportDoubleAssignmentInClosure.symbols b/tests/baselines/reference/jsDeclarationsExportDoubleAssignmentInClosure.symbols index 5031ff1166d3a..27d5ca6f16f57 100644 --- a/tests/baselines/reference/jsDeclarationsExportDoubleAssignmentInClosure.symbols +++ b/tests/baselines/reference/jsDeclarationsExportDoubleAssignmentInClosure.symbols @@ -16,7 +16,14 @@ function foo() { >o : Symbol(o, Decl(index.js, 2, 41)) }; - exports.methods = methods; ->exports : Symbol(methods, Decl(index.js, 4, 6)) ->methods : Symbol(methods, Decl(index.js, 4, 6)) + const m = function () { +>m : Symbol(m, Decl(index.js, 5, 9)) + + // I have no idea what to put here + } + exports.methods = m; +>exports : Symbol(methods, Decl(index.js, 7, 5)) +>methods : Symbol(methods, Decl(index.js, 7, 5)) +>m : Symbol(m, Decl(index.js, 5, 9)) } + diff --git a/tests/baselines/reference/jsDeclarationsExportDoubleAssignmentInClosure.types b/tests/baselines/reference/jsDeclarationsExportDoubleAssignmentInClosure.types index c58351d7a668b..dab4aaf35fcf0 100644 --- a/tests/baselines/reference/jsDeclarationsExportDoubleAssignmentInClosure.types +++ b/tests/baselines/reference/jsDeclarationsExportDoubleAssignmentInClosure.types @@ -30,10 +30,17 @@ function foo() { >descriptors : error }; - exports.methods = methods; ->exports.methods = methods : error + const m = function () { +>m : () => void +>function () { // I have no idea what to put here } : () => void + + // I have no idea what to put here + } + exports.methods = m; +>exports.methods = m : () => void >exports.methods : any >exports : any >methods : any ->methods : error +>m : () => void } + diff --git a/tests/baselines/reference/jsDeclarationsFunctionsCjs.js b/tests/baselines/reference/jsDeclarationsFunctionsCjs.js index 41d6e017dbd58..e933efe112cb3 100644 --- a/tests/baselines/reference/jsDeclarationsFunctionsCjs.js +++ b/tests/baselines/reference/jsDeclarationsFunctionsCjs.js @@ -130,6 +130,10 @@ export namespace f { import self = f; export { self }; } +export function i(): void; +export function j(): void; +declare class Cls { +} /** * @param {{x: string}} a * @param {{y: typeof module.exports.b}} b @@ -146,7 +150,7 @@ export function g(a: { * @param {{x: string}} a * @param {{y: typeof module.exports.b}} b */ -export function h(a: { +declare function hh(a: { x: string; }, b: { y: { @@ -154,10 +158,4 @@ export function h(a: { cat: string; }; }): void; -export function i(): void; -export function ii(): void; -export function jj(): void; -export function j(): void; -declare class Cls { -} -export {}; +export { hh as h, i as ii, j as jj }; diff --git a/tests/baselines/reference/jsDeclarationsImportAliasExposedWithinNamespaceCjs.errors.txt b/tests/baselines/reference/jsDeclarationsImportAliasExposedWithinNamespaceCjs.errors.txt deleted file mode 100644 index c771f9c9d664d..0000000000000 --- a/tests/baselines/reference/jsDeclarationsImportAliasExposedWithinNamespaceCjs.errors.txt +++ /dev/null @@ -1,55 +0,0 @@ -tests/cases/conformance/jsdoc/declarations/file2.js(12,31): error TS2694: Namespace '"tests/cases/conformance/jsdoc/declarations/file".myTypes' has no exported member 'typeC'. - - -==== tests/cases/conformance/jsdoc/declarations/file2.js (1 errors) ==== - const {myTypes} = require('./file.js'); - - /** - * @namespace testFnTypes - * @global - * @type {Object} - */ - const testFnTypes = { - // SOME PROPS HERE - }; - - /** @typedef {boolean|myTypes.typeC} testFnTypes.input */ - ~~~~~ -!!! error TS2694: Namespace '"tests/cases/conformance/jsdoc/declarations/file".myTypes' has no exported member 'typeC'. - - /** - * @function testFn - * @description A test function. - * @param {testFnTypes.input} input - Input. - * @returns {number|null} Result. - */ - function testFn(input) { - if (typeof input === 'number') { - return 2 * input; - } else { - return null; - } - } - - module.exports = {testFn, testFnTypes}; -==== tests/cases/conformance/jsdoc/declarations/file.js (0 errors) ==== - /** - * @namespace myTypes - * @global - * @type {Object} - */ - const myTypes = { - // SOME PROPS HERE - }; - - /** @typedef {string|RegExp|Array} myTypes.typeA */ - - /** - * @typedef myTypes.typeB - * @property {myTypes.typeA} prop1 - Prop 1. - * @property {string} prop2 - Prop 2. - */ - - /** @typedef {myTypes.typeB|Function} myTypes.typeC */ - - exports.myTypes = myTypes; \ No newline at end of file diff --git a/tests/baselines/reference/jsDeclarationsImportAliasExposedWithinNamespaceCjs.js b/tests/baselines/reference/jsDeclarationsImportAliasExposedWithinNamespaceCjs.js index 0c0e0ba34cc52..aeaa3107de27f 100644 --- a/tests/baselines/reference/jsDeclarationsImportAliasExposedWithinNamespaceCjs.js +++ b/tests/baselines/reference/jsDeclarationsImportAliasExposedWithinNamespaceCjs.js @@ -54,9 +54,28 @@ module.exports = {testFn, testFnTypes}; //// [file.d.ts] -export var myTypes: { +/** + * @namespace myTypes + * @global + * @type {Object} + */ +export const myTypes: { [x: string]: any; }; +export namespace myTypes { + type typeA = string | RegExp | (string | RegExp)[]; + type typeB = { + /** + * - Prop 1. + */ + prop1: string | RegExp | (string | RegExp)[]; + /** + * - Prop 2. + */ + prop2: string; + }; + type typeC = Function | typeB; +} //// [file2.d.ts] /** @typedef {boolean|myTypes.typeC} testFnTypes.input */ /** @@ -65,7 +84,16 @@ export var myTypes: { * @param {testFnTypes.input} input - Input. * @returns {number|null} Result. */ -export function testFn(input: any): number | null; +export function testFn(input: boolean | Function | { + /** + * - Prop 1. + */ + prop1: string | RegExp | (string | RegExp)[]; + /** + * - Prop 2. + */ + prop2: string; +}): number | null; /** * @namespace testFnTypes * @global @@ -75,5 +103,14 @@ export const testFnTypes: { [x: string]: any; }; export namespace testFnTypes { - type input = any; + type input = boolean | Function | { + /** + * - Prop 1. + */ + prop1: string | RegExp | (string | RegExp)[]; + /** + * - Prop 2. + */ + prop2: string; + }; } diff --git a/tests/baselines/reference/jsDeclarationsImportAliasExposedWithinNamespaceCjs.types b/tests/baselines/reference/jsDeclarationsImportAliasExposedWithinNamespaceCjs.types index fd1aae4d8ca5e..6af711dea185c 100644 --- a/tests/baselines/reference/jsDeclarationsImportAliasExposedWithinNamespaceCjs.types +++ b/tests/baselines/reference/jsDeclarationsImportAliasExposedWithinNamespaceCjs.types @@ -27,18 +27,18 @@ const testFnTypes = { */ function testFn(input) { >testFn : (input: testFnTypes.input) => number | null ->input : any +>input : boolean | Function | { prop1: string | RegExp | (string | RegExp)[]; prop2: string; } if (typeof input === 'number') { >typeof input === 'number' : boolean >typeof input : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" ->input : any +>input : boolean | Function | { prop1: string | RegExp | (string | RegExp)[]; prop2: string; } >'number' : "number" return 2 * input; >2 * input : number >2 : 2 ->input : number +>input : never } else { return null; @@ -47,12 +47,12 @@ function testFn(input) { } module.exports = {testFn, testFnTypes}; ->module.exports = {testFn, testFnTypes} : { testFn: (input: any) => number; testFnTypes: { [x: string]: any; }; } ->module.exports : { testFn: (input: any) => number; testFnTypes: { [x: string]: any; }; } ->module : { "\"tests/cases/conformance/jsdoc/declarations/file2\"": { testFn: (input: any) => number; testFnTypes: { [x: string]: any; }; }; } ->exports : { testFn: (input: any) => number; testFnTypes: { [x: string]: any; }; } ->{testFn, testFnTypes} : { testFn: (input: any) => number; testFnTypes: { [x: string]: any; }; } ->testFn : (input: any) => number +>module.exports = {testFn, testFnTypes} : { testFn: (input: boolean | Function | { prop1: string | RegExp | (string | RegExp)[]; prop2: string; }) => number; testFnTypes: { [x: string]: any; }; } +>module.exports : { testFn: (input: boolean | Function | { prop1: string | RegExp | (string | RegExp)[]; prop2: string; }) => number; testFnTypes: { [x: string]: any; }; } +>module : { "\"tests/cases/conformance/jsdoc/declarations/file2\"": { testFn: (input: boolean | Function | { prop1: string | RegExp | (string | RegExp)[]; prop2: string; }) => number; testFnTypes: { [x: string]: any; }; }; } +>exports : { testFn: (input: boolean | Function | { prop1: string | RegExp | (string | RegExp)[]; prop2: string; }) => number; testFnTypes: { [x: string]: any; }; } +>{testFn, testFnTypes} : { testFn: (input: boolean | Function | { prop1: string | RegExp | (string | RegExp)[]; prop2: string; }) => number; testFnTypes: { [x: string]: any; }; } +>testFn : (input: boolean | Function | { prop1: string | RegExp | (string | RegExp)[]; prop2: string; }) => number >testFnTypes : { [x: string]: any; } === tests/cases/conformance/jsdoc/declarations/file.js === diff --git a/tests/baselines/reference/jsdocImportTypeReferenceToClassAlias.types b/tests/baselines/reference/jsdocImportTypeReferenceToClassAlias.types index 49b85f1f06361..0c6d7515d300e 100644 --- a/tests/baselines/reference/jsdocImportTypeReferenceToClassAlias.types +++ b/tests/baselines/reference/jsdocImportTypeReferenceToClassAlias.types @@ -19,11 +19,11 @@ module.exports.C = C /** @param {X} c */ function demo(c) { >demo : (c: X) => void ->c : C +>c : import("tests/cases/conformance/jsdoc/mod1").C c.s >c.s : () => void ->c : C +>c : import("tests/cases/conformance/jsdoc/mod1").C >s : () => void } diff --git a/tests/baselines/reference/jsdocTypeFromChainedAssignment3.symbols b/tests/baselines/reference/jsdocTypeFromChainedAssignment3.symbols index 33389d753639f..685009210f3ea 100644 --- a/tests/baselines/reference/jsdocTypeFromChainedAssignment3.symbols +++ b/tests/baselines/reference/jsdocTypeFromChainedAssignment3.symbols @@ -297,5 +297,5 @@ exports.wrapSync = exports.selectSeries = exports.selectLimit = exports.select = >exports.apply : Symbol(apply, Decl(a.js, 0, 1900)) >exports : Symbol(apply, Decl(a.js, 0, 1900)) >apply : Symbol(apply, Decl(a.js, 0, 1900)) ->undefined : Symbol(undefined) +>undefined : Symbol(apply) diff --git a/tests/baselines/reference/jsdocTypeFromChainedAssignment3.types b/tests/baselines/reference/jsdocTypeFromChainedAssignment3.types index 58605205ea3c9..7950174398922 100644 --- a/tests/baselines/reference/jsdocTypeFromChainedAssignment3.types +++ b/tests/baselines/reference/jsdocTypeFromChainedAssignment3.types @@ -393,8 +393,8 @@ exports.wrapSync = exports.selectSeries = exports.selectLimit = exports.select = >exports : typeof import("tests/cases/conformance/jsdoc/a") >applyEach : any >exports.apply = undefined : undefined ->exports.apply : any +>exports.apply : undefined >exports : typeof import("tests/cases/conformance/jsdoc/a") ->apply : any +>apply : undefined >undefined : undefined diff --git a/tests/baselines/reference/lateBoundAssignmentDeclarationSupport4.types b/tests/baselines/reference/lateBoundAssignmentDeclarationSupport4.types index 0c8199d0fcbab..ab76826b9a4cc 100644 --- a/tests/baselines/reference/lateBoundAssignmentDeclarationSupport4.types +++ b/tests/baselines/reference/lateBoundAssignmentDeclarationSupport4.types @@ -6,22 +6,22 @@ const x = require("./lateBoundAssignmentDeclarationSupport4.js"); >"./lateBoundAssignmentDeclarationSupport4.js" : "./lateBoundAssignmentDeclarationSupport4.js" const inst = new x.F(); ->inst : F ->new x.F() : F ->x.F : typeof F +>inst : x.F +>new x.F() : x.F +>x.F : typeof x.F >x : typeof x ->F : typeof F +>F : typeof x.F const y = inst["my-fake-sym"]; >y : any >inst["my-fake-sym"] : any ->inst : F +>inst : x.F >"my-fake-sym" : "my-fake-sym" const z = inst[x.S]; >z : any >inst[x.S] : any ->inst : F +>inst : x.F >x.S : unique symbol >x : typeof x >S : unique symbol diff --git a/tests/baselines/reference/lateBoundAssignmentDeclarationSupport5.types b/tests/baselines/reference/lateBoundAssignmentDeclarationSupport5.types index d5b65354374ca..ec6fbfadb2aac 100644 --- a/tests/baselines/reference/lateBoundAssignmentDeclarationSupport5.types +++ b/tests/baselines/reference/lateBoundAssignmentDeclarationSupport5.types @@ -6,22 +6,22 @@ const x = require("./lateBoundAssignmentDeclarationSupport5.js"); >"./lateBoundAssignmentDeclarationSupport5.js" : "./lateBoundAssignmentDeclarationSupport5.js" const inst = new x.F(); ->inst : F ->new x.F() : F ->x.F : typeof F +>inst : x.F +>new x.F() : x.F +>x.F : typeof x.F >x : typeof x ->F : typeof F +>F : typeof x.F const y = inst["my-fake-sym"]; >y : any >inst["my-fake-sym"] : any ->inst : F +>inst : x.F >"my-fake-sym" : "my-fake-sym" const z = inst[x.S]; >z : any >inst[x.S] : any ->inst : F +>inst : x.F >x.S : unique symbol >x : typeof x >S : unique symbol diff --git a/tests/baselines/reference/lateBoundAssignmentDeclarationSupport6.types b/tests/baselines/reference/lateBoundAssignmentDeclarationSupport6.types index 54d6ca94a9e1b..e25880167c6a9 100644 --- a/tests/baselines/reference/lateBoundAssignmentDeclarationSupport6.types +++ b/tests/baselines/reference/lateBoundAssignmentDeclarationSupport6.types @@ -6,22 +6,22 @@ const x = require("./lateBoundAssignmentDeclarationSupport6.js"); >"./lateBoundAssignmentDeclarationSupport6.js" : "./lateBoundAssignmentDeclarationSupport6.js" const inst = new x.F(); ->inst : F ->new x.F() : F ->x.F : typeof F +>inst : x.F +>new x.F() : x.F +>x.F : typeof x.F >x : typeof x ->F : typeof F +>F : typeof x.F const y = inst["my-fake-sym"]; >y : any >inst["my-fake-sym"] : any ->inst : F +>inst : x.F >"my-fake-sym" : "my-fake-sym" const z = inst[x.S]; >z : any >inst[x.S] : any ->inst : F +>inst : x.F >x.S : unique symbol >x : typeof x >S : unique symbol diff --git a/tests/baselines/reference/lateBoundAssignmentDeclarationSupport7.symbols b/tests/baselines/reference/lateBoundAssignmentDeclarationSupport7.symbols index 434f00ed278fe..12281050f5805 100644 --- a/tests/baselines/reference/lateBoundAssignmentDeclarationSupport7.symbols +++ b/tests/baselines/reference/lateBoundAssignmentDeclarationSupport7.symbols @@ -9,7 +9,7 @@ const y = x.F["my-fake-sym"]; >x.F : Symbol(x.F, Decl(lateBoundAssignmentDeclarationSupport7.js, 6, 15)) >x : Symbol(x, Decl(usage.js, 0, 5)) >F : Symbol(x.F, Decl(lateBoundAssignmentDeclarationSupport7.js, 6, 15)) ->"my-fake-sym" : Symbol(F.F[_str], Decl(lateBoundAssignmentDeclarationSupport7.js, 5, 15)) +>"my-fake-sym" : Symbol(x.F.F[_str], Decl(lateBoundAssignmentDeclarationSupport7.js, 5, 15)) const z = x.F[x.S]; >z : Symbol(z, Decl(usage.js, 2, 5)) diff --git a/tests/baselines/reference/lateBoundAssignmentDeclarationSupport7.types b/tests/baselines/reference/lateBoundAssignmentDeclarationSupport7.types index d0d472cb20ad4..8b0266457b6d3 100644 --- a/tests/baselines/reference/lateBoundAssignmentDeclarationSupport7.types +++ b/tests/baselines/reference/lateBoundAssignmentDeclarationSupport7.types @@ -8,17 +8,17 @@ const x = require("./lateBoundAssignmentDeclarationSupport7.js"); const y = x.F["my-fake-sym"]; >y : string >x.F["my-fake-sym"] : string ->x.F : typeof F +>x.F : typeof x.F >x : typeof x ->F : typeof F +>F : typeof x.F >"my-fake-sym" : "my-fake-sym" const z = x.F[x.S]; >z : string >x.F[x.S] : string ->x.F : typeof F +>x.F : typeof x.F >x : typeof x ->F : typeof F +>F : typeof x.F >x.S : unique symbol >x : typeof x >S : unique symbol diff --git a/tests/baselines/reference/moduleExportAlias4.symbols b/tests/baselines/reference/moduleExportAlias4.symbols index 2d27298ac9038..e7b83f18927d0 100644 --- a/tests/baselines/reference/moduleExportAlias4.symbols +++ b/tests/baselines/reference/moduleExportAlias4.symbols @@ -17,5 +17,5 @@ module.exports.D = class D { } >module : Symbol(module, Decl(bug24024.js, 1, 31)) >exports : Symbol("tests/cases/conformance/salsa/bug24024", Decl(bug24024.js, 0, 0)) >D : Symbol(wat.D, Decl(bug24024.js, 2, 27)) ->D : Symbol(D, Decl(bug24024.js, 3, 18)) +>D : Symbol(wat.D, Decl(bug24024.js, 3, 18)) diff --git a/tests/baselines/reference/moduleExportAlias4.types b/tests/baselines/reference/moduleExportAlias4.types index 173c7c714a284..3f434998d6e11 100644 --- a/tests/baselines/reference/moduleExportAlias4.types +++ b/tests/baselines/reference/moduleExportAlias4.types @@ -15,12 +15,12 @@ module.exports = class C {} >C : typeof wat module.exports.D = class D { } ->module.exports.D = class D { } : typeof D ->module.exports.D : typeof D +>module.exports.D = class D { } : typeof wat.D +>module.exports.D : typeof wat.D >module.exports : typeof wat >module : { "\"tests/cases/conformance/salsa/bug24024\"": typeof wat; } >exports : typeof wat ->D : typeof D ->class D { } : typeof D ->D : typeof D +>D : typeof wat.D +>class D { } : typeof wat.D +>D : typeof wat.D diff --git a/tests/baselines/reference/moduleExportNestedNamespaces.symbols b/tests/baselines/reference/moduleExportNestedNamespaces.symbols index 2ed7db8d2879b..f2719df948721 100644 --- a/tests/baselines/reference/moduleExportNestedNamespaces.symbols +++ b/tests/baselines/reference/moduleExportNestedNamespaces.symbols @@ -73,8 +73,8 @@ function f(c, classic) { >x : Symbol(C.x, Decl(mod.js, 1, 35)) classic.p ->classic.p : Symbol(Classic.p, Decl(mod.js, 5, 19)) +>classic.p : Symbol(s.Classic.p, Decl(mod.js, 5, 19)) >classic : Symbol(classic, Decl(use.js, 9, 13)) ->p : Symbol(Classic.p, Decl(mod.js, 5, 19)) +>p : Symbol(s.Classic.p, Decl(mod.js, 5, 19)) } diff --git a/tests/baselines/reference/moduleExportNestedNamespaces.types b/tests/baselines/reference/moduleExportNestedNamespaces.types index 7da94f8a29dbd..17f6bf86e9041 100644 --- a/tests/baselines/reference/moduleExportNestedNamespaces.types +++ b/tests/baselines/reference/moduleExportNestedNamespaces.types @@ -65,11 +65,11 @@ k.x >x : number var classic = new s.Classic() ->classic : Classic ->new s.Classic() : Classic ->s.Classic : typeof Classic +>classic : s.Classic +>new s.Classic() : s.Classic +>s.Classic : typeof s.Classic >s : typeof s ->Classic : typeof Classic +>Classic : typeof s.Classic /** @param {s.n.K} c @@ -77,7 +77,7 @@ var classic = new s.Classic() function f(c, classic) { >f : (c: C, classic: s.Classic) => void >c : C ->classic : Classic +>classic : s.Classic c.x >c.x : number @@ -86,7 +86,7 @@ function f(c, classic) { classic.p >classic.p : number ->classic : Classic +>classic : s.Classic >p : number } diff --git a/tests/baselines/reference/typedefCrossModule2.errors.txt b/tests/baselines/reference/typedefCrossModule2.errors.txt index e20bd6acc0b0f..b292cbb617e8e 100644 --- a/tests/baselines/reference/typedefCrossModule2.errors.txt +++ b/tests/baselines/reference/typedefCrossModule2.errors.txt @@ -1,7 +1,5 @@ tests/cases/conformance/jsdoc/mod1.js(3,23): error TS2300: Duplicate identifier 'Foo'. tests/cases/conformance/jsdoc/mod1.js(4,7): error TS2300: Duplicate identifier 'Foo'. -tests/cases/conformance/jsdoc/mod1.js(6,23): error TS2300: Duplicate identifier 'Bar'. -tests/cases/conformance/jsdoc/mod1.js(7,9): error TS2300: Duplicate identifier 'Bar'. tests/cases/conformance/jsdoc/mod1.js(9,23): error TS2300: Duplicate identifier 'Baz'. tests/cases/conformance/jsdoc/mod1.js(11,5): error TS2300: Duplicate identifier 'Baz'. @@ -14,7 +12,7 @@ tests/cases/conformance/jsdoc/mod1.js(11,5): error TS2300: Duplicate identifier var bb; var bbb = new mod.Baz(); -==== tests/cases/conformance/jsdoc/mod1.js (6 errors) ==== +==== tests/cases/conformance/jsdoc/mod1.js (4 errors) ==== // error /** @typedef {number} Foo */ @@ -25,11 +23,7 @@ tests/cases/conformance/jsdoc/mod1.js(11,5): error TS2300: Duplicate identifier !!! error TS2300: Duplicate identifier 'Foo'. /** @typedef {number} Bar */ - ~~~ -!!! error TS2300: Duplicate identifier 'Bar'. exports.Bar = class { } - ~~~ -!!! error TS2300: Duplicate identifier 'Bar'. /** @typedef {number} Baz */ ~~~ diff --git a/tests/baselines/reference/typedefCrossModule2.symbols b/tests/baselines/reference/typedefCrossModule2.symbols index ba1f7c39a0b87..a473991f8c4b4 100644 --- a/tests/baselines/reference/typedefCrossModule2.symbols +++ b/tests/baselines/reference/typedefCrossModule2.symbols @@ -25,9 +25,9 @@ class Foo { } // should error /** @typedef {number} Bar */ exports.Bar = class { } ->exports.Bar : Symbol(Bar, Decl(mod1.js, 3, 13)) ->exports : Symbol(Bar, Decl(mod1.js, 3, 13)) ->Bar : Symbol(Bar, Decl(mod1.js, 3, 13)) +>exports.Bar : Symbol(Bar, Decl(mod1.js, 3, 13), Decl(mod1.js, 5, 4)) +>exports : Symbol(Bar, Decl(mod1.js, 3, 13), Decl(mod1.js, 5, 4)) +>Bar : Symbol(Bar, Decl(mod1.js, 3, 13), Decl(mod1.js, 5, 4)) /** @typedef {number} Baz */ module.exports = { diff --git a/tests/baselines/reference/typedefCrossModule2.types b/tests/baselines/reference/typedefCrossModule2.types index 9a1b0922f9e64..02aa91c079877 100644 --- a/tests/baselines/reference/typedefCrossModule2.types +++ b/tests/baselines/reference/typedefCrossModule2.types @@ -1,7 +1,7 @@ === tests/cases/conformance/jsdoc/use.js === var mod = require('./mod1.js'); ->mod : { Baz: typeof Baz; Bar: typeof Bar; Quid: number; } | { Quack: number; Bar: typeof Bar; Quid: number; } ->require('./mod1.js') : { Baz: typeof Baz; Bar: typeof Bar; Quid: number; } | { Quack: number; Bar: typeof Bar; Quid: number; } +>mod : { Baz: typeof Baz; Bar: typeof mod.Bar; Quid: number; } | { Quack: number; Bar: typeof mod.Bar; Quid: number; } +>require('./mod1.js') : { Baz: typeof Baz; Bar: typeof mod.Bar; Quid: number; } | { Quack: number; Bar: typeof mod.Bar; Quid: number; } >require : any >'./mod1.js' : "./mod1.js" @@ -17,7 +17,7 @@ var bbb = new mod.Baz(); >bbb : any >new mod.Baz() : any >mod.Baz : any ->mod : { Baz: typeof Baz; Bar: typeof Bar; Quid: number; } | { Quack: number; Bar: typeof Bar; Quid: number; } +>mod : { Baz: typeof Baz; Bar: typeof mod.Bar; Quid: number; } | { Quack: number; Bar: typeof mod.Bar; Quid: number; } >Baz : any === tests/cases/conformance/jsdoc/mod1.js === diff --git a/tests/cases/conformance/jsdoc/declarations/jsDeclarationsExportDoubleAssignmentInClosure.ts b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsExportDoubleAssignmentInClosure.ts index bcb7644f8bd58..9d5b109332119 100644 --- a/tests/cases/conformance/jsdoc/declarations/jsDeclarationsExportDoubleAssignmentInClosure.ts +++ b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsExportDoubleAssignmentInClosure.ts @@ -8,5 +8,8 @@ function foo() { module.exports = exports = function (o) { return (o == null) ? create(base) : defineProperties(Object(o), descriptors); }; - exports.methods = methods; -} \ No newline at end of file + const m = function () { + // I have no idea what to put here + } + exports.methods = m; +} diff --git a/tests/cases/conformance/salsa/commonJSImportClassExpression.ts b/tests/cases/conformance/salsa/commonJSImportClassExpression.ts new file mode 100644 index 0000000000000..f821c24012656 --- /dev/null +++ b/tests/cases/conformance/salsa/commonJSImportClassExpression.ts @@ -0,0 +1,18 @@ +// @allowJs: true +// @checkJs: true +// @strict: true +// @outDir: out +// @declaration: true + +// @filename: main.js +const { K } = require("./mod1"); +/** @param {K} k */ +function f(k) { + k.values() +} + +// @filename: mod1.js +exports.K = class K { + values() { + } +}; diff --git a/tests/cases/conformance/salsa/commonJSImportClassTypeReference.ts b/tests/cases/conformance/salsa/commonJSImportClassTypeReference.ts new file mode 100644 index 0000000000000..bdb6bfef656ad --- /dev/null +++ b/tests/cases/conformance/salsa/commonJSImportClassTypeReference.ts @@ -0,0 +1,20 @@ +// @allowJs: true +// @checkJs: true +// @strict: true +// @outDir: out +// @declaration: true + +// @filename: main.js +const { K } = require("./mod1"); +/** @param {K} k */ +function f(k) { + k.values() +} + +// @filename: mod1.js +class K { + values() { + return new K() + } +} +exports.K = K; diff --git a/tests/cases/conformance/salsa/commonJSImportNestedClassTypeReference.ts b/tests/cases/conformance/salsa/commonJSImportNestedClassTypeReference.ts new file mode 100644 index 0000000000000..eed12f4c2886d --- /dev/null +++ b/tests/cases/conformance/salsa/commonJSImportNestedClassTypeReference.ts @@ -0,0 +1,21 @@ +// @allowJs: true +// @checkJs: true +// @strict: true +// @outDir: out +// @declaration: true + +// @filename: main.js +const { K } = require("./mod1"); +/** @param {K} k */ +function f(k) { + k.values() +} + +// @filename: mod1.js +var NS = {} +NS.K =class { + values() { + return new NS.K() + } +} +exports.K = NS.K; diff --git a/tests/cases/fourslash/findAllRefsClassExpression2.ts b/tests/cases/fourslash/findAllRefsClassExpression2.ts index bd0ee3a880462..49140ec6ce08c 100644 --- a/tests/cases/fourslash/findAllRefsClassExpression2.ts +++ b/tests/cases/fourslash/findAllRefsClassExpression2.ts @@ -10,7 +10,7 @@ ////[|A|]; const [r0Def, r0, r1Def, r1, r2] = test.ranges(); -const defs = { definition: "class A\n(property) A: typeof A", ranges: [r0] }; -const imports = { definition: "(alias) class A\n(alias) (property) A: typeof A\nimport A", ranges: [r1, r2] }; +const defs = { definition: "(alias) (local class) A\nimport A", ranges: [r0] }; +const imports = { definition: "(alias) (local class) A\nimport A", ranges: [r1, r2] }; verify.referenceGroups([r0], [defs, imports]); verify.referenceGroups([r1, r2], [imports, defs]); diff --git a/tests/cases/fourslash/findAllRefs_importType_js.ts b/tests/cases/fourslash/findAllRefs_importType_js.ts index ee57b862066d1..6802f055d4022 100644 --- a/tests/cases/fourslash/findAllRefs_importType_js.ts +++ b/tests/cases/fourslash/findAllRefs_importType_js.ts @@ -30,11 +30,11 @@ verify.referenceGroups(r0, [ { definition: "(alias) (local class) export=\nimport export=", ranges: [r3] }, ]); verify.referenceGroups([r1, r5], [ - { definition: "class D\n(property) D: typeof D", ranges: [r1, r5, r5] }, // TODO: should only reference r5 once + { definition: "(alias) (local class) D\nimport D", ranges: [r1, r5] }, ]); verify.referenceGroups(r2, [ { definition: "(local class) D", ranges: [r2] }, - { definition: "class D\n(property) D: typeof D", ranges: [r5] }, + { definition: "(alias) (local class) D\nimport D", ranges: [r5] }, ]); verify.referenceGroups([r3, r4], [ { definition: 'module "/a"', ranges: [r4, rModule] }, diff --git a/tests/cases/fourslash/goToDefinitionImportedNames10.ts b/tests/cases/fourslash/goToDefinitionImportedNames10.ts index faa9ed745cc36..ebf2bb2f92435 100644 --- a/tests/cases/fourslash/goToDefinitionImportedNames10.ts +++ b/tests/cases/fourslash/goToDefinitionImportedNames10.ts @@ -2,10 +2,10 @@ // @allowjs: true // @Filename: a.js -//// class Class { +//// class /*classDefinition*/Class { //// f; //// } -//// module.exports./*classDefinition*/Class = Class; +//// module.exports.Class = Class; // @Filename: b.js ////const { Class } = require("./a"); diff --git a/tests/cases/fourslash/server/completionEntryDetailAcrossFiles01.ts b/tests/cases/fourslash/server/completionEntryDetailAcrossFiles01.ts index 005f42f82bceb..16b6b80c59d9e 100644 --- a/tests/cases/fourslash/server/completionEntryDetailAcrossFiles01.ts +++ b/tests/cases/fourslash/server/completionEntryDetailAcrossFiles01.ts @@ -17,5 +17,5 @@ const entry = (text: string): FourSlashInterface.ExpectedCompletionEntry => ({ name: "foo", text, documentation: "Modify the parameter", tags: [{ name: "param", text: "p1" }] }); verify.completions( { marker: "1", includes: entry("var foo: (p1: string) => void") }, - { marker: "2", exact: entry("(property) a.foo: (p1: string) => void") }, + { marker: "2", exact: entry("(alias) var foo: (p1: string) => void\nimport a.foo") }, ); diff --git a/tests/cases/fourslash/server/completionEntryDetailAcrossFiles02.ts b/tests/cases/fourslash/server/completionEntryDetailAcrossFiles02.ts index d915c55e32053..03aeee3b0ed1f 100644 --- a/tests/cases/fourslash/server/completionEntryDetailAcrossFiles02.ts +++ b/tests/cases/fourslash/server/completionEntryDetailAcrossFiles02.ts @@ -16,5 +16,5 @@ verify.completions( { marker: "1", includes: { name: "foo", text: "var foo: (p1: string) => void", documentation: "Modify the parameter", tags: [{ name: "param", text: "p1" }] } }, - { marker: "2", exact: { name: "foo", text: "(property) a.foo: (p1: string) => void", documentation: "Modify the parameter", tags: [{ name: "param", text: "p1" }] } }, + { marker: "2", exact: { name: "foo", text: "(alias) var foo: (p1: string) => void\nimport a.foo", documentation: "Modify the parameter", tags: [{ name: "param", text: "p1" }] } }, ); diff --git a/tests/cases/fourslash/syntheticImportFromBabelGeneratedFile1.ts b/tests/cases/fourslash/syntheticImportFromBabelGeneratedFile1.ts index 4dd0654a897df..9a42d0923038b 100644 --- a/tests/cases/fourslash/syntheticImportFromBabelGeneratedFile1.ts +++ b/tests/cases/fourslash/syntheticImportFromBabelGeneratedFile1.ts @@ -16,5 +16,5 @@ ////import f from "./a" /////**/f -verify.quickInfoAt("", `(alias) (property) f: (t: string) => void -import f`, "Run this function"); // Passes \ No newline at end of file +verify.quickInfoAt("", `(alias) function f(t: string): void +import f`, "Run this function"); // Passes diff --git a/tests/cases/fourslash/syntheticImportFromBabelGeneratedFile2.ts b/tests/cases/fourslash/syntheticImportFromBabelGeneratedFile2.ts index 0cfb4e684542c..3b01723109a6e 100644 --- a/tests/cases/fourslash/syntheticImportFromBabelGeneratedFile2.ts +++ b/tests/cases/fourslash/syntheticImportFromBabelGeneratedFile2.ts @@ -18,5 +18,5 @@ ////import f from "./a" /////**/f -verify.quickInfoAt("", `(alias) (property) f: (t: string) => void -import f`, "Run this function"); // Passes \ No newline at end of file +verify.quickInfoAt("", `(alias) function f(t: string): void +import f`, "Run this function"); // Passes