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

Remove stale diff reasons. #136

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 0 additions & 8 deletions src/harness/harnessIO.ts
Expand Up @@ -1050,10 +1050,6 @@ export namespace Compiler {
fullDiff += Diff.createTwoFilesPatch("TSC", "DTE", tscContent, dteContent, "declarations", "declarations");

Baseline.runBaseline(type + "/" + baselinePath.replace(/\.tsx?/, `.d.ts.map.diff`), fullDiff);

if (reason === undefined) {
throw new Error("The test is not equivalent between TSC and DTE. Please provide an isolatedDeclarationDiffReason/isolatedDeclarationFixedDiffReason setting in the test if this is intentional");
}
}

export function doDeclarationDiffBaseline(
Expand All @@ -1077,10 +1073,6 @@ export namespace Compiler {
fullDiff += Diff.createTwoFilesPatch("TSC", "DTE", tscContent, dteContent, "declarations", "declarations");

Baseline.runBaseline(type + "/" + baselinePath.replace(/\.tsx?/, `.d.ts.diff`), fullDiff);

if (reason === undefined) {
throw new Error("The test is not equivalent between TSC and DTE. Please provide an isolatedDeclarationDiffReason/isolatedDeclarationFixedDiffReason setting in the test if this is intentional");
}
}
function sourceContent(tsSources: readonly TestFile[]) {
let code = "";
Expand Down
59 changes: 35 additions & 24 deletions src/testRunner/compilerRunner.ts
Expand Up @@ -127,7 +127,8 @@ export class CompilerBaselineRunner extends RunnerBase {
});
it(`Correct dte emit for ${fileName}`, () => isolatedTest?.verifyDteOutput());
it(`Correct tsc emit for ${fileName}`, () => isolatedTest?.verifyTscOutput());
it(`Correct dte/tsc diff ${fileName}`, () => isolatedTest?.verifyDiff());
it(`Correct dte/tsc diff for ${fileName}`, () => isolatedTest?.verifyDiff());
it(`Correct diff reason for ${fileName}`, () => isolatedTest?.verifyDiffReason());

after(() => {
isolatedTest = undefined!;
Expand All @@ -145,12 +146,13 @@ export class CompilerBaselineRunner extends RunnerBase {
this.skip();
}
});
it(`Correct dte emit for ${fileName}`, () => fixedIsolatedTest?.verifyDteOutput());
it(`Correct tsc emit for ${fileName}`, () => fixedIsolatedTest?.verifyTscOutput());
it(`Correct dte/tsc diff ${fileName}`, () => fixedIsolatedTest?.verifyDiff());
it(`Correct dte map emit for ${fileName}`, () => fixedIsolatedTest?.verifyDteMapOutput());
it(`Correct tsc map emit for ${fileName}`, () => fixedIsolatedTest?.verifyTscMapOutput());
it(`Correct dte/tsc map diff ${fileName}`, () => fixedIsolatedTest?.verifyMapDiff());
it(`Correct dte emit for fixed ${fileName}`, () => fixedIsolatedTest?.verifyDteOutput());
it(`Correct tsc emit for fixed ${fileName}`, () => fixedIsolatedTest?.verifyTscOutput());
it(`Correct dte/tsc diff for fixed ${fileName}`, () => fixedIsolatedTest?.verifyDiff());
it(`Correct dte map emit for fixed ${fileName}`, () => fixedIsolatedTest?.verifyDteMapOutput());
it(`Correct tsc map emit for fixed ${fileName}`, () => fixedIsolatedTest?.verifyTscMapOutput());
it(`Correct dte/tsc map diff for fixed ${fileName}`, () => fixedIsolatedTest?.verifyMapDiff());
it(`Correct diff reason for fixed ${fileName}`, () => fixedIsolatedTest?.verifyDiffReason());

after(() => {
fixedIsolatedTest = undefined!;
Expand Down Expand Up @@ -480,13 +482,15 @@ class IsolatedDeclarationTest extends CompilerTestBase {
protected isDiagnosticEquivalent: boolean;
protected isOutputMapEquivalent: boolean;

static transformEnvironment(compilerEnvironment: CompilerTestEnvironment): CompilerTestEnvironment | undefined {
static transformEnvironment(compilerEnvironment: CompilerTestEnvironment, shouldNotExclude = !!compilerEnvironment.testCaseContent.settings.isolatedDeclarationDiffReason): CompilerTestEnvironment | undefined {
const options = compilerEnvironment.compilerOptions;
// Exclude tests some tests
// - those explicitly not opting into isolatedDeclarations
// - those that do not usually emit output anyway
if (options.isolatedDeclarations === false || options.noEmit || options.noTypesAndSymbols || !options.declaration) {
return undefined;
if (!shouldNotExclude) {
dragomirtitian marked this conversation as resolved.
Show resolved Hide resolved
// Exclude tests some tests
// - those explicitly not opting into isolatedDeclarations
// - those that do not usually emit output anyway
if (options.isolatedDeclarations === false || options.noEmit || options.noTypesAndSymbols || !options.declaration) {
return undefined;
}
}
const clonedOptions: ts.CompilerOptions & Compiler.HarnessOptions = ts.cloneCompilerOptions(compilerEnvironment.compilerOptions);
if (clonedOptions.isolatedDeclarations === undefined) {
Expand Down Expand Up @@ -658,11 +662,16 @@ class IsolatedDeclarationTest extends CompilerTestBase {
);
}

verifyDiffReason() {
if (this.isOutputMapEquivalent && this.isOutputEquivalent && this.isDiagnosticEquivalent) {
ts.Debug.assert(this.diffReason === undefined, "Should not have a diff reason if everything is equivalent");
}
else {
ts.Debug.assert(this.diffReason !== undefined, "Should have a reason if everything is not equivalent");
}
}
verifyDiff() {
if (this.isOutputEquivalent && this.isDiagnosticEquivalent) {
if (this.isOutputMapEquivalent) {
ts.Debug.assert(this.diffReason === undefined, "Should not have a diff reason if everything is equivalent");
}
return;
}
Compiler.doDeclarationDiffBaseline(
Expand Down Expand Up @@ -697,16 +706,18 @@ class IsolatedDeclarationTest extends CompilerTestBase {
}

class FixedIsolatedDeclarationTest extends IsolatedDeclarationTest {
static fixTestProject(compilerEnvironment: CompilerTestEnvironment): CompilerTestEnvironment | undefined {
// Exclude test that disable types and symbols (good proxy for very complex test)
if (compilerEnvironment.compilerOptions.noTypesAndSymbols) {
return undefined;
}
if (!compilerEnvironment.compilerOptions.declaration) {
return undefined;
static fixTestProject(compilerEnvironment: CompilerTestEnvironment, shouldNotExclude = !!compilerEnvironment.testCaseContent.settings.isolatedDeclarationFixedDiffReason): CompilerTestEnvironment | undefined {
if (!shouldNotExclude) {
// Exclude test that disable types and symbols (good proxy for very complex test)
if (compilerEnvironment.compilerOptions.noTypesAndSymbols) {
return undefined;
}
if (!compilerEnvironment.compilerOptions.declaration) {
return undefined;
}
}

const env = IsolatedDeclarationTest.transformEnvironment(compilerEnvironment);
const env = IsolatedDeclarationTest.transformEnvironment(compilerEnvironment, shouldNotExclude);
if (!env) {
return undefined;
}
Expand Down
1 change: 0 additions & 1 deletion tests/cases/compiler/arrayFind.ts
@@ -1,5 +1,4 @@
// @lib: es2015
// @isolatedDeclarationDiffReason: TS normalizes types

// test fix for #18112, type guard predicates should narrow returned element
function isNumber(x: any): x is number {
Expand Down
1 change: 0 additions & 1 deletion tests/cases/compiler/bigintIndex.ts
@@ -1,5 +1,4 @@
// @target: es2020
// @isolatedDeclarationDiffReason: Invalid computed property can only be detected by TSC

// @filename: a.ts
interface BigIntIndex<E> {
Expand Down
1 change: 0 additions & 1 deletion tests/cases/compiler/booleanFilterAnyArray.ts
@@ -1,4 +1,3 @@
// @isolatedDeclarationDiffReason: TS normalizes types
interface Bullean { }
interface BulleanConstructor {
new(v1?: any): Bullean;
Expand Down
1 change: 0 additions & 1 deletion tests/cases/compiler/capturedParametersInInitializers1.ts
@@ -1,5 +1,4 @@
// @target: es6
// @isolatedDeclarationDiffReason: TS normalizes types
// ok - usage is deferred
function foo1(y = class {c = x}, x = 1) {
new y().c;
Expand Down
1 change: 0 additions & 1 deletion tests/cases/compiler/circularObjectLiteralAccessors.ts
@@ -1,4 +1,3 @@
// @isolatedDeclarationDiffReason: TS merges accessors with the same type. DTE can only merge if one type is specified.
// @target: es5

// Repro from #6000
Expand Down
1 change: 0 additions & 1 deletion tests/cases/compiler/complicatedPrivacy.ts
@@ -1,5 +1,4 @@
// @target: es5
// @isolatedDeclarationDiffReason: Invalid computed property can only be detected by TSC

module m1 {
export module m2 {
Expand Down
1 change: 0 additions & 1 deletion tests/cases/compiler/constEnumErrors.ts
@@ -1,5 +1,4 @@
// @lib: es5
// @isolatedDeclarationDiffReason: TSC detects forward ref which is not allowed and so enum value is undefined, which is also the way we detect isolated declaration errors.
const enum E {
A
}
Expand Down
1 change: 0 additions & 1 deletion tests/cases/compiler/contextualTyping.ts
@@ -1,5 +1,4 @@
// @sourcemap: true
// @isolatedDeclarationDiffReason: TS normalizes types
// DEFAULT INTERFACES
interface IFoo {
n: number;
Expand Down
1 change: 0 additions & 1 deletion tests/cases/compiler/contextualTyping38.ts
@@ -1,2 +1 @@
// @isolatedDeclarationDiffReason: TS normalizes types
var foo = <{ (): number; }> function(a) { return a };
1 change: 0 additions & 1 deletion tests/cases/compiler/contextualTyping39.ts
@@ -1,2 +1 @@
// @isolatedDeclarationDiffReason: TS normalizes types
var foo = <{ (): number; }> function() { return "err"; };
Expand Up @@ -3,7 +3,6 @@
// @emitdecoratormetadata: true
// @target: es5
// @module: commonjs
// @isolatedDeclarationDiffReason: TSC removes import that is not used in a semantically valid way. DTE can't know about this.
// @filename: db.ts
export default class db {
public doSomething() {
Expand Down
1 change: 0 additions & 1 deletion tests/cases/compiler/decoratorsOnComputedProperties.ts
@@ -1,6 +1,5 @@
// @target: es6
// @experimentalDecorators: true
// @isolatedDeclarationDiffReason: Invalid computed property can only be detected by TSC
function x(o: object, k: PropertyKey) { }
let i = 0;
function foo(): string { return ++i + ""; }
Expand Down
@@ -1,4 +1,3 @@
// @isolatedDeclarationDiffReason: DTE preserves different duplicate identifier
const t1 = {
1: 1,
[1]: 0 // duplicate
Expand Down
@@ -1,4 +1,3 @@
// @isolatedDeclarationDiffReason: Computed property are not resolved
const n = 1;
const s = "s";
enum E1 { A = "ENUM_KEY" }
Expand Down
1 change: 0 additions & 1 deletion tests/cases/compiler/duplicateVarsAcrossFileBoundaries.ts
@@ -1,4 +1,3 @@
// @isolatedDeclarationDiffReason: TSC Resolves variable types across files.
// @Filename: duplicateVarsAcrossFileBoundaries_0.ts
var x = 3;
var y = "";
Expand Down
1 change: 0 additions & 1 deletion tests/cases/compiler/escapedIdentifiers.ts
@@ -1,6 +1,5 @@
// @allowUnusedLabels: true
// @allowUnreachableCode: true
// @isolatedDeclarationDiffReason: DTE resolves unicode escapes in some cases.

/*
0 .. \u0030
Expand Down
1 change: 0 additions & 1 deletion tests/cases/compiler/forwardRefInEnum.ts
@@ -1,4 +1,3 @@
// @isolatedDeclarationDiffReason: TSC detects forward ref which is not allowed and so enum value is undefined, which is also the way we detect isolated declaration errors.
enum E1 {
// illegal case
// forward reference to the element of the same enum
Expand Down
1 change: 0 additions & 1 deletion tests/cases/compiler/gettersAndSettersErrors.ts
@@ -1,4 +1,3 @@
// @isolatedDeclarationDiffReason: Duplicate identifiers in class result in different types
class C {
public get Foo() { return "foo";} // ok
public set Foo(foo:string) {} // ok
Expand Down
1 change: 0 additions & 1 deletion tests/cases/compiler/inKeywordAndIntersection.ts
@@ -1,5 +1,4 @@
// @strict: true
// @isolatedDeclarationDiffReason: TS normalizes types

class A { a = 0 }
class B { b = 0 }
Expand Down
@@ -1,4 +1,3 @@
// @isolatedDeclarationDiffReason: Invalid computed property can only be detected by TSC
interface I {
// Used to be indexer, now it is a computed property
[x]: string;
Expand Down
1 change: 0 additions & 1 deletion tests/cases/compiler/indexWithoutParamType2.ts
@@ -1,4 +1,3 @@
// @isolatedDeclarationDiffReason: Invalid computed property can only be detected by TSC
class C {
// Used to be indexer, now it is a computed property
[x]: string
Expand Down
1 change: 0 additions & 1 deletion tests/cases/compiler/intTypeCheck.ts
@@ -1,4 +1,3 @@
// @isolatedDeclarationDiffReason: Invalid computed property can only be detected by TSC
interface i1 {
//Property Signatures
p;
Expand Down
@@ -1,5 +1,4 @@
// @isolatedDeclarationDiffReason: Invalid computed property can only be detected by TSC
// @lib: es5
// @lib: es5
// @target: es6

// All will be error from using ES6 features but only include ES5 library
Expand Down
@@ -1,5 +1,4 @@
// moduleSuffixes has one entry and there's a matching package with TS files.
// @isolatedDeclarationDiffReason: checker.typeToTypeNode deliberately fails on types that originate from node_modules
// @fullEmitPaths: true
// @filename: /tsconfig.json
{
Expand Down
1 change: 0 additions & 1 deletion tests/cases/compiler/objectLiteralEnumPropertyNames.ts
@@ -1,4 +1,3 @@
// @isolatedDeclarationDiffReason: Computed property are not resolved
// Fixes #16887
enum Strs {
A = 'a',
Expand Down
1 change: 0 additions & 1 deletion tests/cases/compiler/overloadsWithComputedNames.ts
@@ -1,4 +1,3 @@
// @isolatedDeclarationDiffReason: Invalid computed property can only be detected by TSC
// https://github.com/microsoft/TypeScript/issues/52329
class Person {
["B"](a: number): string;
Expand Down
1 change: 0 additions & 1 deletion tests/cases/compiler/parseInvalidNonNullableTypes.ts
@@ -1,5 +1,4 @@
// @strict: true
// @isolatedDeclarationDiffReason: Syntactically invalid.

function f1(a: string): a is string! {
return true;
Expand Down
1 change: 0 additions & 1 deletion tests/cases/compiler/parseInvalidNullableTypes.ts
@@ -1,5 +1,4 @@
// @strict: true
// @isolatedDeclarationDiffReason: Syntactically invalid.

function f1(a: string): a is ?string {
return true;
Expand Down
1 change: 0 additions & 1 deletion tests/cases/compiler/parseTypes.ts
@@ -1,4 +1,3 @@
// @isolatedDeclarationDiffReason: TS normalizes types

var x = <() => number>null;
var y = <{(): number; }>null;
Expand Down
1 change: 0 additions & 1 deletion tests/cases/compiler/propertyAssignment.ts
@@ -1,4 +1,3 @@
// @isolatedDeclarationDiffReason: Syntactically invalid.


var foo1: { new ():any; }
Expand Down
1 change: 0 additions & 1 deletion tests/cases/compiler/typeUsedAsTypeLiteralIndex.ts
@@ -1,5 +1,4 @@
// @target: esnext
// @isolatedDeclarationDiffReason: Invalid computed property can only be detected by TSC

type K = number | string;
type T = {
Expand Down
1 change: 0 additions & 1 deletion tests/cases/conformance/Symbols/ES5SymbolProperty1.ts
@@ -1,5 +1,4 @@
//@target: ES5
//@isolatedDeclarationDiffReason: Invalid computed property can only be detected by TSC
interface SymbolConstructor {
foo: string;
}
Expand Down
1 change: 0 additions & 1 deletion tests/cases/conformance/Symbols/ES5SymbolProperty2.ts
@@ -1,4 +1,3 @@
// @isolatedDeclarationDiffReason: Invalid computed property can only be detected by TSC
//@target: ES5
module M {
var Symbol: any;
Expand Down
1 change: 0 additions & 1 deletion tests/cases/conformance/Symbols/ES5SymbolProperty3.ts
@@ -1,4 +1,3 @@
// @isolatedDeclarationDiffReason: Invalid computed property can only be detected by TSC
//@target: ES5
var Symbol: any;

Expand Down
1 change: 0 additions & 1 deletion tests/cases/conformance/Symbols/ES5SymbolProperty4.ts
@@ -1,4 +1,3 @@
// @isolatedDeclarationDiffReason: Invalid computed property can only be detected by TSC
//@target: ES5
var Symbol: { iterator: string };

Expand Down
1 change: 0 additions & 1 deletion tests/cases/conformance/Symbols/ES5SymbolProperty5.ts
@@ -1,4 +1,3 @@
// @isolatedDeclarationDiffReason: Invalid computed property can only be detected by TSC
//@target: ES5
var Symbol: { iterator: symbol };

Expand Down
1 change: 0 additions & 1 deletion tests/cases/conformance/Symbols/ES5SymbolProperty6.ts
@@ -1,4 +1,3 @@
// @isolatedDeclarationDiffReason: Invalid computed property can only be detected by TSC
//@target: ES5
class C {
[Symbol.iterator]() { }
Expand Down
1 change: 0 additions & 1 deletion tests/cases/conformance/Symbols/ES5SymbolProperty7.ts
@@ -1,4 +1,3 @@
// @isolatedDeclarationDiffReason: Invalid computed property can only be detected by TSC
//@target: ES5
var Symbol: { iterator: any };

Expand Down
@@ -1,4 +1,3 @@
// @target: es2017
// @noEmitHelpers: true
// @isolatedDeclarationDiffReason: Invalid computed property can only be detected by TSC
var v = { [await]: foo }
@@ -1,5 +1,4 @@
// @target: ES5
// @lib: es5,es2015.promise
// @noEmitHelpers: true
// @isolatedDeclarationDiffReason: Invalid computed property can only be detected by TSC
var v = { [await]: foo }
@@ -1,4 +1,3 @@
// @target: ES6
// @noEmitHelpers: true
// @isolatedDeclarationDiffReason: Invalid computed property can only be detected by TSC
var v = { [await]: foo }
@@ -1,4 +1,3 @@
// @isolatedDeclarationDiffReason: TS normalizes types
// @target: ES5

var x: { foo: string; }
Expand Down
@@ -1,4 +1,3 @@
// @isolatedDeclarationDiffReason: TS normalizes types
// @target: ES5
var x: { foo: string; }
var y: { foo: string; bar: string; }
Expand Down
@@ -1,4 +1,3 @@
// @isolatedDeclarationDiffReason: TS normalizes types
// @target: ES5

var x: { foo: string; }
Expand Down
@@ -1,4 +1,3 @@
// @isolatedDeclarationDiffReason: TS normalizes types
var x: { foo: string; }
var y: { foo: string; bar: string; }

Expand Down
@@ -1,6 +1,5 @@
// @target: es5
// @useDefineForClassFields: true,false
// @isolatedDeclarationDiffReason: Invalid computed property can only be detected by TSC

const FunctionPropertyNames = {
name: 'name',
Expand Down
1 change: 0 additions & 1 deletion tests/cases/conformance/es6/Symbols/symbolProperty1.ts
@@ -1,5 +1,4 @@
//@target: ES6
//@isolatedDeclarationDiffReason: Invalid computed property can only be detected by TSC
var s: symbol;
var x = {
[s]: 0,
Expand Down
1 change: 0 additions & 1 deletion tests/cases/conformance/es6/Symbols/symbolProperty2.ts
@@ -1,5 +1,4 @@
//@target: ES6
//@isolatedDeclarationDiffReason: Invalid computed property can only be detected by TSC
var s = Symbol();
var x = {
[s]: 0,
Expand Down
1 change: 0 additions & 1 deletion tests/cases/conformance/es6/Symbols/symbolProperty3.ts
@@ -1,5 +1,4 @@
//@target: ES6
//@isolatedDeclarationDiffReason: Invalid computed property can only be detected by TSC
var s = Symbol;
var x = {
[s]: 0,
Expand Down
1 change: 0 additions & 1 deletion tests/cases/conformance/es6/Symbols/symbolProperty52.ts
@@ -1,5 +1,4 @@
//@target: ES6
//@isolatedDeclarationDiffReason: Invalid computed property can only be detected by TSC
var obj = {
[Symbol.nonsense]: 0
};
Expand Down