mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-25 05:29:07 -05:00
Fixed crash in auto import suggestions for default of exported UMD objects (#60313)
This commit is contained in:
committed by
GitHub
parent
1679f4481d
commit
437d7f7d9c
@@ -169,6 +169,7 @@ import {
|
||||
isExternalModule,
|
||||
isExternalModuleImportEqualsDeclaration,
|
||||
isExternalModuleReference,
|
||||
isExternalModuleSymbol,
|
||||
isFileLevelUniqueName,
|
||||
isForInStatement,
|
||||
isForOfStatement,
|
||||
@@ -4027,7 +4028,13 @@ export function getDefaultLikeExportNameFromDeclaration(symbol: Symbol): string
|
||||
return tryCast(d.propertyName, isIdentifier)?.text;
|
||||
}
|
||||
// GH#52694
|
||||
return tryCast(getNameOfDeclaration(d), isIdentifier)?.text;
|
||||
const name = tryCast(getNameOfDeclaration(d), isIdentifier)?.text;
|
||||
if (name) {
|
||||
return name;
|
||||
}
|
||||
if (symbol.parent && !isExternalModuleSymbol(symbol.parent)) {
|
||||
return symbol.parent.getName();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -35,8 +35,8 @@
|
||||
|
||||
verify.completions({
|
||||
marker: "1",
|
||||
// some kind of a check should be added here
|
||||
includes: [{ name: "$" }],
|
||||
preferences: {
|
||||
includeCompletionsForModuleExports: true,
|
||||
includeCompletionsForModuleExports: true,
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,51 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @module: nodenext
|
||||
// @allowJs: true
|
||||
|
||||
// @Filename: /node_modules/dom7/index.d.ts
|
||||
//// export interface Dom7Array {
|
||||
//// length: number;
|
||||
//// prop(propName: string): any;
|
||||
//// }
|
||||
////
|
||||
//// export interface Dom7 {
|
||||
//// (): Dom7Array;
|
||||
//// fn: any;
|
||||
//// }
|
||||
////
|
||||
//// declare const Dom7: Dom7;
|
||||
////
|
||||
//// export {
|
||||
//// Dom7 as $,
|
||||
//// };
|
||||
|
||||
// @Filename: /dom7.js
|
||||
//// import * as methods from 'dom7';
|
||||
//// Object.keys(methods).forEach((methodName) => {
|
||||
//// if (methodName === '$') return;
|
||||
//// methods.$.fn[methodName] = methods[methodName];
|
||||
//// });
|
||||
////
|
||||
//// export default methods.$;
|
||||
|
||||
// @Filename: /swipe-back.js
|
||||
//// /*1*/
|
||||
|
||||
verify.completions({
|
||||
marker: "1",
|
||||
includes: [{
|
||||
name: "$",
|
||||
hasAction: true,
|
||||
source: 'dom7',
|
||||
sortText: completion.SortText.AutoImportSuggestions,
|
||||
}, {
|
||||
name: "Dom7",
|
||||
hasAction: true,
|
||||
source: './dom7',
|
||||
sortText: completion.SortText.AutoImportSuggestions,
|
||||
}],
|
||||
preferences: {
|
||||
includeCompletionsForModuleExports: true,
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,49 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @moduleResolution: node
|
||||
// @allowJs: true
|
||||
// @checkJs: true
|
||||
|
||||
// @Filename: /node_modules/dottie/package.json
|
||||
//// {
|
||||
//// "name": "dottie",
|
||||
//// "main": "dottie.js"
|
||||
//// }
|
||||
|
||||
// @Filename: /node_modules/dottie/dottie.js
|
||||
//// (function (undefined) {
|
||||
//// var root = this;
|
||||
////
|
||||
//// var Dottie = function () {};
|
||||
////
|
||||
//// Dottie["default"] = function (object, path, value) {};
|
||||
////
|
||||
//// if (typeof module !== "undefined" && module.exports) {
|
||||
//// exports = module.exports = Dottie;
|
||||
//// } else {
|
||||
//// root["Dottie"] = Dottie;
|
||||
//// root["Dot"] = Dottie;
|
||||
////
|
||||
//// if (typeof define === "function") {
|
||||
//// define([], function () {
|
||||
//// return Dottie;
|
||||
//// });
|
||||
//// }
|
||||
//// }
|
||||
//// })();
|
||||
|
||||
// @Filename: /src/index.js
|
||||
//// /**/
|
||||
|
||||
verify.completions({
|
||||
marker: "",
|
||||
includes: [
|
||||
{
|
||||
name: "Dottie",
|
||||
hasAction: true,
|
||||
source: "/node_modules/dottie/dottie",
|
||||
sortText: completion.SortText.AutoImportSuggestions,
|
||||
},
|
||||
],
|
||||
preferences: { includeCompletionsForModuleExports: true },
|
||||
});
|
||||
@@ -0,0 +1,43 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @moduleResolution: node
|
||||
// @allowJs: true
|
||||
// @checkJs: true
|
||||
|
||||
// @Filename: /node_modules/dottie/package.json
|
||||
//// {
|
||||
//// "name": "dottie",
|
||||
//// "main": "dottie.js"
|
||||
//// }
|
||||
|
||||
// @Filename: /node_modules/dottie/dottie.js
|
||||
//// (function (undefined) {
|
||||
//// var root = this;
|
||||
////
|
||||
//// var Dottie = function () {};
|
||||
////
|
||||
//// Dottie["default"] = function (object, path, value) {};
|
||||
////
|
||||
//// if (typeof module !== "undefined" && module.exports) {
|
||||
//// exports = module.exports = Dottie;
|
||||
//// } else {
|
||||
//// root["Dottie"] = Dottie;
|
||||
//// root["Dot"] = Dottie;
|
||||
////
|
||||
//// if (typeof define === "function") {
|
||||
//// define([], function () {
|
||||
//// return Dottie;
|
||||
//// });
|
||||
//// }
|
||||
//// }
|
||||
//// })();
|
||||
|
||||
// @Filename: /src/index.js
|
||||
//// import Dottie from 'dottie';
|
||||
//// /**/
|
||||
|
||||
verify.completions({
|
||||
marker: "",
|
||||
includes: [{ name: "Dottie" }],
|
||||
preferences: { includeCompletionsForModuleExports: true },
|
||||
});
|
||||
Reference in New Issue
Block a user