mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-15 03:23:08 -06:00
Merge branch 'master' of https://github.com/Microsoft/TypeScript
This commit is contained in:
commit
e1edf4ad99
@ -11072,7 +11072,7 @@ module ts {
|
||||
|
||||
var symbol = declarationSymbol ||
|
||||
getNodeLinks(n).resolvedSymbol ||
|
||||
resolveName(n, n.text, SymbolFlags.BlockScopedVariable | SymbolFlags.Alias, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined);
|
||||
resolveName(n, n.text, SymbolFlags.Value | SymbolFlags.Alias, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined);
|
||||
|
||||
var isLetOrConst =
|
||||
symbol &&
|
||||
|
||||
@ -2975,6 +2975,12 @@ module ts {
|
||||
return !scanner.hasPrecedingLineBreak() && isIdentifier()
|
||||
}
|
||||
|
||||
function nextTokenIsIdentifierOrStartOfDestructuringOnTheSameLine() {
|
||||
nextToken();
|
||||
return !scanner.hasPrecedingLineBreak() &&
|
||||
(isIdentifier() || token === SyntaxKind.OpenBraceToken || token === SyntaxKind.OpenBracketToken);
|
||||
}
|
||||
|
||||
function parseYieldExpression(): YieldExpression {
|
||||
var node = <YieldExpression>createNode(SyntaxKind.YieldExpression);
|
||||
|
||||
@ -4873,9 +4879,9 @@ module ts {
|
||||
}
|
||||
|
||||
function isLetDeclaration() {
|
||||
// It is let declaration if in strict mode or next token is identifier on same line.
|
||||
// It is let declaration if in strict mode or next token is identifier\open bracket\open curly on same line.
|
||||
// otherwise it needs to be treated like identifier
|
||||
return inStrictModeContext() || lookAhead(nextTokenIsIdentifierOnSameLine);
|
||||
return inStrictModeContext() || lookAhead(nextTokenIsIdentifierOrStartOfDestructuringOnTheSameLine);
|
||||
}
|
||||
|
||||
function isDeclarationStart(): boolean {
|
||||
|
||||
28
tests/baselines/reference/letConstMatchingParameterNames.js
Normal file
28
tests/baselines/reference/letConstMatchingParameterNames.js
Normal file
@ -0,0 +1,28 @@
|
||||
//// [letConstMatchingParameterNames.ts]
|
||||
let parent = true;
|
||||
const parent2 = true;
|
||||
declare function use(a: any);
|
||||
|
||||
function a() {
|
||||
|
||||
let parent = 1;
|
||||
const parent2 = 2;
|
||||
|
||||
function b(parent: string, parent2: number) {
|
||||
use(parent);
|
||||
use(parent2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// [letConstMatchingParameterNames.js]
|
||||
var parent = true;
|
||||
var parent2 = true;
|
||||
function a() {
|
||||
var _parent = 1;
|
||||
var _parent2 = 2;
|
||||
function b(parent, parent2) {
|
||||
use(parent);
|
||||
use(parent2);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,37 @@
|
||||
=== tests/cases/compiler/letConstMatchingParameterNames.ts ===
|
||||
let parent = true;
|
||||
>parent : boolean
|
||||
|
||||
const parent2 = true;
|
||||
>parent2 : boolean
|
||||
|
||||
declare function use(a: any);
|
||||
>use : (a: any) => any
|
||||
>a : any
|
||||
|
||||
function a() {
|
||||
>a : () => void
|
||||
|
||||
let parent = 1;
|
||||
>parent : number
|
||||
|
||||
const parent2 = 2;
|
||||
>parent2 : number
|
||||
|
||||
function b(parent: string, parent2: number) {
|
||||
>b : (parent: string, parent2: number) => void
|
||||
>parent : string
|
||||
>parent2 : number
|
||||
|
||||
use(parent);
|
||||
>use(parent) : any
|
||||
>use : (a: any) => any
|
||||
>parent : string
|
||||
|
||||
use(parent2);
|
||||
>use(parent2) : any
|
||||
>use : (a: any) => any
|
||||
>parent2 : number
|
||||
}
|
||||
}
|
||||
|
||||
11
tests/baselines/reference/letInNonStrictMode.js
Normal file
11
tests/baselines/reference/letInNonStrictMode.js
Normal file
@ -0,0 +1,11 @@
|
||||
//// [letInNonStrictMode.ts]
|
||||
let [x] = [1];
|
||||
let {a: y} = {a: 1};
|
||||
|
||||
//// [letInNonStrictMode.js]
|
||||
var x = ([
|
||||
1
|
||||
])[0];
|
||||
var y = ({
|
||||
a: 1
|
||||
}).a;
|
||||
11
tests/baselines/reference/letInNonStrictMode.types
Normal file
11
tests/baselines/reference/letInNonStrictMode.types
Normal file
@ -0,0 +1,11 @@
|
||||
=== tests/cases/compiler/letInNonStrictMode.ts ===
|
||||
let [x] = [1];
|
||||
>x : number
|
||||
>[1] : [number]
|
||||
|
||||
let {a: y} = {a: 1};
|
||||
>a : unknown
|
||||
>y : number
|
||||
>{a: 1} : { a: number; }
|
||||
>a : number
|
||||
|
||||
15
tests/cases/compiler/letConstMatchingParameterNames.ts
Normal file
15
tests/cases/compiler/letConstMatchingParameterNames.ts
Normal file
@ -0,0 +1,15 @@
|
||||
// @target: es5
|
||||
let parent = true;
|
||||
const parent2 = true;
|
||||
declare function use(a: any);
|
||||
|
||||
function a() {
|
||||
|
||||
let parent = 1;
|
||||
const parent2 = 2;
|
||||
|
||||
function b(parent: string, parent2: number) {
|
||||
use(parent);
|
||||
use(parent2);
|
||||
}
|
||||
}
|
||||
2
tests/cases/compiler/letInNonStrictMode.ts
Normal file
2
tests/cases/compiler/letInNonStrictMode.ts
Normal file
@ -0,0 +1,2 @@
|
||||
let [x] = [1];
|
||||
let {a: y} = {a: 1};
|
||||
Loading…
x
Reference in New Issue
Block a user