From 8e204519eb09c8d39c4487a812c4a26168a1dc00 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Fri, 15 Dec 2017 16:52:28 -0800 Subject: [PATCH 1/2] Fix devtools test --- src/compiler/checker.ts | 1 + tests/baselines/reference/user/chrome-devtools-frontend.log | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 1421c4a3749ae..149280622bacb 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4677,6 +4677,7 @@ namespace ts { } else if (isJSDocPropertyTag(declaration) || isPropertyAccessExpression(declaration) + || isIdentifier(declaration) || isMethodDeclaration(declaration) && !isObjectLiteralMethod(declaration)) { // TODO: Mimics old behavior from incorrect usage of getWidenedTypeForVariableLikeDeclaration, but seems incorrect type = tryGetTypeFromEffectiveTypeNode(declaration) || anyType; diff --git a/tests/baselines/reference/user/chrome-devtools-frontend.log b/tests/baselines/reference/user/chrome-devtools-frontend.log index c997005026f2d..ca43cccaa18e4 100644 --- a/tests/baselines/reference/user/chrome-devtools-frontend.log +++ b/tests/baselines/reference/user/chrome-devtools-frontend.log @@ -12,8 +12,8 @@ Standard output: ../../../../built/local/lib.dom.d.ts(9253,13): error TS2300: Duplicate identifier 'Request'. ../../../../built/local/lib.dom.d.ts(13511,11): error TS2300: Duplicate identifier 'Window'. ../../../../built/local/lib.dom.d.ts(13700,13): error TS2300: Duplicate identifier 'Window'. -../../../../built/local/lib.es5.d.ts(1322,11): error TS2300: Duplicate identifier 'ArrayLike'. -../../../../built/local/lib.es5.d.ts(1351,6): error TS2300: Duplicate identifier 'Record'. +../../../../built/local/lib.es5.d.ts(1321,11): error TS2300: Duplicate identifier 'ArrayLike'. +../../../../built/local/lib.es5.d.ts(1350,6): error TS2300: Duplicate identifier 'Record'. node_modules/chrome-devtools-frontend/front_end/Runtime.js(43,8): error TS2339: Property '_importScriptPathPrefix' does not exist on type 'Window'. node_modules/chrome-devtools-frontend/front_end/Runtime.js(95,28): error TS2339: Property 'response' does not exist on type 'EventTarget'. node_modules/chrome-devtools-frontend/front_end/Runtime.js(147,37): error TS2339: Property '_importScriptPathPrefix' does not exist on type 'Window'. From ac7e161a361af20c2a352a7654c6fa333af606aa Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Mon, 18 Dec 2017 13:22:47 -0800 Subject: [PATCH 2/2] Add small test case mimicing the issue from the user test --- ...peFromPropertyAssignmentOutOfOrder.symbols | 28 +++++++++++++ ...typeFromPropertyAssignmentOutOfOrder.types | 42 +++++++++++++++++++ .../typeFromPropertyAssignmentOutOfOrder.ts | 16 +++++++ 3 files changed, 86 insertions(+) create mode 100644 tests/baselines/reference/typeFromPropertyAssignmentOutOfOrder.symbols create mode 100644 tests/baselines/reference/typeFromPropertyAssignmentOutOfOrder.types create mode 100644 tests/cases/conformance/salsa/typeFromPropertyAssignmentOutOfOrder.ts diff --git a/tests/baselines/reference/typeFromPropertyAssignmentOutOfOrder.symbols b/tests/baselines/reference/typeFromPropertyAssignmentOutOfOrder.symbols new file mode 100644 index 0000000000000..fa526ebbe7d40 --- /dev/null +++ b/tests/baselines/reference/typeFromPropertyAssignmentOutOfOrder.symbols @@ -0,0 +1,28 @@ +=== tests/cases/conformance/salsa/index.js === +Common.Item = class I {} +>Common : Symbol(Common, Decl(index.js, 0, 0), Decl(roots.js, 0, 3)) +>I : Symbol(I, Decl(index.js, 0, 13)) + +Common.Object = class extends Common.Item {} +>Common : Symbol(Common, Decl(index.js, 0, 0), Decl(roots.js, 0, 3)) +>Common.Item : Symbol(Common.Item, Decl(index.js, 0, 0)) +>Common : Symbol(Common, Decl(index.js, 0, 0), Decl(roots.js, 0, 3)) +>Item : Symbol(Common.Item, Decl(index.js, 0, 0)) + +Workspace.Object = class extends Common.Object {} +>Workspace : Symbol(Workspace, Decl(index.js, 1, 44), Decl(roots.js, 1, 3)) +>Common.Object : Symbol(Common.Object, Decl(index.js, 0, 24)) +>Common : Symbol(Common, Decl(index.js, 0, 0), Decl(roots.js, 0, 3)) +>Object : Symbol(Common.Object, Decl(index.js, 0, 24)) + +/** @type {Workspace.Object} */ +var am; +>am : Symbol(am, Decl(index.js, 6, 3)) + +=== tests/cases/conformance/salsa/roots.js === +var Common = {}; +>Common : Symbol(Common, Decl(index.js, 0, 0), Decl(roots.js, 0, 3)) + +var Workspace = {}; +>Workspace : Symbol(Workspace, Decl(index.js, 1, 44), Decl(roots.js, 1, 3)) + diff --git a/tests/baselines/reference/typeFromPropertyAssignmentOutOfOrder.types b/tests/baselines/reference/typeFromPropertyAssignmentOutOfOrder.types new file mode 100644 index 0000000000000..3fb6b6df1b446 --- /dev/null +++ b/tests/baselines/reference/typeFromPropertyAssignmentOutOfOrder.types @@ -0,0 +1,42 @@ +=== tests/cases/conformance/salsa/index.js === +Common.Item = class I {} +>Common.Item = class I {} : typeof I +>Common.Item : any +>Common : any +>Item : any +>class I {} : typeof I +>I : typeof I + +Common.Object = class extends Common.Item {} +>Common.Object = class extends Common.Item {} : typeof (Anonymous class) +>Common.Object : any +>Common : any +>Object : any +>class extends Common.Item {} : typeof (Anonymous class) +>Common.Item : any +>Common : any +>Item : any + +Workspace.Object = class extends Common.Object {} +>Workspace.Object = class extends Common.Object {} : typeof (Anonymous class) +>Workspace.Object : any +>Workspace : any +>Object : any +>class extends Common.Object {} : typeof (Anonymous class) +>Common.Object : any +>Common : any +>Object : any + +/** @type {Workspace.Object} */ +var am; +>am : (Anonymous class) + +=== tests/cases/conformance/salsa/roots.js === +var Common = {}; +>Common : any +>{} : { [x: string]: any; } + +var Workspace = {}; +>Workspace : any +>{} : { [x: string]: any; } + diff --git a/tests/cases/conformance/salsa/typeFromPropertyAssignmentOutOfOrder.ts b/tests/cases/conformance/salsa/typeFromPropertyAssignmentOutOfOrder.ts new file mode 100644 index 0000000000000..d6f9737573468 --- /dev/null +++ b/tests/cases/conformance/salsa/typeFromPropertyAssignmentOutOfOrder.ts @@ -0,0 +1,16 @@ +// @noEmit: true +// @allowJs: true +// @checkJs: true +// @target: es3 +// @filename: index.js +Common.Item = class I {} +Common.Object = class extends Common.Item {} + +Workspace.Object = class extends Common.Object {} + +/** @type {Workspace.Object} */ +var am; + +// @filename: roots.js +var Common = {}; +var Workspace = {};