mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-12-15 16:53:31 -06:00
Fixed completion crashes related to JSDocImportTag (#59527)
This commit is contained in:
parent
2937728ddb
commit
f04672842b
@ -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);
|
||||
|
||||
@ -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,
|
||||
});
|
||||
@ -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,
|
||||
});
|
||||
@ -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,
|
||||
});
|
||||
@ -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,
|
||||
});
|
||||
@ -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,
|
||||
});
|
||||
31
tests/cases/fourslash/completionsJSDocNoCrash1.ts
Normal file
31
tests/cases/fourslash/completionsJSDocNoCrash1.ts
Normal 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
|
||||
}
|
||||
});
|
||||
29
tests/cases/fourslash/completionsJSDocNoCrash2.ts
Normal file
29
tests/cases/fourslash/completionsJSDocNoCrash2.ts
Normal 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
|
||||
}
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user