Fixed completion crashes related to JSDocImportTag (#59527)

This commit is contained in:
Mateusz Burzyński 2024-08-12 23:36:03 +02:00 committed by GitHub
parent 2937728ddb
commit f04672842b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 154 additions and 1 deletions

View File

@ -1191,10 +1191,10 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
case SyntaxKind.JSDocEnumTag:
bindJSDocTypeAlias(node as JSDocTypedefTag | JSDocCallbackTag | JSDocEnumTag);
break;
// In source files and blocks, bind functions first to match hoisting that occurs at runtime
case SyntaxKind.JSDocImportTag:
bindJSDocImportTag(node as JSDocImportTag);
break;
// In source files and blocks, bind functions first to match hoisting that occurs at runtime
case SyntaxKind.SourceFile: {
bindEachFunctionsFirst((node as SourceFile).statements);
bind((node as SourceFile).endOfFileToken);
@ -2105,7 +2105,10 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
}
function bindJSDocImportTag(node: JSDocImportTag) {
// don't bind the importClause yet; that's delayed until bindJSDocImports
bind(node.tagName);
bind(node.moduleSpecifier);
bind(node.attributes);
if (typeof node.comment !== "string") {
bindEach(node.comment);

View File

@ -0,0 +1,17 @@
/// <reference path='fourslash.ts' />
// @strict: true
// @filename: global.d.ts
//// interface ImportAttributes {
//// type: "json";
//// }
// @filename: index.ts
//// import * as ns from "" with { type: "/**/" };
verify.completions({
marker: "",
exact: ["json"],
isNewIdentifierLocation: false,
});

View File

@ -0,0 +1,17 @@
/// <reference path='fourslash.ts' />
// @strict: true
// @filename: global.d.ts
//// interface ImportAttributes {
//// type: "json";
//// }
// @filename: index.ts
//// import * as ns from () with { type: "/**/" };
verify.completions({
marker: "",
exact: ["json"],
isNewIdentifierLocation: false,
});

View File

@ -0,0 +1,19 @@
/// <reference path='fourslash.ts' />
// @strict: true
// @checkJs: true
// @allowJs: true
// @filename: global.d.ts
//// interface ImportAttributes {
//// type: "json";
//// }
// @filename: index.js
//// /** @import * as ns from "" with { type: "/**/" } */
verify.completions({
marker: "",
exact: ["json"],
isNewIdentifierLocation: false,
});

View File

@ -0,0 +1,19 @@
/// <reference path='fourslash.ts' />
// @strict: true
// @checkJs: true
// @allowJs: true
// @filename: global.d.ts
//// interface ImportAttributes {
//// type: "json";
//// }
// @filename: index.js
//// /** @import * as ns from () with { type: "/**/" } */
verify.completions({
marker: "",
exact: ["json"],
isNewIdentifierLocation: false,
});

View File

@ -0,0 +1,18 @@
/// <reference path='fourslash.ts' />
// @strict: true
// @checkJs: true
// @allowJs: true
// @moduleResolution: nodenext
// @filename: node_modules/pkg/index.d.ts
//// export type MyUnion = string | number;
// @filename: index.js
//// /** @import { MyUnion } from "/**/" */
verify.completions({
marker: "",
exact: ["pkg"],
isNewIdentifierLocation: true,
});

View File

@ -0,0 +1,31 @@
/// <reference path='fourslash.ts' />
// @strict: true
// @checkJs: true
// @allowJs: true
// @filename: index.js
//// /**
//// * @example
//// <file name="glyphicons.css">
//// @import url(//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-glyphicons.css);
//// </file>
//// <example module="ngAnimate" deps="angular-animate.js" animations="true">
//// <file name="animations.css">
//// .animate-show.ng-hide-add.ng-hide-add-active,
//// .animate-show.ng-hide-remove.ng-hide-remove-active {
//// transition:all linear 0./**/5s;
//// }
//// </file>
//// </example>
//// */
//// var ngShowDirective = ['$animate', function($animate) {}];
verify.completions({
marker: "",
includes: ["url"],
isNewIdentifierLocation: true,
preferences: {
includeCompletionsWithInsertText: true
}
});

View File

@ -0,0 +1,29 @@
/// <reference path='fourslash.ts' />
// @strict: true
// @filename: index.ts
//// /**
//// * @example
//// <file name="glyphicons.css">
//// @import url(//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-glyphicons.css);
//// </file>
//// <example module="ngAnimate" deps="angular-animate.js" animations="true">
//// <file name="animations.css">
//// .animate-show.ng-hide-add.ng-hide-add-active,
//// .animate-show.ng-hide-remove.ng-hide-remove-active {
//// transition:all linear 0./**/5s;
//// }
//// </file>
//// </example>
//// */
//// var ngShowDirective = ['$animate', function($animate) {}];
verify.completions({
marker: "",
exact: completion.globalTypes,
isNewIdentifierLocation: false,
preferences: {
includeCompletionsWithInsertText: true
}
});