Merge branch 'master' into named_modules

This commit is contained in:
Vladimir Matveev 2015-06-04 21:38:25 -07:00
commit 6269598c52
31 changed files with 158 additions and 123 deletions

View file

@ -507,7 +507,7 @@ function cleanTestDirs() {
// used to pass data from jake command line directly to run.js // used to pass data from jake command line directly to run.js
function writeTestConfigFile(tests, testConfigFile) { function writeTestConfigFile(tests, testConfigFile) {
console.log('Running test(s): ' + tests); console.log('Running test(s): ' + tests);
var testConfigContents = '{\n' + '\ttest: [\'' + tests + '\']\n}'; var testConfigContents = JSON.stringify({ test: [tests]});
fs.writeFileSync('test.config', testConfigContents); fs.writeFileSync('test.config', testConfigContents);
} }
@ -690,4 +690,4 @@ task('tsc-instrumented', [loggedIOJsPath, instrumenterJsPath, tscFile], function
complete(); complete();
}); });
ex.run(); ex.run();
}, { async: true }); }, { async: true });

View file

@ -11368,6 +11368,10 @@ module ts {
function checkSourceFileWorker(node: SourceFile) { function checkSourceFileWorker(node: SourceFile) {
let links = getNodeLinks(node); let links = getNodeLinks(node);
if (!(links.flags & NodeCheckFlags.TypeChecked)) { if (!(links.flags & NodeCheckFlags.TypeChecked)) {
if (node.isDefaultLib && compilerOptions.skipDefaultLibCheck) {
return;
}
// Grammar checking // Grammar checking
checkGrammarSourceFile(node); checkGrammarSourceFile(node);

View file

@ -103,6 +103,10 @@ module ts {
name: "noResolve", name: "noResolve",
type: "boolean", type: "boolean",
}, },
{
name: "skipDefaultLibCheck",
type: "boolean",
},
{ {
name: "out", name: "out",
type: "string", type: "string",

View file

@ -21,7 +21,7 @@ module ts {
get, get,
set, set,
contains, contains,
delete: deleteItem, remove,
forEachValue: forEachValueInMap forEachValue: forEachValueInMap
} }
@ -37,7 +37,7 @@ module ts {
return hasProperty(files, normalizeKey(fileName)); return hasProperty(files, normalizeKey(fileName));
} }
function deleteItem (fileName: string) { function remove (fileName: string) {
let key = normalizeKey(fileName); let key = normalizeKey(fileName);
delete files[key]; delete files[key];
} }

View file

@ -4503,7 +4503,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
emitDeclarationName(node); emitDeclarationName(node);
write(`", `); write(`", `);
emitDeclarationName(node); emitDeclarationName(node);
write(")"); write(");");
} }
emitExportMemberAssignments(node.name); emitExportMemberAssignments(node.name);
} }
@ -4624,7 +4624,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
emitDeclarationName(node); emitDeclarationName(node);
write(`", `); write(`", `);
emitDeclarationName(node); emitDeclarationName(node);
write(")"); write(");");
} }
emitExportMemberAssignments(<Identifier>node.name); emitExportMemberAssignments(<Identifier>node.name);
} }

View file

