mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 21:36:50 -05:00
add test case and fix regression (#26726)
This commit is contained in:
committed by
Nathan Shively-Sanders
parent
30f611b055
commit
f67d7e01cf
@@ -1211,8 +1211,8 @@ namespace ts {
|
||||
: false;
|
||||
}
|
||||
if (meaning & SymbolFlags.Value && result.flags & SymbolFlags.Variable) {
|
||||
// parameter initializer will lookup as normal variable scope when targeting es2015+
|
||||
if (compilerOptions.target && compilerOptions.target >= ScriptTarget.ES2015 && isParameter(lastLocation) && result.valueDeclaration !== lastLocation) {
|
||||
// expression inside parameter will lookup as normal variable scope when targeting es2015+
|
||||
if (compilerOptions.target && compilerOptions.target >= ScriptTarget.ES2015 && isParameter(lastLocation) && !isParameterPropertyDeclaration(lastLocation) && result.valueDeclaration !== lastLocation) {
|
||||
useResult = false;
|
||||
}
|
||||
else if (result.flags & SymbolFlags.FunctionScopedVariable) {
|
||||
|
||||
@@ -51,4 +51,8 @@ tests/cases/conformance/functions/parameterInitializersForwardReferencing1.ts(29
|
||||
!!! related TS2728 tests/cases/conformance/functions/parameterInitializersForwardReferencing1.ts:30:9: 'foo' is declared here.
|
||||
let foo: number = 2;
|
||||
}
|
||||
|
||||
class Foo {
|
||||
constructor(public x = 12, public y = x) {}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,10 @@ function f6 (async = async) {
|
||||
function f7({[foo]: bar}: any[]) {
|
||||
let foo: number = 2;
|
||||
}
|
||||
|
||||
class Foo {
|
||||
constructor(public x = 12, public y = x) {}
|
||||
}
|
||||
|
||||
|
||||
//// [parameterInitializersForwardReferencing1.js]
|
||||
@@ -68,3 +72,12 @@ function f7(_a) {
|
||||
var _b = foo, bar = _a[_b];
|
||||
var foo = 2;
|
||||
}
|
||||
var Foo = /** @class */ (function () {
|
||||
function Foo(x, y) {
|
||||
if (x === void 0) { x = 12; }
|
||||
if (y === void 0) { y = x; }
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
return Foo;
|
||||
}());
|
||||
|
||||
@@ -75,3 +75,12 @@ function f7({[foo]: bar}: any[]) {
|
||||
>foo : Symbol(foo, Decl(parameterInitializersForwardReferencing1.ts, 29, 7))
|
||||
}
|
||||
|
||||
class Foo {
|
||||
>Foo : Symbol(Foo, Decl(parameterInitializersForwardReferencing1.ts, 30, 1))
|
||||
|
||||
constructor(public x = 12, public y = x) {}
|
||||
>x : Symbol(Foo.x, Decl(parameterInitializersForwardReferencing1.ts, 33, 16))
|
||||
>y : Symbol(Foo.y, Decl(parameterInitializersForwardReferencing1.ts, 33, 30))
|
||||
>x : Symbol(x, Decl(parameterInitializersForwardReferencing1.ts, 33, 16))
|
||||
}
|
||||
|
||||
|
||||
@@ -82,3 +82,13 @@ function f7({[foo]: bar}: any[]) {
|
||||
>2 : 2
|
||||
}
|
||||
|
||||
class Foo {
|
||||
>Foo : Foo
|
||||
|
||||
constructor(public x = 12, public y = x) {}
|
||||
>x : number
|
||||
>12 : 12
|
||||
>y : number
|
||||
>x : number
|
||||
}
|
||||
|
||||
|
||||
@@ -38,4 +38,8 @@ tests/cases/conformance/functions/parameterInitializersForwardReferencing1_es6.t
|
||||
function f7({[foo]: bar}: any[]) {
|
||||
let foo: number = 2;
|
||||
}
|
||||
|
||||
class Foo {
|
||||
constructor(public x = 12, public y = x) {}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,10 @@ function f6 (async = async) {
|
||||
function f7({[foo]: bar}: any[]) {
|
||||
let foo: number = 2;
|
||||
}
|
||||
|
||||
class Foo {
|
||||
constructor(public x = 12, public y = x) {}
|
||||
}
|
||||
|
||||
|
||||
//// [parameterInitializersForwardReferencing1_es6.js]
|
||||
@@ -57,3 +61,9 @@ function f6(async = async) {
|
||||
function f7({ [foo]: bar }) {
|
||||
let foo = 2;
|
||||
}
|
||||
class Foo {
|
||||
constructor(x = 12, y = x) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,3 +75,12 @@ function f7({[foo]: bar}: any[]) {
|
||||
>foo : Symbol(foo, Decl(parameterInitializersForwardReferencing1_es6.ts, 29, 7))
|
||||
}
|
||||
|
||||
class Foo {
|
||||
>Foo : Symbol(Foo, Decl(parameterInitializersForwardReferencing1_es6.ts, 30, 1))
|
||||
|
||||
constructor(public x = 12, public y = x) {}
|
||||
>x : Symbol(Foo.x, Decl(parameterInitializersForwardReferencing1_es6.ts, 33, 16))
|
||||
>y : Symbol(Foo.y, Decl(parameterInitializersForwardReferencing1_es6.ts, 33, 30))
|
||||
>x : Symbol(x, Decl(parameterInitializersForwardReferencing1_es6.ts, 33, 16))
|
||||
}
|
||||
|
||||
|
||||
@@ -82,3 +82,13 @@ function f7({[foo]: bar}: any[]) {
|
||||
>2 : 2
|
||||
}
|
||||
|
||||
class Foo {
|
||||
>Foo : Foo
|
||||
|
||||
constructor(public x = 12, public y = x) {}
|
||||
>x : number
|
||||
>12 : 12
|
||||
>y : number
|
||||
>x : number
|
||||
}
|
||||
|
||||
|
||||
@@ -29,3 +29,7 @@ function f6 (async = async) {
|
||||
function f7({[foo]: bar}: any[]) {
|
||||
let foo: number = 2;
|
||||
}
|
||||
|
||||
class Foo {
|
||||
constructor(public x = 12, public y = x) {}
|
||||
}
|
||||
|
||||
@@ -31,3 +31,7 @@ function f6 (async = async) {
|
||||
function f7({[foo]: bar}: any[]) {
|
||||
let foo: number = 2;
|
||||
}
|
||||
|
||||
class Foo {
|
||||
constructor(public x = 12, public y = x) {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user