Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import helpers reports errors for __rest #12154

Merged
merged 3 commits into from
Nov 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/compiler/binder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1553,7 +1553,7 @@ namespace ts {
const seen = createMap<ElementKind>();

for (const prop of node.properties) {
if (prop.name.kind !== SyntaxKind.Identifier) {
if (prop.kind === SyntaxKind.SpreadAssignment || prop.name.kind !== SyntaxKind.Identifier) {
continue;
}

Expand Down
6 changes: 5 additions & 1 deletion src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19970,9 +19970,13 @@ namespace ts {
if (requestedExternalEmitHelpers & NodeFlags.HasClassExtends && languageVersion < ScriptTarget.ES2015) {
verifyHelperSymbol(exports, "__extends", SymbolFlags.Value);
}
if (requestedExternalEmitHelpers & NodeFlags.HasSpreadAttribute && compilerOptions.jsx !== JsxEmit.Preserve) {
if (requestedExternalEmitHelpers & NodeFlags.HasSpreadAttribute &&
(languageVersion < ScriptTarget.ESNext || compilerOptions.jsx === JsxEmit.React)) {
verifyHelperSymbol(exports, "__assign", SymbolFlags.Value);
}
if (languageVersion < ScriptTarget.ESNext && requestedExternalEmitHelpers & NodeFlags.HasRestAttribute) {
verifyHelperSymbol(exports, "__rest", SymbolFlags.Value);
}
if (requestedExternalEmitHelpers & NodeFlags.HasDecorators) {
verifyHelperSymbol(exports, "__decorate", SymbolFlags.Value);
if (compilerOptions.emitDecoratorMetadata) {
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ namespace ts {
BlockScoped = Let | Const,

ReachabilityCheckFlags = HasImplicitReturn | HasExplicitReturn,
EmitHelperFlags = HasClassExtends | HasDecorators | HasParamDecorators | HasAsyncFunctions | HasSpreadAttribute,
EmitHelperFlags = HasClassExtends | HasDecorators | HasParamDecorators | HasAsyncFunctions | HasSpreadAttribute | HasRestAttribute,
ReachabilityAndEmitFlags = ReachabilityCheckFlags | EmitHelperFlags,

// Parsing context flags
Expand Down
11 changes: 10 additions & 1 deletion tests/baselines/reference/importHelpersNoHelpers.errors.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
error TS2305: Module 'tslib' has no exported member '__assign'.
error TS2305: Module 'tslib' has no exported member '__decorate'.
error TS2305: Module 'tslib' has no exported member '__extends'.
error TS2305: Module 'tslib' has no exported member '__metadata'.
error TS2305: Module 'tslib' has no exported member '__param'.
error TS2305: Module 'tslib' has no exported member '__rest'.


!!! error TS2305: Module 'tslib' has no exported member '__assign'.
!!! error TS2305: Module 'tslib' has no exported member '__decorate'.
!!! error TS2305: Module 'tslib' has no exported member '__extends'.
!!! error TS2305: Module 'tslib' has no exported member '__metadata'.
!!! error TS2305: Module 'tslib' has no exported member '__param'.
!!! error TS2305: Module 'tslib' has no exported member '__rest'.
==== tests/cases/compiler/external.ts (0 errors) ====
export class A { }
export class B extends A { }
Expand All @@ -20,6 +24,10 @@ error TS2305: Module 'tslib' has no exported member '__param'.
}
}

const o = { a: 1 };
const y = { ...o };
const { ...x } = y;

==== tests/cases/compiler/script.ts (0 errors) ====
class A { }
class B extends A { }
Expand All @@ -33,4 +41,5 @@ error TS2305: Module 'tslib' has no exported member '__param'.
}

==== tests/cases/compiler/tslib.d.ts (0 errors) ====
export {}
export {}

10 changes: 9 additions & 1 deletion tests/baselines/reference/importHelpersNoHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ class C {
method(@dec x: number) {
}
}

const o = { a: 1 };
const y = { ...o };
const { ...x } = y;

//// [script.ts]
class A { }
Expand All @@ -25,7 +29,8 @@ class C {
}

//// [tslib.d.ts]
export {}
export {}


//// [external.js]
"use strict";
Expand Down Expand Up @@ -61,6 +66,9 @@ C = tslib_1.__decorate([
dec,
tslib_1.__metadata("design:paramtypes", [])
], C);
var o = { a: 1 };
var y = __assign({}, o);
var x = __rest(y, []);
//// [script.js]
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
Expand Down
6 changes: 5 additions & 1 deletion tests/cases/compiler/importHelpersNoHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ class C {
}
}

const o = { a: 1 };
const y = { ...o };
const { ...x } = y;

// @filename: script.ts
class A { }
class B extends A { }
Expand All @@ -29,4 +33,4 @@ class C {
}

// @filename: tslib.d.ts
export {}
export {}