Skip to content

Commit

Permalink
WIP more tests, almost done
Browse files Browse the repository at this point in the history
  • Loading branch information
weswigham committed Aug 24, 2022
1 parent b45165d commit 1be381d
Show file tree
Hide file tree
Showing 129 changed files with 10,734 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/compiler/binder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1351,7 +1351,7 @@ namespace ts {
const clause = clauses[i];
bind(clause);
fallthroughFlow = currentFlow;
if (!(currentFlow.flags & FlowFlags.Unreachable) && i !== clauses.length - 1 && options.noFallthroughCasesInSwitch) {
if (!(currentFlow.flags & FlowFlags.Unreachable) && i !== clauses.length - 1 && getFileLocalCompilerOption(file, options, "noFallthroughCasesInSwitch")) {
clause.fallthroughFlowNode = currentFlow;
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12742,7 +12742,7 @@ namespace ts {
return symbol;
}
if (skipObjectFunctionPropertyAugment) return undefined;
const file = symbol?.valueDeclaration && getSourceFileOfNode(symbol.valueDeclaration);
const file = resolved.symbol?.declarations?.[0] && getSourceFileOfNode(resolved.symbol.declarations[0]);
const functionType = resolved === anyFunctionType ? globalFunctionType :
resolved.callSignatures.length ? globalCallableFunctionType(file) :
resolved.constructSignatures.length ? globalNewableFunctionType(file) :
Expand Down Expand Up @@ -19123,8 +19123,8 @@ namespace ts {
}

function hasExcessProperties(source: FreshObjectLiteralType, target: Type, reportErrors: boolean): boolean {
const sourceNoImplicitAny = noImplicitAny(source.symbol?.valueDeclaration);
const targetNoImplicitAny = noImplicitAny(target.symbol?.valueDeclaration);
const sourceNoImplicitAny = noImplicitAny(source.symbol?.declarations?.[0]);
const targetNoImplicitAny = noImplicitAny(target.symbol?.declarations?.[0]);
if (!isExcessPropertyCheckTarget(target) || !(sourceNoImplicitAny || targetNoImplicitAny) && getObjectFlags(target) & ObjectFlags.JSLiteral) {
return false; // Disable excess property checks on JS literals to simulate having an implicit "index signature" - but only outside of noImplicitAny
}
Expand Down Expand Up @@ -43113,7 +43113,7 @@ namespace ts {
function getAugmentedPropertiesOfType(type: Type): Symbol[] {
type = getApparentType(type);
const propsByName = createSymbolTable(getPropertiesOfType(type));
const file = type.symbol?.valueDeclaration && getSourceFileOfNode(type.symbol.valueDeclaration);
const file = type.symbol?.declarations?.[0] && getSourceFileOfNode(type.symbol.declarations[0]);
const functionType = getSignaturesOfType(type, SignatureKind.Call).length ? globalCallableFunctionType(file) :
getSignaturesOfType(type, SignatureKind.Construct).length ? globalNewableFunctionType(file) :
undefined;
Expand Down
20 changes: 20 additions & 0 deletions tests/baselines/reference/alwaysStrictPragma1.errors.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
tests/cases/conformance/pragma/alwaysStrict/file1.ts(2,5): error TS1212: Identifier expected. 'private' is a reserved word in strict mode.
tests/cases/conformance/pragma/alwaysStrict/file2.ts(2,5): error TS1212: Identifier expected. 'protected' is a reserved word in strict mode.


==== tests/cases/conformance/pragma/alwaysStrict/file1.ts (1 errors) ====
// @ts-alwaysStrict
let private = {};
~~~~~~~
!!! error TS1212: Identifier expected. 'private' is a reserved word in strict mode.
==== tests/cases/conformance/pragma/alwaysStrict/file2.ts (1 errors) ====
// @ts-alwaysStrict true
let protected = {};
~~~~~~~~~
!!! error TS1212: Identifier expected. 'protected' is a reserved word in strict mode.
==== tests/cases/conformance/pragma/alwaysStrict/file3.ts (0 errors) ====
// @ts-alwaysStrict false
let public = {};
==== tests/cases/conformance/pragma/alwaysStrict/file4.ts (0 errors) ====
let static = {};

28 changes: 28 additions & 0 deletions tests/baselines/reference/alwaysStrictPragma1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//// [tests/cases/conformance/pragma/alwaysStrict/alwaysStrictPragma1.ts] ////

//// [file1.ts]
// @ts-alwaysStrict
let private = {};
//// [file2.ts]
// @ts-alwaysStrict true
let protected = {};
//// [file3.ts]
// @ts-alwaysStrict false
let public = {};
//// [file4.ts]
let static = {};


//// [file1.js]
"use strict";
// @ts-alwaysStrict
var private = {};
//// [file2.js]
"use strict";
// @ts-alwaysStrict true
var protected = {};
//// [file3.js]
// @ts-alwaysStrict false
var public = {};
//// [file4.js]
var static = {};
19 changes: 19 additions & 0 deletions tests/baselines/reference/alwaysStrictPragma1.symbols
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
=== tests/cases/conformance/pragma/alwaysStrict/file1.ts ===
// @ts-alwaysStrict
let private = {};
>private : Symbol(private, Decl(file1.ts, 1, 3))

=== tests/cases/conformance/pragma/alwaysStrict/file2.ts ===
// @ts-alwaysStrict true
let protected = {};
>protected : Symbol(protected, Decl(file2.ts, 1, 3))

=== tests/cases/conformance/pragma/alwaysStrict/file3.ts ===
// @ts-alwaysStrict false
let public = {};
>public : Symbol(public, Decl(file3.ts, 1, 3))

=== tests/cases/conformance/pragma/alwaysStrict/file4.ts ===
let static = {};
>static : Symbol(static, Decl(file4.ts, 0, 3))

23 changes: 23 additions & 0 deletions tests/baselines/reference/alwaysStrictPragma1.types
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
=== tests/cases/conformance/pragma/alwaysStrict/file1.ts ===
// @ts-alwaysStrict
let private = {};
>private : {}
>{} : {}

=== tests/cases/conformance/pragma/alwaysStrict/file2.ts ===
// @ts-alwaysStrict true
let protected = {};
>protected : {}
>{} : {}

=== tests/cases/conformance/pragma/alwaysStrict/file3.ts ===
// @ts-alwaysStrict false
let public = {};
>public : {}
>{} : {}

=== tests/cases/conformance/pragma/alwaysStrict/file4.ts ===
let static = {};
>static : {}
>{} : {}

23 changes: 23 additions & 0 deletions tests/baselines/reference/alwaysStrictPragma2.errors.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
tests/cases/conformance/pragma/alwaysStrict/file1.ts(2,5): error TS1212: Identifier expected. 'private' is a reserved word in strict mode.
tests/cases/conformance/pragma/alwaysStrict/file2.ts(2,5): error TS1212: Identifier expected. 'protected' is a reserved word in strict mode.
tests/cases/conformance/pragma/alwaysStrict/file4.ts(1,5): error TS1212: Identifier expected. 'static' is a reserved word in strict mode.


==== tests/cases/conformance/pragma/alwaysStrict/file1.ts (1 errors) ====
// @ts-alwaysStrict
let private = {};
~~~~~~~
!!! error TS1212: Identifier expected. 'private' is a reserved word in strict mode.
==== tests/cases/conformance/pragma/alwaysStrict/file2.ts (1 errors) ====
// @ts-alwaysStrict true
let protected = {};
~~~~~~~~~
!!! error TS1212: Identifier expected. 'protected' is a reserved word in strict mode.
==== tests/cases/conformance/pragma/alwaysStrict/file3.ts (0 errors) ====
// @ts-alwaysStrict false
let public = {};
==== tests/cases/conformance/pragma/alwaysStrict/file4.ts (1 errors) ====
let static = {};
~~~~~~
!!! error TS1212: Identifier expected. 'static' is a reserved word in strict mode.

29 changes: 29 additions & 0 deletions tests/baselines/reference/alwaysStrictPragma2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//// [tests/cases/conformance/pragma/alwaysStrict/alwaysStrictPragma2.ts] ////

//// [file1.ts]
// @ts-alwaysStrict
let private = {};
//// [file2.ts]
// @ts-alwaysStrict true
let protected = {};
//// [file3.ts]
// @ts-alwaysStrict false
let public = {};
//// [file4.ts]
let static = {};


//// [file1.js]
"use strict";
// @ts-alwaysStrict
var private = {};
//// [file2.js]
"use strict";
// @ts-alwaysStrict true
var protected = {};
//// [file3.js]
// @ts-alwaysStrict false
var public = {};
//// [file4.js]
"use strict";
var static = {};
19 changes: 19 additions & 0 deletions tests/baselines/reference/alwaysStrictPragma2.symbols
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
=== tests/cases/conformance/pragma/alwaysStrict/file1.ts ===
// @ts-alwaysStrict
let private = {};
>private : Symbol(private, Decl(file1.ts, 1, 3))

=== tests/cases/conformance/pragma/alwaysStrict/file2.ts ===
// @ts-alwaysStrict true
let protected = {};
>protected : Symbol(protected, Decl(file2.ts, 1, 3))

=== tests/cases/conformance/pragma/alwaysStrict/file3.ts ===
// @ts-alwaysStrict false
let public = {};
>public : Symbol(public, Decl(file3.ts, 1, 3))

=== tests/cases/conformance/pragma/alwaysStrict/file4.ts ===
let static = {};
>static : Symbol(static, Decl(file4.ts, 0, 3))

23 changes: 23 additions & 0 deletions tests/baselines/reference/alwaysStrictPragma2.types
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
=== tests/cases/conformance/pragma/alwaysStrict/file1.ts ===
// @ts-alwaysStrict
let private = {};
>private : {}
>{} : {}

=== tests/cases/conformance/pragma/alwaysStrict/file2.ts ===
// @ts-alwaysStrict true
let protected = {};
>protected : {}
>{} : {}

=== tests/cases/conformance/pragma/alwaysStrict/file3.ts ===
// @ts-alwaysStrict false
let public = {};
>public : {}
>{} : {}

=== tests/cases/conformance/pragma/alwaysStrict/file4.ts ===
let static = {};
>static : {}
>{} : {}

Loading

0 comments on commit 1be381d

Please sign in to comment.