Merge remote-tracking branch 'microsoft/master' into documentHighlights
This commit is contained in:
commit
6dce7ce545
|
@ -37,6 +37,11 @@
|
|||
"tslint": "latest"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "jake runtests"
|
||||
"pretest": "jake tests",
|
||||
"test": "jake runtests",
|
||||
"build": "npm run build:compiler && npm run build:tests",
|
||||
"build:compiler": "jake local",
|
||||
"build:tests": "jake tests",
|
||||
"clean": "jake clean"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6436,22 +6436,79 @@ namespace ts {
|
|||
let classType = classDeclaration && <InterfaceType>getDeclaredTypeOfSymbol(getSymbolOfNode(classDeclaration));
|
||||
let baseClassType = classType && getBaseTypes(classType)[0];
|
||||
|
||||
let container = getSuperContainer(node, /*includeFunctions*/ true);
|
||||
let needToCaptureLexicalThis = false;
|
||||
|
||||
if (!isCallExpression) {
|
||||
// adjust the container reference in case if super is used inside arrow functions with arbitrary deep nesting
|
||||
while (container && container.kind === SyntaxKind.ArrowFunction) {
|
||||
container = getSuperContainer(container, /*includeFunctions*/ true);
|
||||
needToCaptureLexicalThis = languageVersion < ScriptTarget.ES6;
|
||||
}
|
||||
}
|
||||
|
||||
let canUseSuperExpression = isLegalUsageOfSuperExpression(container);
|
||||
let nodeCheckFlag: NodeCheckFlags = 0;
|
||||
|
||||
// always set NodeCheckFlags for 'super' expression node
|
||||
if (canUseSuperExpression) {
|
||||
if ((container.flags & NodeFlags.Static) || isCallExpression) {
|
||||
nodeCheckFlag = NodeCheckFlags.SuperStatic;
|
||||
}
|
||||
else {
|
||||
nodeCheckFlag = NodeCheckFlags.SuperInstance;
|
||||
}
|
||||
|
||||
getNodeLinks(node).flags |= nodeCheckFlag;
|
||||
|
||||
if (needToCaptureLexicalThis) {
|
||||
// call expressions are allowed only in constructors so they should always capture correct 'this'
|
||||
// super property access expressions can also appear in arrow functions -
|
||||
// in this case they should also use correct lexical this
|
||||
captureLexicalThis(node.parent, container);
|
||||
}
|
||||
}
|
||||
|
||||
if (!baseClassType) {
|
||||
if (!classDeclaration || !getClassExtendsHeritageClauseElement(classDeclaration)) {
|
||||
error(node, Diagnostics.super_can_only_be_referenced_in_a_derived_class);
|
||||
}
|
||||
return unknownType;
|
||||
}
|
||||
|
||||
if (!canUseSuperExpression) {
|
||||
if (container && container.kind === SyntaxKind.ComputedPropertyName) {
|
||||
error(node, Diagnostics.super_cannot_be_referenced_in_a_computed_property_name);
|
||||
}
|
||||
else if (isCallExpression) {
|
||||
error(node, Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors);
|
||||
}
|
||||
else {
|
||||
error(node, Diagnostics.super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class);
|
||||
}
|
||||
|
||||
return unknownType;
|
||||
}
|
||||
|
||||
if (container.kind === SyntaxKind.Constructor && isInConstructorArgumentInitializer(node, container)) {
|
||||
// issue custom error message for super property access in constructor arguments (to be aligned with old compiler)
|
||||
error(node, Diagnostics.super_cannot_be_referenced_in_constructor_arguments);
|
||||
return unknownType;
|
||||
}
|
||||
|
||||
return nodeCheckFlag === NodeCheckFlags.SuperStatic
|
||||
? getBaseConstructorTypeOfClass(classType)
|
||||
: baseClassType;
|
||||
|
||||
function isLegalUsageOfSuperExpression(container: Node): boolean {
|
||||
if (!container) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let container = getSuperContainer(node, /*includeFunctions*/ true);
|
||||
|
||||
if (container) {
|
||||
let canUseSuperExpression = false;
|
||||
let needToCaptureLexicalThis: boolean;
|
||||
if (isCallExpression) {
|
||||
// TS 1.0 SPEC (April 2014): 4.8.1
|
||||
// Super calls are only permitted in constructors of derived classes
|
||||
canUseSuperExpression = container.kind === SyntaxKind.Constructor;
|
||||
return container.kind === SyntaxKind.Constructor;
|
||||
}
|
||||
else {
|
||||
// TS 1.0 SPEC (April 2014)
|
||||
|
@ -6459,75 +6516,28 @@ namespace ts {
|
|||
// - In a constructor, instance member function, instance member accessor, or instance member variable initializer where this references a derived class instance
|
||||
// - In a static member function or static member accessor
|
||||
|
||||
// super property access might appear in arrow functions with arbitrary deep nesting
|
||||
needToCaptureLexicalThis = false;
|
||||
while (container && container.kind === SyntaxKind.ArrowFunction) {
|
||||
container = getSuperContainer(container, /*includeFunctions*/ true);
|
||||
needToCaptureLexicalThis = languageVersion < ScriptTarget.ES6;
|
||||
}
|
||||
|
||||
// topmost container must be something that is directly nested in the class declaration
|
||||
if (container && isClassLike(container.parent)) {
|
||||
if (container.flags & NodeFlags.Static) {
|
||||
canUseSuperExpression =
|
||||
container.kind === SyntaxKind.MethodDeclaration ||
|
||||
container.kind === SyntaxKind.MethodSignature ||
|
||||
container.kind === SyntaxKind.GetAccessor ||
|
||||
container.kind === SyntaxKind.SetAccessor;
|
||||
return container.kind === SyntaxKind.MethodDeclaration ||
|
||||
container.kind === SyntaxKind.MethodSignature ||
|
||||
container.kind === SyntaxKind.GetAccessor ||
|
||||
container.kind === SyntaxKind.SetAccessor;
|
||||
}
|
||||
else {
|
||||
canUseSuperExpression =
|
||||
container.kind === SyntaxKind.MethodDeclaration ||
|
||||
container.kind === SyntaxKind.MethodSignature ||
|
||||
container.kind === SyntaxKind.GetAccessor ||
|
||||
container.kind === SyntaxKind.SetAccessor ||
|
||||
container.kind === SyntaxKind.PropertyDeclaration ||
|
||||
container.kind === SyntaxKind.PropertySignature ||
|
||||
container.kind === SyntaxKind.Constructor;
|
||||
return container.kind === SyntaxKind.MethodDeclaration ||
|
||||
container.kind === SyntaxKind.MethodSignature ||
|
||||
container.kind === SyntaxKind.GetAccessor ||
|
||||
container.kind === SyntaxKind.SetAccessor ||
|
||||
container.kind === SyntaxKind.PropertyDeclaration ||
|
||||
container.kind === SyntaxKind.PropertySignature ||
|
||||
container.kind === SyntaxKind.Constructor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (canUseSuperExpression) {
|
||||
let returnType: Type;
|
||||
|
||||
if ((container.flags & NodeFlags.Static) || isCallExpression) {
|
||||
getNodeLinks(node).flags |= NodeCheckFlags.SuperStatic;
|
||||
returnType = getBaseConstructorTypeOfClass(classType);
|
||||
}
|
||||
else {
|
||||
getNodeLinks(node).flags |= NodeCheckFlags.SuperInstance;
|
||||
returnType = baseClassType;
|
||||
}
|
||||
|
||||
if (container.kind === SyntaxKind.Constructor && isInConstructorArgumentInitializer(node, container)) {
|
||||
// issue custom error message for super property access in constructor arguments (to be aligned with old compiler)
|
||||
error(node, Diagnostics.super_cannot_be_referenced_in_constructor_arguments);
|
||||
returnType = unknownType;
|
||||
}
|
||||
|
||||
if (!isCallExpression && needToCaptureLexicalThis) {
|
||||
// call expressions are allowed only in constructors so they should always capture correct 'this'
|
||||
// super property access expressions can also appear in arrow functions -
|
||||
// in this case they should also use correct lexical this
|
||||
captureLexicalThis(node.parent, container);
|
||||
}
|
||||
|
||||
return returnType;
|
||||
}
|
||||
}
|
||||
|
||||
if (container && container.kind === SyntaxKind.ComputedPropertyName) {
|
||||
error(node, Diagnostics.super_cannot_be_referenced_in_a_computed_property_name);
|
||||
}
|
||||
else if (isCallExpression) {
|
||||
error(node, Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors);
|
||||
}
|
||||
else {
|
||||
error(node, Diagnostics.super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class);
|
||||
}
|
||||
|
||||
return unknownType;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Return contextual type of parameter or undefined if no contextual type is available
|
||||
|
|
|
@ -6259,6 +6259,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
|||
write(`], function(${exportFunctionForFile}) {`);
|
||||
writeLine();
|
||||
increaseIndent();
|
||||
emitEmitHelpers(node);
|
||||
emitCaptureThisForNodeIfNecessary(node);
|
||||
emitSystemModuleBody(node, startIndex);
|
||||
decreaseIndent();
|
||||
|
@ -6330,6 +6331,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
|||
}
|
||||
|
||||
function emitAMDModule(node: SourceFile, startIndex: number) {
|
||||
emitEmitHelpers(node);
|
||||
collectExternalModuleInfo(node);
|
||||
|
||||
writeLine();
|
||||
|
@ -6351,6 +6353,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
|||
}
|
||||
|
||||
function emitCommonJSModule(node: SourceFile, startIndex: number) {
|
||||
emitEmitHelpers(node);
|
||||
collectExternalModuleInfo(node);
|
||||
emitExportStarHelper();
|
||||
emitCaptureThisForNodeIfNecessary(node);
|
||||
|
@ -6360,6 +6363,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
|||
}
|
||||
|
||||
function emitUMDModule(node: SourceFile, startIndex: number) {
|
||||
emitEmitHelpers(node);
|
||||
collectExternalModuleInfo(node);
|
||||
|
||||
// Module is detected first to support Browserify users that load into a browser with an AMD loader
|
||||
|
@ -6389,6 +6393,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
|||
exportSpecifiers = undefined;
|
||||
exportEquals = undefined;
|
||||
hasExportStars = false;
|
||||
emitEmitHelpers(node);
|
||||
emitCaptureThisForNodeIfNecessary(node);
|
||||
emitLinesStartingAt(node.statements, startIndex);
|
||||
emitTempDeclarations(/*newLine*/ true);
|
||||
|
@ -6527,14 +6532,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
|||
}
|
||||
}
|
||||
|
||||
function emitSourceFileNode(node: SourceFile) {
|
||||
// Start new file on new line
|
||||
writeLine();
|
||||
emitDetachedComments(node);
|
||||
|
||||
// emit prologue directives prior to __extends
|
||||
let startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false);
|
||||
|
||||
function emitEmitHelpers(node: SourceFile): void {
|
||||
// Only emit helpers if the user did not say otherwise.
|
||||
if (!compilerOptions.noEmitHelpers) {
|
||||
// Only Emit __extends function when target ES5.
|
||||
|
@ -6562,6 +6560,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
|||
awaiterEmitted = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function emitSourceFileNode(node: SourceFile) {
|
||||
// Start new file on new line
|
||||
writeLine();
|
||||
emitShebang();
|
||||
emitDetachedComments(node);
|
||||
|
||||
// emit prologue directives prior to __extends
|
||||
let startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false);
|
||||
|
||||
if (isExternalModule(node) || compilerOptions.isolatedModules) {
|
||||
if (languageVersion >= ScriptTarget.ES6) {
|
||||
|
@ -6585,6 +6593,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
|||
exportSpecifiers = undefined;
|
||||
exportEquals = undefined;
|
||||
hasExportStars = false;
|
||||
emitEmitHelpers(node);
|
||||
emitCaptureThisForNodeIfNecessary(node);
|
||||
emitLinesStartingAt(node.statements, startIndex);
|
||||
emitTempDeclarations(/*newLine*/ true);
|
||||
|
@ -6978,6 +6987,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
function emitShebang() {
|
||||
let shebang = getShebang(currentSourceFile.text);
|
||||
if (shebang) {
|
||||
write(shebang);
|
||||
}
|
||||
}
|
||||
|
||||
function isPinnedOrTripleSlashComment(comment: CommentRange) {
|
||||
if (currentSourceFile.text.charCodeAt(comment.pos + 1) === CharacterCodes.asterisk) {
|
||||
|
|
|
@ -401,6 +401,9 @@ namespace ts {
|
|||
case CharacterCodes.greaterThan:
|
||||
// Starts of conflict marker trivia
|
||||
return true;
|
||||
case CharacterCodes.hash:
|
||||
// Only if its the beginning can we have #! trivia
|
||||
return pos === 0;
|
||||
default:
|
||||
return ch > CharacterCodes.maxAsciiCharacter;
|
||||
}
|
||||
|
@ -461,6 +464,13 @@ namespace ts {
|
|||
}
|
||||
break;
|
||||
|
||||
case CharacterCodes.hash:
|
||||
if (isShebangTrivia(text, pos)) {
|
||||
pos = scanShebangTrivia(text, pos);
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
if (ch > CharacterCodes.maxAsciiCharacter && (isWhiteSpace(ch) || isLineBreak(ch))) {
|
||||
pos++;
|
||||
|
@ -528,6 +538,20 @@ namespace ts {
|
|||
return pos;
|
||||
}
|
||||
|
||||
const shebangTriviaRegex = /^#!.*/;
|
||||
|
||||
function isShebangTrivia(text: string, pos: number) {
|
||||
// Shebangs check must only be done at the start of the file
|
||||
Debug.assert(pos === 0);
|
||||
return shebangTriviaRegex.test(text);
|
||||
}
|
||||
|
||||
function scanShebangTrivia(text: string, pos: number) {
|
||||
let shebang = shebangTriviaRegex.exec(text)[0];
|
||||
pos = pos + shebang.length;
|
||||
return pos;
|
||||
}
|
||||
|
||||
// Extract comments from the given source text starting at the given position. If trailing is
|
||||
// false, whitespace is skipped until the first line break and comments between that location
|
||||
// and the next token are returned.If trailing is true, comments occurring between the given
|
||||
|
@ -617,6 +641,13 @@ namespace ts {
|
|||
export function getTrailingCommentRanges(text: string, pos: number): CommentRange[] {
|
||||
return getCommentRanges(text, pos, /*trailing*/ true);
|
||||
}
|
||||
|
||||
/** Optionally, get the shebang */
|
||||
export function getShebang(text: string): string {
|
||||
return shebangTriviaRegex.test(text)
|
||||
? shebangTriviaRegex.exec(text)[0]
|
||||
: undefined;
|
||||
}
|
||||
|
||||
export function isIdentifierStart(ch: number, languageVersion: ScriptTarget): boolean {
|
||||
return ch >= CharacterCodes.A && ch <= CharacterCodes.Z || ch >= CharacterCodes.a && ch <= CharacterCodes.z ||
|
||||
|
@ -1087,6 +1118,18 @@ namespace ts {
|
|||
return token = SyntaxKind.EndOfFileToken;
|
||||
}
|
||||
let ch = text.charCodeAt(pos);
|
||||
|
||||
// Special handling for shebang
|
||||
if (ch === CharacterCodes.hash && pos === 0 && isShebangTrivia(text, pos)) {
|
||||
pos = scanShebangTrivia(text ,pos);
|
||||
if (skipTrivia) {
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
return token = SyntaxKind.ShebangTrivia;
|
||||
}
|
||||
}
|
||||
|
||||
switch (ch) {
|
||||
case CharacterCodes.lineFeed:
|
||||
case CharacterCodes.carriageReturn:
|
||||
|
|
|
@ -17,6 +17,7 @@ namespace ts {
|
|||
}
|
||||
|
||||
// token > SyntaxKind.Identifer => token is a keyword
|
||||
// Also, If you add a new SyntaxKind be sure to keep the `Markers` section at the bottom in sync
|
||||
export const enum SyntaxKind {
|
||||
Unknown,
|
||||
EndOfFileToken,
|
||||
|
@ -24,6 +25,8 @@ namespace ts {
|
|||
MultiLineCommentTrivia,
|
||||
NewLineTrivia,
|
||||
WhitespaceTrivia,
|
||||
// We detect and preserve #! on the first line
|
||||
ShebangTrivia,
|
||||
// We detect and provide better error recovery when we encounter a git merge marker. This
|
||||
// allows us to edit files with git-conflict markers in them in a much more pleasant manner.
|
||||
ConflictMarkerTrivia,
|
||||
|
|
|
@ -75,28 +75,28 @@ function delint(sourceFile) {
|
|||
delintNode(sourceFile);
|
||||
function delintNode(node) {
|
||||
switch (node.kind) {
|
||||
case 196 /* ForStatement */:
|
||||
case 197 /* ForInStatement */:
|
||||
case 195 /* WhileStatement */:
|
||||
case 194 /* DoStatement */:
|
||||
if (node.statement.kind !== 189 /* Block */) {
|
||||
case 197 /* ForStatement */:
|
||||
case 198 /* ForInStatement */:
|
||||
case 196 /* WhileStatement */:
|
||||
case 195 /* DoStatement */:
|
||||
if (node.statement.kind !== 190 /* Block */) {
|
||||
report(node, "A looping statement's contents should be wrapped in a block body.");
|
||||
}
|
||||
break;
|
||||
case 193 /* IfStatement */:
|
||||
case 194 /* IfStatement */:
|
||||
var ifStatement = node;
|
||||
if (ifStatement.thenStatement.kind !== 189 /* Block */) {
|
||||
if (ifStatement.thenStatement.kind !== 190 /* Block */) {
|
||||
report(ifStatement.thenStatement, "An if statement's contents should be wrapped in a block body.");
|
||||
}
|
||||
if (ifStatement.elseStatement &&
|
||||
ifStatement.elseStatement.kind !== 189 /* Block */ &&
|
||||
ifStatement.elseStatement.kind !== 193 /* IfStatement */) {
|
||||
ifStatement.elseStatement.kind !== 190 /* Block */ &&
|
||||
ifStatement.elseStatement.kind !== 194 /* IfStatement */) {
|
||||
report(ifStatement.elseStatement, "An else statement's contents should be wrapped in a block body.");
|
||||
}
|
||||
break;
|
||||
case 178 /* BinaryExpression */:
|
||||
case 179 /* BinaryExpression */:
|
||||
var op = node.operatorToken.kind;
|
||||
if (op === 29 /* EqualsEqualsToken */ || op == 30 /* ExclamationEqualsToken */) {
|
||||
if (op === 30 /* EqualsEqualsToken */ || op == 31 /* ExclamationEqualsToken */) {
|
||||
report(node, "Use '===' and '!=='.");
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -139,14 +139,14 @@ var __extends = (this && this.__extends) || function (d, b) {
|
|||
//super property access in instance member accessor(get and set) of class with no base type
|
||||
var NoBase = (function () {
|
||||
function NoBase() {
|
||||
this.m = _super.prototype;
|
||||
this.n = _super.hasOwnProperty.call(this, '');
|
||||
var a = _super.prototype;
|
||||
var b = _super.hasOwnProperty.call(this, '');
|
||||
this.m = _super.prototype.prototype;
|
||||
this.n = _super.prototype.hasOwnProperty.call(this, '');
|
||||
var a = _super.prototype.prototype;
|
||||
var b = _super.prototype.hasOwnProperty.call(this, '');
|
||||
}
|
||||
NoBase.prototype.fn = function () {
|
||||
var a = _super.prototype;
|
||||
var b = _super.hasOwnProperty.call(this, '');
|
||||
var a = _super.prototype.prototype;
|
||||
var b = _super.prototype.hasOwnProperty.call(this, '');
|
||||
};
|
||||
//super static property access in static member function of class with no base type
|
||||
//super static property access in static member accessor(get and set) of class with no base type
|
||||
|
|
|
@ -18,7 +18,7 @@ var C = (function () {
|
|||
function C() {
|
||||
}
|
||||
C.prototype.foo = function () {
|
||||
_super.foo.call(this);
|
||||
_super.prototype.foo.call(this);
|
||||
};
|
||||
return C;
|
||||
})();
|
||||
|
@ -30,7 +30,7 @@ var M1;
|
|||
function C() {
|
||||
}
|
||||
C.prototype.foo = function () {
|
||||
_super.foo.call(this);
|
||||
_super.prototype.foo.call(this);
|
||||
};
|
||||
return C;
|
||||
})();
|
||||
|
|
|
@ -10,7 +10,7 @@ var C = (function () {
|
|||
function C() {
|
||||
}
|
||||
C.prototype.M = function () {
|
||||
_super..call(this, 0);
|
||||
_super.prototype..call(this, 0);
|
||||
};
|
||||
return C;
|
||||
})();
|
||||
|
|
|
@ -18,7 +18,7 @@ var C = (function () {
|
|||
function C() {
|
||||
}
|
||||
C.prototype.foo = function () {
|
||||
_super.foo = 1;
|
||||
_super.prototype.foo = 1;
|
||||
};
|
||||
return C;
|
||||
})();
|
||||
|
@ -30,7 +30,7 @@ var M1;
|
|||
function C() {
|
||||
}
|
||||
C.prototype.foo = function () {
|
||||
_super.foo = 1;
|
||||
_super.prototype.foo = 1;
|
||||
};
|
||||
return C;
|
||||
})();
|
||||
|
|
8
tests/baselines/reference/shebang.js
Normal file
8
tests/baselines/reference/shebang.js
Normal file
|
@ -0,0 +1,8 @@
|
|||
//// [shebang.ts]
|
||||
#!/usr/bin/env node
|
||||
var foo = 'I wish the generated JS to be executed in node';
|
||||
|
||||
|
||||
//// [shebang.js]
|
||||
#!/usr/bin/env node
|
||||
var foo = 'I wish the generated JS to be executed in node';
|
5
tests/baselines/reference/shebang.symbols
Normal file
5
tests/baselines/reference/shebang.symbols
Normal file
|
@ -0,0 +1,5 @@
|
|||
=== tests/cases/compiler/shebang.ts ===
|
||||
#!/usr/bin/env node
|
||||
var foo = 'I wish the generated JS to be executed in node';
|
||||
>foo : Symbol(foo, Decl(shebang.ts, 1, 3))
|
||||
|
6
tests/baselines/reference/shebang.types
Normal file
6
tests/baselines/reference/shebang.types
Normal file
|
@ -0,0 +1,6 @@
|
|||
=== tests/cases/compiler/shebang.ts ===
|
||||
#!/usr/bin/env node
|
||||
var foo = 'I wish the generated JS to be executed in node';
|
||||
>foo : string
|
||||
>'I wish the generated JS to be executed in node' : string
|
||||
|
20
tests/baselines/reference/shebangError.errors.txt
Normal file
20
tests/baselines/reference/shebangError.errors.txt
Normal file
|
@ -0,0 +1,20 @@
|
|||
tests/cases/compiler/shebangError.ts(2,1): error TS1127: Invalid character.
|
||||
tests/cases/compiler/shebangError.ts(2,2): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
tests/cases/compiler/shebangError.ts(2,12): error TS2304: Cannot find name 'env'.
|
||||
tests/cases/compiler/shebangError.ts(2,16): error TS1005: ';' expected.
|
||||
tests/cases/compiler/shebangError.ts(2,16): error TS2304: Cannot find name 'node'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/shebangError.ts (5 errors) ====
|
||||
var foo = 'Shebang is only allowed on the first line';
|
||||
#!/usr/bin/env node
|
||||
|
||||
!!! error TS1127: Invalid character.
|
||||
~~~~~~~~~
|
||||
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
|
||||
~~~
|
||||
!!! error TS2304: Cannot find name 'env'.
|
||||
~~~~
|
||||
!!! error TS1005: ';' expected.
|
||||
~~~~
|
||||
!!! error TS2304: Cannot find name 'node'.
|
8
tests/baselines/reference/shebangError.js
Normal file
8
tests/baselines/reference/shebangError.js
Normal file
|
@ -0,0 +1,8 @@
|
|||
//// [shebangError.ts]
|
||||
var foo = 'Shebang is only allowed on the first line';
|
||||
#!/usr/bin/env node
|
||||
|
||||
//// [shebangError.js]
|
||||
var foo = 'Shebang is only allowed on the first line';
|
||||
!/usr/bin / env;
|
||||
node;
|
|
@ -79,7 +79,7 @@ var Base2 = (function () {
|
|||
function Base2() {
|
||||
}
|
||||
Base2.prototype.foo = function () {
|
||||
_super.foo.call(this);
|
||||
_super.prototype.foo.call(this);
|
||||
};
|
||||
return Base2;
|
||||
})();
|
||||
|
|
|
@ -165,7 +165,7 @@ var Base4;
|
|||
function Sub4E() {
|
||||
}
|
||||
Sub4E.prototype.x = function () {
|
||||
return _super.x.call(this);
|
||||
return _super.prototype.x.call(this);
|
||||
};
|
||||
return Sub4E;
|
||||
})();
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
tests/cases/compiler/superCallWithMissingBaseClass.ts(1,19): error TS2304: Cannot find name 'Bar'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/superCallWithMissingBaseClass.ts (1 errors) ====
|
||||
class Foo extends Bar {
|
||||
~~~
|
||||
!!! error TS2304: Cannot find name 'Bar'.
|
||||
m1() {
|
||||
return super.m1();
|
||||
}
|
||||
|
||||
static m2() {
|
||||
return super.m2();
|
||||
}
|
||||
}
|
30
tests/baselines/reference/superCallWithMissingBaseClass.js
Normal file
30
tests/baselines/reference/superCallWithMissingBaseClass.js
Normal file
|
@ -0,0 +1,30 @@
|
|||
//// [superCallWithMissingBaseClass.ts]
|
||||
class Foo extends Bar {
|
||||
m1() {
|
||||
return super.m1();
|
||||
}
|
||||
|
||||
static m2() {
|
||||
return super.m2();
|
||||
}
|
||||
}
|
||||
|
||||
//// [superCallWithMissingBaseClass.js]
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
var Foo = (function (_super) {
|
||||
__extends(Foo, _super);
|
||||
function Foo() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
Foo.prototype.m1 = function () {
|
||||
return _super.prototype.m1.call(this);
|
||||
};
|
||||
Foo.m2 = function () {
|
||||
return _super.m2.call(this);
|
||||
};
|
||||
return Foo;
|
||||
})(Bar);
|
55
tests/baselines/reference/systemModuleWithSuperClass.js
Normal file
55
tests/baselines/reference/systemModuleWithSuperClass.js
Normal file
|
@ -0,0 +1,55 @@
|
|||
//// [tests/cases/compiler/systemModuleWithSuperClass.ts] ////
|
||||
|
||||
//// [foo.ts]
|
||||
|
||||
export class Foo {
|
||||
a: string;
|
||||
}
|
||||
|
||||
//// [bar.ts]
|
||||
import {Foo} from './foo';
|
||||
export class Bar extends Foo {
|
||||
b: string;
|
||||
}
|
||||
|
||||
//// [foo.js]
|
||||
System.register([], function(exports_1) {
|
||||
var Foo;
|
||||
return {
|
||||
setters:[],
|
||||
execute: function() {
|
||||
Foo = (function () {
|
||||
function Foo() {
|
||||
}
|
||||
return Foo;
|
||||
})();
|
||||
exports_1("Foo", Foo);
|
||||
}
|
||||
}
|
||||
});
|
||||
//// [bar.js]
|
||||
System.register(['./foo'], function(exports_1) {
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
var foo_1;
|
||||
var Bar;
|
||||
return {
|
||||
setters:[
|
||||
function (_foo_1) {
|
||||
foo_1 = _foo_1;
|
||||
}],
|
||||
execute: function() {
|
||||
Bar = (function (_super) {
|
||||
__extends(Bar, _super);
|
||||
function Bar() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
return Bar;
|
||||
})(foo_1.Foo);
|
||||
exports_1("Bar", Bar);
|
||||
}
|
||||
}
|
||||
});
|
20
tests/baselines/reference/systemModuleWithSuperClass.symbols
Normal file
20
tests/baselines/reference/systemModuleWithSuperClass.symbols
Normal file
|
@ -0,0 +1,20 @@
|
|||
=== tests/cases/compiler/foo.ts ===
|
||||
|
||||
export class Foo {
|
||||
>Foo : Symbol(Foo, Decl(foo.ts, 0, 0))
|
||||
|
||||
a: string;
|
||||
>a : Symbol(a, Decl(foo.ts, 1, 18))
|
||||
}
|
||||
|
||||
=== tests/cases/compiler/bar.ts ===
|
||||
import {Foo} from './foo';
|
||||
>Foo : Symbol(Foo, Decl(bar.ts, 0, 8))
|
||||
|
||||
export class Bar extends Foo {
|
||||
>Bar : Symbol(Bar, Decl(bar.ts, 0, 26))
|
||||
>Foo : Symbol(Foo, Decl(bar.ts, 0, 8))
|
||||
|
||||
b: string;
|
||||
>b : Symbol(b, Decl(bar.ts, 1, 30))
|
||||
}
|
20
tests/baselines/reference/systemModuleWithSuperClass.types
Normal file
20
tests/baselines/reference/systemModuleWithSuperClass.types
Normal file
|
@ -0,0 +1,20 @@
|
|||
=== tests/cases/compiler/foo.ts ===
|
||||
|
||||
export class Foo {
|
||||
>Foo : Foo
|
||||
|
||||
a: string;
|
||||
>a : string
|
||||
}
|
||||
|
||||
=== tests/cases/compiler/bar.ts ===
|
||||
import {Foo} from './foo';
|
||||
>Foo : typeof Foo
|
||||
|
||||
export class Bar extends Foo {
|
||||
>Bar : Bar
|
||||
>Foo : Foo
|
||||
|
||||
b: string;
|
||||
>b : string
|
||||
}
|
2
tests/cases/compiler/shebang.ts
Normal file
2
tests/cases/compiler/shebang.ts
Normal file
|
@ -0,0 +1,2 @@
|
|||
#!/usr/bin/env node
|
||||
var foo = 'I wish the generated JS to be executed in node';
|
2
tests/cases/compiler/shebangError.ts
Normal file
2
tests/cases/compiler/shebangError.ts
Normal file
|
@ -0,0 +1,2 @@
|
|||
var foo = 'Shebang is only allowed on the first line';
|
||||
#!/usr/bin/env node
|
9
tests/cases/compiler/superCallWithMissingBaseClass.ts
Normal file
9
tests/cases/compiler/superCallWithMissingBaseClass.ts
Normal file
|
@ -0,0 +1,9 @@
|
|||
class Foo extends Bar {
|
||||
m1() {
|
||||
return super.m1();
|
||||
}
|
||||
|
||||
static m2() {
|
||||
return super.m2();
|
||||
}
|
||||
}
|
12
tests/cases/compiler/systemModuleWithSuperClass.ts
Normal file
12
tests/cases/compiler/systemModuleWithSuperClass.ts
Normal file
|
@ -0,0 +1,12 @@
|
|||
// @module: system
|
||||
|
||||
// @Filename: foo.ts
|
||||
export class Foo {
|
||||
a: string;
|
||||
}
|
||||
|
||||
// @Filename: bar.ts
|
||||
import {Foo} from './foo';
|
||||
export class Bar extends Foo {
|
||||
b: string;
|
||||
}
|
17
tslint.json
17
tslint.json
|
@ -4,20 +4,31 @@
|
|||
"comment-format": [true,
|
||||
"check-space"
|
||||
],
|
||||
"indent": true,
|
||||
"indent": [true,
|
||||
"spaces"
|
||||
],
|
||||
"one-line": [true,
|
||||
"check-open-brace"
|
||||
],
|
||||
"no-unreachable": true,
|
||||
"no-use-before-declare": true,
|
||||
"no-var-keyword": true,
|
||||
"quotemark": true,
|
||||
"quotemark": [true,
|
||||
"double"
|
||||
],
|
||||
"semicolon": true,
|
||||
"whitespace": [true,
|
||||
"check-branch",
|
||||
"check-operator",
|
||||
"check-separator",
|
||||
"check-type"
|
||||
]
|
||||
],
|
||||
"typedef-whitespace": [true, {
|
||||
"call-signature": "nospace",
|
||||
"index-signature": "nospace",
|
||||
"parameter": "nospace",
|
||||
"property-declaration": "nospace",
|
||||
"variable-declaration": "nospace"
|
||||
}]
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue