Skip to content

Commit 59c4d3f

Browse files
committed
Merge branch 'release-2.0'
2 parents 3d3ae29 + 08b3b8b commit 59c4d3f

40 files changed

+679
-19
lines changed

lib/tsc.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24051,6 +24051,7 @@ var ts;
2405124051
var parameter = local_1.valueDeclaration;
2405224052
if (compilerOptions.noUnusedParameters &&
2405324053
!ts.isParameterPropertyDeclaration(parameter) &&
24054+
!parameterIsThisKeyword(parameter) &&
2405424055
!parameterNameStartsWithUnderscore(parameter)) {
2405524056
error(local_1.valueDeclaration.name, ts.Diagnostics._0_is_declared_but_never_used, local_1.name);
2405624057
}
@@ -24066,6 +24067,9 @@ var ts;
2406624067
}
2406724068
}
2406824069
}
24070+
function parameterIsThisKeyword(parameter) {
24071+
return parameter.name && parameter.name.originalKeywordKind === 97;
24072+
}
2406924073
function parameterNameStartsWithUnderscore(parameter) {
2407024074
return parameter.name && parameter.name.kind === 69 && parameter.name.text.charCodeAt(0) === 95;
2407124075
}

lib/tsserver.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24969,6 +24969,7 @@ var ts;
2496924969
var parameter = local_1.valueDeclaration;
2497024970
if (compilerOptions.noUnusedParameters &&
2497124971
!ts.isParameterPropertyDeclaration(parameter) &&
24972+
!parameterIsThisKeyword(parameter) &&
2497224973
!parameterNameStartsWithUnderscore(parameter)) {
2497324974
error(local_1.valueDeclaration.name, ts.Diagnostics._0_is_declared_but_never_used, local_1.name);
2497424975
}
@@ -24984,6 +24985,9 @@ var ts;
2498424985
}
2498524986
}
2498624987
}
24988+
function parameterIsThisKeyword(parameter) {
24989+
return parameter.name && parameter.name.originalKeywordKind === 97;
24990+
}
2498724991
function parameterNameStartsWithUnderscore(parameter) {
2498824992
return parameter.name && parameter.name.kind === 69 && parameter.name.text.charCodeAt(0) === 95;
2498924993
}
@@ -50793,7 +50797,6 @@ var ts;
5079350797
if (isOpen === void 0) { isOpen = false; }
5079450798
this.host = host;
5079550799
this.fileName = fileName;
50796-
this.content = content;
5079750800
this.isOpen = isOpen;
5079850801
this.children = [];
5079950802
this.formatCodeOptions = ts.clone(CompilerService.getDefaultFormatCodeOptions(this.host));
@@ -53197,7 +53200,7 @@ var ts;
5319753200
return this.shimHost.getCurrentDirectory();
5319853201
};
5319953202
LanguageServiceShimHostAdapter.prototype.getDirectories = function (path) {
53200-
return this.shimHost.getDirectories(path);
53203+
return JSON.parse(this.shimHost.getDirectories(path));
5320153204
};
5320253205
LanguageServiceShimHostAdapter.prototype.getDefaultLibFileName = function (options) {
5320353206
return this.shimHost.getDefaultLibFileName(JSON.stringify(options));

lib/tsserverlibrary.d.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8388,7 +8388,6 @@ declare namespace ts.server {
83888388
class ScriptInfo {
83898389
private host;
83908390
fileName: string;
8391-
content: string;
83928391
isOpen: boolean;
83938392
svc: ScriptVersionCache;
83948393
children: ScriptInfo[];
@@ -8729,7 +8728,7 @@ declare namespace ts {
87298728
getLocalizedDiagnosticMessages(): string;
87308729
getCancellationToken(): HostCancellationToken;
87318730
getCurrentDirectory(): string;
8732-
getDirectories(path: string): string[];
8731+
getDirectories(path: string): string;
87338732
getDefaultLibFileName(options: string): string;
87348733
getNewLine?(): string;
87358734
getProjectVersion?(): string;

lib/tsserverlibrary.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24969,6 +24969,7 @@ var ts;
2496924969
var parameter = local_1.valueDeclaration;
2497024970
if (compilerOptions.noUnusedParameters &&
2497124971
!ts.isParameterPropertyDeclaration(parameter) &&
24972+
!parameterIsThisKeyword(parameter) &&
2497224973
!parameterNameStartsWithUnderscore(parameter)) {
2497324974
error(local_1.valueDeclaration.name, ts.Diagnostics._0_is_declared_but_never_used, local_1.name);
2497424975
}
@@ -24984,6 +24985,9 @@ var ts;
2498424985
}
2498524986
}
2498624987
}
24988+
function parameterIsThisKeyword(parameter) {
24989+
return parameter.name && parameter.name.originalKeywordKind === 97;
24990+
}
2498724991
function parameterNameStartsWithUnderscore(parameter) {
2498824992
return parameter.name && parameter.name.kind === 69 && parameter.name.text.charCodeAt(0) === 95;
2498924993
}
@@ -50793,7 +50797,6 @@ var ts;
5079350797
if (isOpen === void 0) { isOpen = false; }
5079450798
this.host = host;
5079550799
this.fileName = fileName;
50796-
this.content = content;
5079750800
this.isOpen = isOpen;
5079850801
this.children = [];
5079950802
this.formatCodeOptions = ts.clone(CompilerService.getDefaultFormatCodeOptions(this.host));
@@ -52963,7 +52966,7 @@ var ts;
5296352966
return this.shimHost.getCurrentDirectory();
5296452967
};
5296552968
LanguageServiceShimHostAdapter.prototype.getDirectories = function (path) {
52966-
return this.shimHost.getDirectories(path);
52969+
return JSON.parse(this.shimHost.getDirectories(path));
5296752970
};
5296852971
LanguageServiceShimHostAdapter.prototype.getDefaultLibFileName = function (options) {
5296952972
return this.shimHost.getDefaultLibFileName(JSON.stringify(options));

lib/typescript.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29341,6 +29341,7 @@ var ts;
2934129341
var parameter = local_1.valueDeclaration;
2934229342
if (compilerOptions.noUnusedParameters &&
2934329343
!ts.isParameterPropertyDeclaration(parameter) &&
29344+
!parameterIsThisKeyword(parameter) &&
2934429345
!parameterNameStartsWithUnderscore(parameter)) {
2934529346
error(local_1.valueDeclaration.name, ts.Diagnostics._0_is_declared_but_never_used, local_1.name);
2934629347
}
@@ -29356,6 +29357,9 @@ var ts;
2935629357
}
2935729358
}
2935829359
}
29360+
function parameterIsThisKeyword(parameter) {
29361+
return parameter.name && parameter.name.originalKeywordKind === 97 /* ThisKeyword */;
29362+
}
2935929363
function parameterNameStartsWithUnderscore(parameter) {
2936029364
return parameter.name && parameter.name.kind === 69 /* Identifier */ && parameter.name.text.charCodeAt(0) === 95 /* _ */;
2936129365
}
@@ -59701,7 +59705,7 @@ var ts;
5970159705
return this.shimHost.getCurrentDirectory();
5970259706
};
5970359707
LanguageServiceShimHostAdapter.prototype.getDirectories = function (path) {
59704-
return this.shimHost.getDirectories(path);
59708+
return JSON.parse(this.shimHost.getDirectories(path));
5970559709
};
5970659710
LanguageServiceShimHostAdapter.prototype.getDefaultLibFileName = function (options) {
5970759711
return this.shimHost.getDefaultLibFileName(JSON.stringify(options));

lib/typescriptServices.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29341,6 +29341,7 @@ var ts;
2934129341
var parameter = local_1.valueDeclaration;
2934229342
if (compilerOptions.noUnusedParameters &&
2934329343
!ts.isParameterPropertyDeclaration(parameter) &&
29344+
!parameterIsThisKeyword(parameter) &&
2934429345
!parameterNameStartsWithUnderscore(parameter)) {
2934529346
error(local_1.valueDeclaration.name, ts.Diagnostics._0_is_declared_but_never_used, local_1.name);
2934629347
}
@@ -29356,6 +29357,9 @@ var ts;
2935629357
}
2935729358
}
2935829359
}
29360+
function parameterIsThisKeyword(parameter) {
29361+
return parameter.name && parameter.name.originalKeywordKind === 97 /* ThisKeyword */;
29362+
}
2935929363
function parameterNameStartsWithUnderscore(parameter) {
2936029364
return parameter.name && parameter.name.kind === 69 /* Identifier */ && parameter.name.text.charCodeAt(0) === 95 /* _ */;
2936129365
}
@@ -59701,7 +59705,7 @@ var ts;
5970159705
return this.shimHost.getCurrentDirectory();
5970259706
};
5970359707
LanguageServiceShimHostAdapter.prototype.getDirectories = function (path) {
59704-
return this.shimHost.getDirectories(path);
59708+
return JSON.parse(this.shimHost.getDirectories(path));
5970559709
};
5970659710
LanguageServiceShimHostAdapter.prototype.getDefaultLibFileName = function (options) {
5970759711
return this.shimHost.getDefaultLibFileName(JSON.stringify(options));

src/compiler/checker.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13277,7 +13277,7 @@ namespace ts {
1327713277
checkAsyncFunctionReturnType(<FunctionLikeDeclaration>node);
1327813278
}
1327913279
}
13280-
if (!(<FunctionDeclaration>node).body) {
13280+
if (noUnusedIdentifiers && !(<FunctionDeclaration>node).body) {
1328113281
checkUnusedTypeParameters(node);
1328213282
}
1328313283
}
@@ -14612,8 +14612,15 @@ namespace ts {
1461214612
function checkUnusedTypeParameters(node: ClassDeclaration | ClassExpression | FunctionDeclaration | MethodDeclaration | FunctionExpression | ArrowFunction | ConstructorDeclaration | SignatureDeclaration | InterfaceDeclaration) {
1461314613
if (compilerOptions.noUnusedLocals && !isInAmbientContext(node)) {
1461414614
if (node.typeParameters) {
14615+
// Only report errors on the last declaration for the type parameter container;
14616+
// this ensures that all uses have been accounted for.
14617+
const symbol = getSymbolOfNode(node);
14618+
const lastDeclaration = symbol && symbol.declarations && lastOrUndefined(symbol.declarations);
14619+
if (lastDeclaration !== node) {
14620+
return;
14621+
}
1461514622
for (const typeParameter of node.typeParameters) {
14616-
if (!typeParameter.symbol.isReferenced) {
14623+
if (!getMergedSymbol(typeParameter.symbol).isReferenced) {
1461714624
error(typeParameter.name, Diagnostics._0_is_declared_but_never_used, typeParameter.symbol.name);
1461814625
}
1461914626
}
@@ -16122,7 +16129,7 @@ namespace ts {
1612216129

1612316130
if (produceDiagnostics) {
1612416131
checkTypeForDuplicateIndexSignatures(node);
16125-
checkUnusedTypeParameters(node);
16132+
registerForUnusedIdentifiersCheck(node);
1612616133
}
1612716134
}
1612816135

src/compiler/emitter.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2749,7 +2749,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
27492749
* if we should also export the value after its it changed
27502750
* - check if node is a source level declaration to emit it differently,
27512751
* i.e non-exported variable statement 'var x = 1' is hoisted so
2752-
* we we emit variable statement 'var' should be dropped.
2752+
* when we emit variable statement 'var' should be dropped.
27532753
*/
27542754
function isSourceFileLevelDeclarationInSystemJsModule(node: Node, isExported: boolean): boolean {
27552755
if (!node || !isCurrentFileSystemExternalModule()) {
@@ -5503,16 +5503,15 @@ const _super = (function (geti, seti) {
55035503
write("export ");
55045504
}
55055505

5506-
if (!isHoistedDeclarationInSystemModule) {
5507-
write("let ");
5508-
}
55095506
if (decoratedClassAlias !== undefined) {
5510-
write(`${decoratedClassAlias}`);
5507+
write(`let ${decoratedClassAlias}`);
55115508
}
55125509
else {
5510+
if (!isHoistedDeclarationInSystemModule) {
5511+
write("let ");
5512+
}
55135513
emitDeclarationName(node);
55145514
}
5515-
55165515
write(" = ");
55175516
}
55185517
else if (isES6ExportedDeclaration(node)) {
@@ -5530,7 +5529,9 @@ const _super = (function (geti, seti) {
55305529
//
55315530
// We'll emit:
55325531
//
5533-
// (_temp = class C { ... }, _temp.a = 1, _temp.b = 2, _temp)
5532+
// let C_1 = class C{};
5533+
// C_1.a = 1;
5534+
// C_1.b = 2; // so forth and so on
55345535
//
55355536
// This keeps the expression as an expression, while ensuring that the static parts
55365537
// of it have been initialized by the time it is used.

src/compiler/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2912,7 +2912,6 @@ namespace ts {
29122912
getCancellationToken?(): CancellationToken;
29132913
getDefaultLibFileName(options: CompilerOptions): string;
29142914
getDefaultLibLocation?(): string;
2915-
getDefaultTypeDirectiveNames?(rootPath: string): string[];
29162915
writeFile: WriteFileCallback;
29172916
getCurrentDirectory(): string;
29182917
getDirectories(path: string): string[];
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//// [decoratedClassExportsCommonJS1.ts]
2+
declare var Something: any;
3+
@Something({ v: () => Testing123 })
4+
export class Testing123 {
5+
static prop0: string;
6+
static prop1 = Testing123.prop0;
7+
}
8+
9+
//// [decoratedClassExportsCommonJS1.js]
10+
"use strict";
11+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
12+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
13+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
14+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
15+
return c > 3 && r && Object.defineProperty(target, key, r), r;
16+
};
17+
var __metadata = (this && this.__metadata) || function (k, v) {
18+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
19+
};
20+
let Testing123_1 = class Testing123 {
21+
};
22+
let Testing123 = Testing123_1;
23+
Testing123.prop1 = Testing123.prop0;
24+
Testing123 = Testing123_1 = __decorate([
25+
Something({ v: () => Testing123 }),
26+
__metadata('design:paramtypes', [])
27+
], Testing123);
28+
exports.Testing123 = Testing123;

0 commit comments

Comments
 (0)