@ -144,7 +144,7 @@ module ts {
let program: Program; let program: Program;
let files: SourceFile[] = []; let files: SourceFile[] = [];
let diagnostics = createDiagnosticCollection(); let diagnostics = createDiagnosticCollection();
let seenNoDefaultLib = options.noLib; let skipDefaultLib = options.noLib;
let commonSourceDirectory: string; let commonSourceDirectory: string;
let diagnosticsProducingTypeChecker: TypeChecker; let diagnosticsProducingTypeChecker: TypeChecker;
let noDiagnosticsTypeChecker: TypeChecker; let noDiagnosticsTypeChecker: TypeChecker;
@ -154,9 +154,9 @@ module ts {
host = host || createCompilerHost(options); host = host || createCompilerHost(options);
let filesByName = createFileMap<SourceFile>(host.getCanonicalFileName); let filesByName = createFileMap<SourceFile>(host.getCanonicalFileName);
forEach(rootNames, name => processRootFile(name, false)); forEach(rootNames, name => processRootFile(name, /*isDefaultLib:*/ false));
if (!seenNoDefaultLib) { if (!skipDefaultLib) {
processRootFile(host.getDefaultLibFileName(options), true); processRootFile(host.getDefaultLibFileName(options), /*isDefaultLib:*/ true);
} }
verifyCompilerOptions(); verifyCompilerOptions();
@ -382,7 +382,7 @@ module ts {
}); });
filesByName.set(canonicalName, file); filesByName.set(canonicalName, file);
if (file) { if (file) {
seenNoDefaultLib = seenNoDefaultLib || file.hasNoDefaultLib; skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib;
// Set the source file for normalized absolute path // Set the source file for normalized absolute path
filesByName.set(canonicalAbsolutePath, file); filesByName.set(canonicalAbsolutePath, file);
@ -393,6 +393,7 @@ module ts {
processImportedModules(file, basePath); processImportedModules(file, basePath);
} }
if (isDefaultLib) { if (isDefaultLib) {
file.isDefaultLib = true;
files.unshift(file); files.unshift(file);
} }
else { else {

View file

@ -7,7 +7,7 @@ module ts {
get(fileName: string): T; get(fileName: string): T;
set(fileName: string, value: T): void; set(fileName: string, value: T): void;
contains(fileName: string): boolean; contains(fileName: string): boolean;
delete(fileName: string): void; remove(fileName: string): void;
forEachValue(f: (v: T) => void): void; forEachValue(f: (v: T) => void): void;
} }
@ -1151,7 +1151,8 @@ module ts {
// The first node that causes this file to be an external module // The first node that causes this file to be an external module
/* @internal */ externalModuleIndicator: Node; /* @internal */ externalModuleIndicator: Node;
/* @internal */ isDefaultLib: boolean;
/* @internal */ identifiers: Map<string>; /* @internal */ identifiers: Map<string>;
/* @internal */ nodeCount: number; /* @internal */ nodeCount: number;
/* @internal */ identifierCount: number; /* @internal */ identifierCount: number;
@ -1832,6 +1833,7 @@ module ts {
experimentalDecorators?: boolean; experimentalDecorators?: boolean;
emitDecoratorMetadata?: boolean; emitDecoratorMetadata?: boolean;
/* @internal */ stripInternal?: boolean; /* @internal */ stripInternal?: boolean;
/* @internal */ skipDefaultLibCheck?: boolean;
[option: string]: string | number | boolean; [option: string]: string | number | boolean;
} }

View file

@ -808,9 +808,15 @@ module Harness {
} }
} }
export function createSourceFileAndAssertInvariants(fileName: string, sourceText: string, languageVersion: ts.ScriptTarget, assertInvariants = true) { export function createSourceFileAndAssertInvariants(
fileName: string,
sourceText: string,
languageVersion: ts.ScriptTarget,
assertInvariants: boolean) {
// Only set the parent nodes if we're asserting invariants. We don't need them otherwise. // Only set the parent nodes if we're asserting invariants. We don't need them otherwise.
var result = ts.createSourceFile(fileName, sourceText, languageVersion, /*setParentNodes:*/ assertInvariants); var result = ts.createSourceFile(fileName, sourceText, languageVersion, /*setParentNodes:*/ assertInvariants);
if (assertInvariants) { if (assertInvariants) {
Utils.assertInvariants(result, /*parent:*/ undefined); Utils.assertInvariants(result, /*parent:*/ undefined);
} }
@ -821,8 +827,8 @@ module Harness {
const lineFeed = "\n"; const lineFeed = "\n";
export var defaultLibFileName = 'lib.d.ts'; export var defaultLibFileName = 'lib.d.ts';
export var defaultLibSourceFile = createSourceFileAndAssertInvariants(defaultLibFileName, IO.readFile(libFolder + 'lib.core.d.ts'), /*languageVersion*/ ts.ScriptTarget.Latest); export var defaultLibSourceFile = createSourceFileAndAssertInvariants(defaultLibFileName, IO.readFile(libFolder + 'lib.core.d.ts'), /*languageVersion*/ ts.ScriptTarget.Latest, /*assertInvariants:*/ true);
export var defaultES6LibSourceFile = createSourceFileAndAssertInvariants(defaultLibFileName, IO.readFile(libFolder + 'lib.core.es6.d.ts'), /*languageVersion*/ ts.ScriptTarget.Latest); export var defaultES6LibSourceFile = createSourceFileAndAssertInvariants(defaultLibFileName, IO.readFile(libFolder + 'lib.core.es6.d.ts'), /*languageVersion*/ ts.ScriptTarget.Latest, /*assertInvariants:*/ true);
// Cache these between executions so we don't have to re-parse them for every test // Cache these between executions so we don't have to re-parse them for every test
export var fourslashFileName = 'fourslash.ts'; export var fourslashFileName = 'fourslash.ts';
@ -832,13 +838,14 @@ module Harness {
return ts.sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); return ts.sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase();
} }
export function createCompilerHost(inputFiles: { unitName: string; content: string; }[], export function createCompilerHost(
writeFile: (fn: string, contents: string, writeByteOrderMark: boolean) => void, inputFiles: { unitName: string; content: string; }[],
scriptTarget: ts.ScriptTarget, writeFile: (fn: string, contents: string, writeByteOrderMark: boolean) => void,
useCaseSensitiveFileNames: boolean, scriptTarget: ts.ScriptTarget,
// the currentDirectory is needed for rwcRunner to passed in specified current directory to compiler host useCaseSensitiveFileNames: boolean,
currentDirectory?: string, // the currentDirectory is needed for rwcRunner to passed in specified current directory to compiler host
newLineKind?: ts.NewLineKind): ts.CompilerHost { currentDirectory?: string,
newLineKind?: ts.NewLineKind): ts.CompilerHost {
// Local get canonical file name function, that depends on passed in parameter for useCaseSensitiveFileNames // Local get canonical file name function, that depends on passed in parameter for useCaseSensitiveFileNames
function getCanonicalFileName(fileName: string): string { function getCanonicalFileName(fileName: string): string {
@ -852,7 +859,7 @@ module Harness {
function register(file: { unitName: string; content: string; }) { function register(file: { unitName: string; content: string; }) {
if (file.content !== undefined) { if (file.content !== undefined) {
var fileName = ts.normalizePath(file.unitName); var fileName = ts.normalizePath(file.unitName);
filemap[getCanonicalFileName(fileName)] = createSourceFileAndAssertInvariants(fileName, file.content, scriptTarget); filemap[getCanonicalFileName(fileName)] = createSourceFileAndAssertInvariants(fileName, file.content, scriptTarget, /*assertInvariants:*/ true);
} }
}; };
inputFiles.forEach(register); inputFiles.forEach(register);
@ -875,7 +882,7 @@ module Harness {
} }
else if (fn === fourslashFileName) { else if (fn === fourslashFileName) {
var tsFn = 'tests/cases/fourslash/' + fourslashFileName; var tsFn = 'tests/cases/fourslash/' + fourslashFileName;
fourslashSourceFile = fourslashSourceFile || createSourceFileAndAssertInvariants(tsFn, Harness.IO.readFile(tsFn), scriptTarget); fourslashSourceFile = fourslashSourceFile || createSourceFileAndAssertInvariants(tsFn, Harness.IO.readFile(tsFn), scriptTarget, /*assertInvariants:*/ true);
return fourslashSourceFile; return fourslashSourceFile;
} }
else { else {
@ -964,7 +971,8 @@ module Harness {
settingsCallback(null); settingsCallback(null);
} }
var newLine = '\r\n'; let newLine = '\r\n';
options.skipDefaultLibCheck = true;
// Files from built\local that are requested by test "@includeBuiltFiles" to be in the context. // Files from built\local that are requested by test "@includeBuiltFiles" to be in the context.
// Treat them as library files, so include them in build, but not in baselines. // Treat them as library files, so include them in build, but not in baselines.
@ -1050,6 +1058,10 @@ module Harness {
options.outDir = setting.value; options.outDir = setting.value;
break; break;
case 'skipdefaultlibcheck':
options.skipDefaultLibCheck = setting.value === "true";
break;
case 'sourceroot': case 'sourceroot':
options.sourceRoot = setting.value; options.sourceRoot = setting.value;
break; break;
@ -1134,9 +1146,11 @@ module Harness {
var fileOutputs: GeneratedFile[] = []; var fileOutputs: GeneratedFile[] = [];
var programFiles = inputFiles.concat(includeBuiltFiles).map(file => file.unitName); var programFiles = inputFiles.concat(includeBuiltFiles).map(file => file.unitName);
var program = ts.createProgram(programFiles, options, createCompilerHost(inputFiles.concat(includeBuiltFiles).concat(otherFiles), var compilerHost = createCompilerHost(
inputFiles.concat(includeBuiltFiles).concat(otherFiles),
(fn, contents, writeByteOrderMark) => fileOutputs.push({ fileName: fn, code: contents, writeByteOrderMark: writeByteOrderMark }), (fn, contents, writeByteOrderMark) => fileOutputs.push({ fileName: fn, code: contents, writeByteOrderMark: writeByteOrderMark }),
options.target, useCaseSensitiveFileNames, currentDirectory, options.newLine)); options.target, useCaseSensitiveFileNames, currentDirectory, options.newLine);
var program = ts.createProgram(programFiles, options, compilerHost);
var emitResult = program.emit(); var emitResult = program.emit();
@ -1480,7 +1494,8 @@ module Harness {
"errortruncation", "usecasesensitivefilenames", "preserveconstenums", "errortruncation", "usecasesensitivefilenames", "preserveconstenums",
"includebuiltfile", "suppressimplicitanyindexerrors", "stripinternal", "includebuiltfile", "suppressimplicitanyindexerrors", "stripinternal",
"isolatedmodules", "inlinesourcemap", "maproot", "sourceroot", "isolatedmodules", "inlinesourcemap", "maproot", "sourceroot",
"inlinesources", "emitdecoratormetadata", "experimentaldecorators"]; "inlinesources", "emitdecoratormetadata", "experimentaldecorators",
"skipdefaultlibcheck"];
function extractCompilerSettings(content: string): CompilerSetting[] { function extractCompilerSettings(content: string): CompilerSetting[] {

View file

@ -174,7 +174,7 @@ class ProjectRunner extends RunnerBase {
else { else {
var text = getSourceFileText(fileName); var text = getSourceFileText(fileName);
if (text !== undefined) { if (text !== undefined) {
sourceFile = Harness.Compiler.createSourceFileAndAssertInvariants(fileName, text, languageVersion); sourceFile = Harness.Compiler.createSourceFileAndAssertInvariants(fileName, text, languageVersion, /*assertInvariants:*/ true);
} }
} }

View file

@ -38,41 +38,45 @@ var testConfigFile =
(Harness.IO.fileExists(testconfig) ? Harness.IO.readFile(testconfig) : ''); (Harness.IO.fileExists(testconfig) ? Harness.IO.readFile(testconfig) : '');
if (testConfigFile !== '') { if (testConfigFile !== '') {
// TODO: not sure why this is crashing mocha var testConfig = JSON.parse(testConfigFile);
//var testConfig = JSON.parse(testConfigRaw);
var testConfig = testConfigFile.match(/test:\s\['(.*)'\]/); if (testConfig.test && testConfig.test.length > 0) {
var options = testConfig ? [testConfig[1]] : []; for (let option of testConfig.test) {
for (var i = 0; i < options.length; i++) { if (!option) {
switch (options[i]) { continue;
case 'compiler': }
runners.push(new CompilerBaselineRunner(CompilerTestType.Conformance)); ts.sys.write("Option: " + option + "\r\n");
runners.push(new CompilerBaselineRunner(CompilerTestType.Regressions)); switch (option) {
runners.push(new ProjectRunner()); case 'compiler':
break; runners.push(new CompilerBaselineRunner(CompilerTestType.Conformance));
case 'conformance': runners.push(new CompilerBaselineRunner(CompilerTestType.Regressions));
runners.push(new CompilerBaselineRunner(CompilerTestType.Conformance)); runners.push(new ProjectRunner());
break; break;
case 'project': case 'conformance':
runners.push(new ProjectRunner()); runners.push(new CompilerBaselineRunner(CompilerTestType.Conformance));
break; break;
case 'fourslash': case 'project':
runners.push(new FourSlashRunner(FourSlashTestType.Native)); runners.push(new ProjectRunner());
break; break;
case 'fourslash-shims': case 'fourslash':
runners.push(new FourSlashRunner(FourSlashTestType.Shims)); runners.push(new FourSlashRunner(FourSlashTestType.Native));
break; break;
case 'fourslash-server': case 'fourslash-shims':
runners.push(new FourSlashRunner(FourSlashTestType.Server)); runners.push(new FourSlashRunner(FourSlashTestType.Shims));
break; break;
case 'fourslash-generated': case 'fourslash-server':
runners.push(new GeneratedFourslashRunner(FourSlashTestType.Native)); runners.push(new FourSlashRunner(FourSlashTestType.Server));
break; break;
case 'rwc': case 'fourslash-generated':
runners.push(new RWCRunner()); runners.push(new GeneratedFourslashRunner(FourSlashTestType.Native));
break; break;
case 'test262': case 'rwc':
runners.push(new Test262BaselineRunner()); runners.push(new RWCRunner());
break; break;
case 'test262':
runners.push(new Test262BaselineRunner());
break;
}
} }
} }
} }

View file

@ -743,6 +743,7 @@ module ts {
public parseDiagnostics: Diagnostic[]; public parseDiagnostics: Diagnostic[];
public bindDiagnostics: Diagnostic[]; public bindDiagnostics: Diagnostic[];
public isDefaultLib: boolean;
public hasNoDefaultLib: boolean; public hasNoDefaultLib: boolean;
public externalModuleIndicator: Node; // The first node that causes this file to be an external module public externalModuleIndicator: Node; // The first node that causes this file to be an external module
public nodeCount: number; public nodeCount: number;
@ -1993,7 +1994,7 @@ module ts {
Debug.assert(entry.languageServiceRefCount >= 0); Debug.assert(entry.languageServiceRefCount >= 0);
if (entry.languageServiceRefCount === 0) { if (entry.languageServiceRefCount === 0) {
bucket.delete(fileName); bucket.remove(fileName);
} }
} }

View file

@ -35,14 +35,14 @@ function f1(x: Color | string) {
} }
function f2(x: Color | string | string[]) { function f2(x: Color | string | string[]) {
>f2 : (x: string | string[] | Color) => void >f2 : (x: string | Color | string[]) => void
>x : string | string[] | Color >x : string | Color | string[]
>Color : Color >Color : Color
if (typeof x === "object") { if (typeof x === "object") {
>typeof x === "object" : boolean >typeof x === "object" : boolean
>typeof x : string >typeof x : string
>x : string | string[] | Color >x : string | Color | string[]
>"object" : string >"object" : string
var y = x; var y = x;
@ -55,7 +55,7 @@ function f2(x: Color | string | string[]) {
if (typeof x === "number") { if (typeof x === "number") {
>typeof x === "number" : boolean >typeof x === "number" : boolean
>typeof x : string >typeof x : string
>x : string | string[] | Color >x : string | Color | string[]
>"number" : string >"number" : string
var z = x; var z = x;
@ -77,7 +77,7 @@ function f2(x: Color | string | string[]) {
if (typeof x === "string") { if (typeof x === "string") {
>typeof x === "string" : boolean >typeof x === "string" : boolean
>typeof x : string >typeof x : string
>x : string | string[] | Color >x : string | Color | string[]
>"string" : string >"string" : string
var a = x; var a = x;
@ -89,11 +89,11 @@ function f2(x: Color | string | string[]) {
} }
else { else {
var b = x; var b = x;
>b : string[] | Color >b : Color | string[]
>x : string[] | Color >x : Color | string[]
var b: Color | string[]; var b: Color | string[];
>b : string[] | Color >b : Color | string[]
>Color : Color >Color : Color
} }
} }

View file

@ -2,8 +2,8 @@
// Empty array literal with no contextual type has type Undefined[] // Empty array literal with no contextual type has type Undefined[]
var arr1= [[], [1], ['']]; var arr1= [[], [1], ['']];
>arr1 : (string[] | number[])[] >arr1 : (number[] | string[])[]
>[[], [1], ['']] : (string[] | number[])[] >[[], [1], ['']] : (number[] | string[])[]
>[] : undefined[] >[] : undefined[]
>[1] : number[] >[1] : number[]
>1 : number >1 : number
@ -11,8 +11,8 @@ var arr1= [[], [1], ['']];
>'' : string >'' : string
var arr2 = [[null], [1], ['']]; var arr2 = [[null], [1], ['']];
>arr2 : (string[] | number[])[] >arr2 : (number[] | string[])[]
>[[null], [1], ['']] : (string[] | number[])[] >[[null], [1], ['']] : (number[] | string[])[]
>[null] : null[] >[null] : null[]
>null : null >null : null
>[1] : number[] >[1] : number[]

View file

@ -8,8 +8,8 @@ tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(17,5): error
Type '() => string | number | boolean' is not assignable to type '() => number'. Type '() => string | number | boolean' is not assignable to type '() => number'.
Type 'string | number | boolean' is not assignable to type 'number'. Type 'string | number | boolean' is not assignable to type 'number'.
Type 'string' is not assignable to type 'number'. Type 'string' is not assignable to type 'number'.
tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(32,5): error TS2322: Type '(string[] | number[])[]' is not assignable to type 'tup'. tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(32,5): error TS2322: Type '(number[] | string[])[]' is not assignable to type 'tup'.
Property '0' is missing in type '(string[] | number[])[]'. Property '0' is missing in type '(number[] | string[])[]'.
tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(33,5): error TS2322: Type 'number[]' is not assignable to type '[number, number, number]'. tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(33,5): error TS2322: Type 'number[]' is not assignable to type '[number, number, number]'.
Property '0' is missing in type 'number[]'. Property '0' is missing in type 'number[]'.
tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(34,5): error TS2322: Type '(string | number)[]' is not assignable to type 'myArray'. tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(34,5): error TS2322: Type '(string | number)[]' is not assignable to type 'myArray'.
@ -68,8 +68,8 @@ tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(34,5): error
interface myArray2 extends Array<Number|String> { } interface myArray2 extends Array<Number|String> { }
var c0: tup = [...temp2]; // Error var c0: tup = [...temp2]; // Error
~~ ~~
!!! error TS2322: Type '(string[] | number[])[]' is not assignable to type 'tup'. !!! error TS2322: Type '(number[] | string[])[]' is not assignable to type 'tup'.
!!! error TS2322: Property '0' is missing in type '(string[] | number[])[]'. !!! error TS2322: Property '0' is missing in type '(number[] | string[])[]'.
var c1: [number, number, number] = [...temp1]; // Error cannot assign number[] to [number, number, number] var c1: [number, number, number] = [...temp1]; // Error cannot assign number[] to [number, number, number]
~~ ~~
!!! error TS2322: Type 'number[]' is not assignable to type '[number, number, number]'. !!! error TS2322: Type 'number[]' is not assignable to type '[number, number, number]'.

View file

@ -17,9 +17,9 @@ declare function foo<T>(obj: I<T>): T
>T : T >T : T
foo({ foo({
>foo({ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]}) : string | number | boolean | number[] | (() => void) >foo({ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]}) : string | number | boolean | (() => void) | number[]
>foo : <T>(obj: I<T>) => T >foo : <T>(obj: I<T>) => T
>{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: string]: string | number | boolean | number[] | (() => void); 0: () => void; p: string; } >{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: string]: string | number | boolean | (() => void) | number[]; 0: () => void; p: string; }
p: "", p: "",
>p : string >p : string

View file

@ -17,9 +17,9 @@ declare function foo<T>(obj: I<T>): T
>T : T >T : T
foo({ foo({
>foo({ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]}) : string | number | boolean | number[] | (() => void) >foo({ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]}) : string | number | boolean | (() => void) | number[]
>foo : <T>(obj: I<T>) => T >foo : <T>(obj: I<T>) => T
>{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: string]: string | number | boolean | number[] | (() => void); 0: () => void; p: string; } >{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: string]: string | number | boolean | (() => void) | number[]; 0: () => void; p: string; }
p: "", p: "",
>p : string >p : string

View file

@ -17,9 +17,9 @@ declare function foo<T>(obj: I<T>): T
>T : T >T : T
foo({ foo({
>foo({ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]}) : number | number[] | (() => void) >foo({ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]}) : number | (() => void) | number[]
>foo : <T>(obj: I<T>) => T >foo : <T>(obj: I<T>) => T
>{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: number]: number | number[] | (() => void); 0: () => void; p: string; } >{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: number]: number | (() => void) | number[]; 0: () => void; p: string; }
p: "", p: "",
>p : string >p : string

View file

@ -17,9 +17,9 @@ declare function foo<T>(obj: I<T>): T
>T : T >T : T
foo({ foo({
>foo({ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]}) : number | number[] | (() => void) >foo({ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]}) : number | (() => void) | number[]
>foo : <T>(obj: I<T>) => T >foo : <T>(obj: I<T>) => T
>{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: number]: number | number[] | (() => void); 0: () => void; p: string; } >{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: number]: number | (() => void) | number[]; 0: () => void; p: string; }
p: "", p: "",
>p : string >p : string

View file

@ -120,35 +120,35 @@ var b = baz(b, b, g); // Should be number | string
>g : <T>(x: T, y: T) => T >g : <T>(x: T, y: T) => T
var d: number[] | string[]; var d: number[] | string[];
>d : string[] | number[] >d : number[] | string[]
var d = foo(h); // Should be number[] | string[] var d = foo(h); // Should be number[] | string[]
>d : string[] | number[] >d : number[] | string[]
>foo(h) : string[] | number[] >foo(h) : number[] | string[]
>foo : <T>(cb: (x: number, y: string) => T) => T >foo : <T>(cb: (x: number, y: string) => T) => T
>h : <T, U>(x: T, y: U) => T[] | U[] >h : <T, U>(x: T, y: U) => T[] | U[]
var d = bar(1, "one", h); // Should be number[] | string[] var d = bar(1, "one", h); // Should be number[] | string[]
>d : string[] | number[] >d : number[] | string[]
>bar(1, "one", h) : string[] | number[] >bar(1, "one", h) : number[] | string[]
>bar : <T, U, V>(x: T, y: U, cb: (x: T, y: U) => V) => V >bar : <T, U, V>(x: T, y: U, cb: (x: T, y: U) => V) => V
>1 : number >1 : number
>"one" : string >"one" : string
>h : <T, U>(x: T, y: U) => T[] | U[] >h : <T, U>(x: T, y: U) => T[] | U[]
var d = bar("one", 1, h); // Should be number[] | string[] var d = bar("one", 1, h); // Should be number[] | string[]
>d : string[] | number[] >d : number[] | string[]
>bar("one", 1, h) : string[] | number[] >bar("one", 1, h) : number[] | string[]
>bar : <T, U, V>(x: T, y: U, cb: (x: T, y: U) => V) => V >bar : <T, U, V>(x: T, y: U, cb: (x: T, y: U) => V) => V
>"one" : string >"one" : string
>1 : number >1 : number
>h : <T, U>(x: T, y: U) => T[] | U[] >h : <T, U>(x: T, y: U) => T[] | U[]
var d = baz(d, d, g); // Should be number[] | string[] var d = baz(d, d, g); // Should be number[] | string[]
>d : string[] | number[] >d : number[] | string[]
>baz(d, d, g) : string[] | number[] >baz(d, d, g) : number[] | string[]
>baz : <T, U>(x: T, y: T, cb: (x: T, y: T) => U) => U >baz : <T, U>(x: T, y: T, cb: (x: T, y: T) => U) => U
>d : string[] | number[] >d : number[] | string[]
>d : string[] | number[] >d : number[] | string[]
>g : <T>(x: T, y: T) => T >g : <T>(x: T, y: T) => T

View file

@ -12,7 +12,7 @@ type arrayString = Array<String>
>String : String >String : String
type someArray = Array<String> | number[]; type someArray = Array<String> | number[];
>someArray : number[] | String[] >someArray : String[] | number[]
>Array : T[] >Array : T[]
>String : String >String : String

View file

@ -12,7 +12,7 @@ type arrayString = Array<String>
>String : String >String : String
type someArray = Array<String> | number[]; type someArray = Array<String> | number[];
>someArray : number[] | String[] >someArray : String[] | number[]
>Array : T[] >Array : T[]
>String : String >String : String

View file

@ -40,8 +40,8 @@ var f = [[], [1]]; // number[][]
>1 : number >1 : number
var g = [[1], ['']]; // {}[] var g = [[1], ['']]; // {}[]
>g : (string[] | number[])[] >g : (number[] | string[])[]
>[[1], ['']] : (string[] | number[])[] >[[1], ['']] : (number[] | string[])[]
>[1] : number[] >[1] : number[]
>1 : number >1 : number
>[''] : string[] >[''] : string[]

View file

@ -379,8 +379,8 @@ var rg7 = a7 || a6; // object || enum is object | enum
>a6 : E >a6 : E
var rg8 = a8 || a6; // array || enum is array | enum var rg8 = a8 || a6; // array || enum is array | enum
>rg8 : string[] | E >rg8 : E | string[]
>a8 || a6 : string[] | E >a8 || a6 : E | string[]
>a8 : string[] >a8 : string[]
>a6 : E >a6 : E
@ -439,8 +439,8 @@ var rh7 = a7 || a7; // object || object is object
>a7 : { a: string; } >a7 : { a: string; }
var rh8 = a8 || a7; // array || object is array | object var rh8 = a8 || a7; // array || object is array | object
>rh8 : string[] | { a: string; } >rh8 : { a: string; } | string[]
>a8 || a7 : string[] | { a: string; } >a8 || a7 : { a: string; } | string[]
>a8 : string[] >a8 : string[]
>a7 : { a: string; } >a7 : { a: string; }
@ -487,14 +487,14 @@ var ri5 = a5 || a8; // void || array is void | array
>a8 : string[] >a8 : string[]
var ri6 = a6 || a8; // enum || array is enum | array var ri6 = a6 || a8; // enum || array is enum | array
>ri6 : string[] | E >ri6 : E | string[]
>a6 || a8 : string[] | E >a6 || a8 : E | string[]
>a6 : E >a6 : E
>a8 : string[] >a8 : string[]
var ri7 = a7 || a8; // object || array is object | array var ri7 = a7 || a8; // object || array is object | array
>ri7 : string[] | { a: string; } >ri7 : { a: string; } | string[]
>a7 || a8 : string[] | { a: string; } >a7 || a8 : { a: string; } | string[]
>a7 : { a: string; } >a7 : { a: string; }
>a8 : string[] >a8 : string[]

View file

@ -20,7 +20,7 @@ System.register([], function(exports_1) {
(function (M) { (function (M) {
var x = 1; var x = 1;
})(M = M || (M = {})); })(M = M || (M = {}));
exports_1("M", M) exports_1("M", M);
} }
} }
}); });

View file

@ -20,7 +20,7 @@ System.register([], function(exports_1) {
(function (F) { (function (F) {
var x; var x;
})(F = F || (F = {})); })(F = F || (F = {}));
exports_1("F", F) exports_1("F", F);
C = (function () { C = (function () {
function C() { function C() {
} }
@ -30,14 +30,14 @@ System.register([], function(exports_1) {
(function (C) { (function (C) {
var x; var x;
})(C = C || (C = {})); })(C = C || (C = {}));
exports_1("C", C) exports_1("C", C);
(function (E) { (function (E) {
})(E || (E = {})); })(E || (E = {}));
exports_1("E", E) exports_1("E", E);
(function (E) { (function (E) {
var x; var x;
})(E = E || (E = {})); })(E = E || (E = {}));
exports_1("E", E) exports_1("E", E);
} }
} }
}); });

View file

@ -29,11 +29,11 @@ System.register([], function(exports_1) {
(function (TopLevelModule) { (function (TopLevelModule) {
var v; var v;
})(TopLevelModule = TopLevelModule || (TopLevelModule = {})); })(TopLevelModule = TopLevelModule || (TopLevelModule = {}));
exports_1("TopLevelModule", TopLevelModule) exports_1("TopLevelModule", TopLevelModule);
(function (TopLevelEnum) { (function (TopLevelEnum) {
TopLevelEnum[TopLevelEnum["E"] = 0] = "E"; TopLevelEnum[TopLevelEnum["E"] = 0] = "E";
})(TopLevelEnum || (TopLevelEnum = {})); })(TopLevelEnum || (TopLevelEnum = {}));
exports_1("TopLevelEnum", TopLevelEnum) exports_1("TopLevelEnum", TopLevelEnum);
(function (TopLevelModule2) { (function (TopLevelModule2) {
var NonTopLevelClass = (function () { var NonTopLevelClass = (function () {
function NonTopLevelClass() { function NonTopLevelClass() {
@ -52,7 +52,7 @@ System.register([], function(exports_1) {
})(TopLevelModule2.NonTopLevelEnum || (TopLevelModule2.NonTopLevelEnum = {})); })(TopLevelModule2.NonTopLevelEnum || (TopLevelModule2.NonTopLevelEnum = {}));
var NonTopLevelEnum = TopLevelModule2.NonTopLevelEnum; var NonTopLevelEnum = TopLevelModule2.NonTopLevelEnum;
})(TopLevelModule2 = TopLevelModule2 || (TopLevelModule2 = {})); })(TopLevelModule2 = TopLevelModule2 || (TopLevelModule2 = {}));
exports_1("TopLevelModule2", TopLevelModule2) exports_1("TopLevelModule2", TopLevelModule2);
} }
} }
}); });

View file

@ -363,9 +363,9 @@ function foo12(x: number | string | boolean) {
>10 : number >10 : number
>x.toString().length : number >x.toString().length : number
>x.toString() : string >x.toString() : string
>x.toString : () => string >x.toString : (radix?: number) => string
>x : string | number | boolean >x : string | number | boolean
>toString : () => string >toString : (radix?: number) => string
>length : number >length : number
: ((b = x) // x is number | boolean | string - changed in true branch : ((b = x) // x is number | boolean | string - changed in true branch

View file

@ -1,3 +1,4 @@
// @skipDefaultLibCheck: false
"use strict"; "use strict";
function eval() { function eval() {
} }

View file

@ -1,3 +1,4 @@
// @skipDefaultLibCheck: false
// it is an error to have duplicate index signatures of the same kind in a type // it is an error to have duplicate index signatures of the same kind in a type
interface Number { interface Number {

View file

@ -1,3 +1,4 @@
// @skipDefaultLibCheck: false
class A { class A {
foo: string; foo: string;
} }

View file

@ -1,3 +1,4 @@
// @skipDefaultLibCheck: false
// object types can define string indexers that are more specific than the default 'any' that would be returned // object types can define string indexers that are more specific than the default 'any' that would be returned
// no errors expected below // no errors expected below