Fix bug: Ignore @enum tag in TS (#27076)

This commit is contained in:
Andy
2018-09-13 15:24:49 -07:00
committed by GitHub
parent 64d0e0d448
commit ebfcc1b52d
6 changed files with 33 additions and 1 deletions

View File

@@ -2666,7 +2666,7 @@ namespace ts {
}
if (!isBindingPattern(node.name)) {
const isEnum = !!getJSDocEnumTag(node);
const isEnum = isInJSFile(node) && !!getJSDocEnumTag(node);
const enumFlags = (isEnum ? SymbolFlags.RegularEnum : SymbolFlags.None);
const enumExcludes = (isEnum ? SymbolFlags.RegularEnumExcludes : SymbolFlags.None);
if (isBlockOrCatchScoped(node)) {

View File

@@ -67,4 +67,8 @@ tests/cases/compiler/jsdocInTypeScript.ts(42,12): error TS2503: Cannot find name
* @type {{foo: (function(string, string): string)}}
*/
const obj = { foo: (a, b) => a + b };
/** @enum {string} */
var E = {};
E[""];

View File

@@ -47,6 +47,10 @@ import M = N; // Error: @typedef does not create namespaces in TypeScript code.
* @type {{foo: (function(string, string): string)}}
*/
const obj = { foo: (a, b) => a + b };
/** @enum {string} */
var E = {};
E[""];
//// [jsdocInTypeScript.js]
@@ -79,3 +83,6 @@ var M = N; // Error: @typedef does not create namespaces in TypeScript code.
* @type {{foo: (function(string, string): string)}}
*/
var obj = { foo: function (a, b) { return a + b; } };
/** @enum {string} */
var E = {};
E[""];

View File

@@ -83,3 +83,10 @@ const obj = { foo: (a, b) => a + b };
>a : Symbol(a, Decl(jsdocInTypeScript.ts, 47, 20))
>b : Symbol(b, Decl(jsdocInTypeScript.ts, 47, 22))
/** @enum {string} */
var E = {};
>E : Symbol(E, Decl(jsdocInTypeScript.ts, 50, 3))
E[""];
>E : Symbol(E, Decl(jsdocInTypeScript.ts, 50, 3))

View File

@@ -93,3 +93,13 @@ const obj = { foo: (a, b) => a + b };
>a : any
>b : any
/** @enum {string} */
var E = {};
>E : {}
>{} : {}
E[""];
>E[""] : any
>E : {}
>"" : ""

View File

@@ -46,3 +46,7 @@ import M = N; // Error: @typedef does not create namespaces in TypeScript code.
* @type {{foo: (function(string, string): string)}}
*/
const obj = { foo: (a, b) => a + b };
/** @enum {string} */
var E = {};
E[""];