mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-22 22:55:36 -05:00
merge with master
This commit is contained in:
14
tests/cases/compiler/asiAbstract.ts
Normal file
14
tests/cases/compiler/asiAbstract.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
abstract
|
||||
class NonAbstractClass {
|
||||
abstract s();
|
||||
}
|
||||
|
||||
class C2 {
|
||||
abstract
|
||||
nonAbstractFunction() {
|
||||
}
|
||||
}
|
||||
|
||||
class C3 {
|
||||
abstract
|
||||
}
|
||||
39
tests/cases/compiler/asiPublicPrivateProtected.ts
Normal file
39
tests/cases/compiler/asiPublicPrivateProtected.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
public
|
||||
class NonPublicClass {
|
||||
public s() {
|
||||
}
|
||||
}
|
||||
|
||||
class NonPublicClass2 {
|
||||
public
|
||||
private nonPublicFunction() {
|
||||
}
|
||||
}
|
||||
private
|
||||
class NonPrivateClass {
|
||||
private s() {
|
||||
}
|
||||
}
|
||||
|
||||
class NonPrivateClass2 {
|
||||
private
|
||||
public nonPrivateFunction() {
|
||||
}
|
||||
}
|
||||
protected
|
||||
class NonProtectedClass {
|
||||
protected s() {
|
||||
}
|
||||
}
|
||||
|
||||
class NonProtectedClass2 {
|
||||
protected
|
||||
public nonProtectedFunction() {
|
||||
}
|
||||
}
|
||||
|
||||
class ClassWithThreeMembers {
|
||||
public
|
||||
private
|
||||
protected
|
||||
}
|
||||
29
tests/cases/compiler/constIndexedAccess.ts
Normal file
29
tests/cases/compiler/constIndexedAccess.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
|
||||
const enum numbers {
|
||||
zero,
|
||||
one
|
||||
}
|
||||
|
||||
interface indexAccess {
|
||||
0: string;
|
||||
1: number;
|
||||
}
|
||||
|
||||
let test: indexAccess;
|
||||
|
||||
let s = test[0];
|
||||
let n = test[1];
|
||||
|
||||
let s1 = test[numbers.zero];
|
||||
let n1 = test[numbers.one];
|
||||
|
||||
let s2 = test[numbers["zero"]];
|
||||
let n2 = test[numbers["one"]];
|
||||
|
||||
enum numbersNotConst {
|
||||
zero,
|
||||
one
|
||||
}
|
||||
|
||||
let s3 = test[numbersNotConst.zero];
|
||||
let n3 = test[numbersNotConst.one];
|
||||
4
tests/cases/compiler/modulePrologueAMD.ts
Normal file
4
tests/cases/compiler/modulePrologueAMD.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
// @module: amd
|
||||
"use strict";
|
||||
|
||||
export class Foo {}
|
||||
4
tests/cases/compiler/modulePrologueCommonjs.ts
Normal file
4
tests/cases/compiler/modulePrologueCommonjs.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
// @module: commonjs
|
||||
"use strict";
|
||||
|
||||
export class Foo {}
|
||||
5
tests/cases/compiler/modulePrologueES6.ts
Normal file
5
tests/cases/compiler/modulePrologueES6.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
// @module: es6
|
||||
// @target: es6
|
||||
"use strict";
|
||||
|
||||
export class Foo {}
|
||||
4
tests/cases/compiler/modulePrologueSystem.ts
Normal file
4
tests/cases/compiler/modulePrologueSystem.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
// @module: system
|
||||
"use strict";
|
||||
|
||||
export class Foo {}
|
||||
4
tests/cases/compiler/modulePrologueUmd.ts
Normal file
4
tests/cases/compiler/modulePrologueUmd.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
// @module: umd
|
||||
"use strict";
|
||||
|
||||
export class Foo {}
|
||||
20
tests/cases/compiler/recursiveGenericUnionType1.ts
Normal file
20
tests/cases/compiler/recursiveGenericUnionType1.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
declare module Test1 {
|
||||
export type Container<T> = T | {
|
||||
[i: string]: Container<T>;
|
||||
};
|
||||
export type IStringContainer = Container<string>;
|
||||
}
|
||||
|
||||
declare module Test2 {
|
||||
export type Container<T> = T | {
|
||||
[i: string]: Container<T>;
|
||||
};
|
||||
export type IStringContainer = Container<string>;
|
||||
}
|
||||
|
||||
var x: Test1.Container<number>;
|
||||
|
||||
var s1: Test1.IStringContainer;
|
||||
var s2: Test2.IStringContainer;
|
||||
s1 = s2;
|
||||
s2 = s1;
|
||||
20
tests/cases/compiler/recursiveGenericUnionType2.ts
Normal file
20
tests/cases/compiler/recursiveGenericUnionType2.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
declare module Test1 {
|
||||
export type Container<T> = T | {
|
||||
[i: string]: Container<T>[];
|
||||
};
|
||||
export type IStringContainer = Container<string>;
|
||||
}
|
||||
|
||||
declare module Test2 {
|
||||
export type Container<T> = T | {
|
||||
[i: string]: Container<T>[];
|
||||
};
|
||||
export type IStringContainer = Container<string>;
|
||||
}
|
||||
|
||||
var x: Test1.Container<number>;
|
||||
|
||||
var s1: Test1.IStringContainer;
|
||||
var s2: Test2.IStringContainer;
|
||||
s1 = s2;
|
||||
s2 = s1;
|
||||
@@ -0,0 +1,118 @@
|
||||
// @target: ES5
|
||||
|
||||
|
||||
(function() {
|
||||
var s0;
|
||||
for ({ s0 = 5 } of [{ s0: 1 }]) {
|
||||
}
|
||||
});
|
||||
(function() {
|
||||
var s0;
|
||||
for ({ s0:s0 = 5 } of [{ s0: 1 }]) {
|
||||
}
|
||||
});
|
||||
|
||||
(function() {
|
||||
var s1;
|
||||
for ({ s1 = 5 } of [{}]) {
|
||||
}
|
||||
});
|
||||
|
||||
(function() {
|
||||
var s1;
|
||||
for ({ s1:s1 = 5 } of [{}]) {
|
||||
}
|
||||
});
|
||||
|
||||
(function() {
|
||||
var s2;
|
||||
for ({ s2 = 5 } of [{ s2: "" }]) {
|
||||
}
|
||||
});
|
||||
|
||||
(function() {
|
||||
var s2;
|
||||
for ({ s2:s2 = 5 } of [{ s2: "" }]) {
|
||||
}
|
||||
});
|
||||
|
||||
(function() {
|
||||
var s3: string;
|
||||
for ({ s3 = 5 } of [{ s3: "" }]) {
|
||||
}
|
||||
});
|
||||
|
||||
(function() {
|
||||
var s3: string;
|
||||
for ({ s3:s3 = 5 } of [{ s3: "" }]) {
|
||||
}
|
||||
});
|
||||
|
||||
(function() {
|
||||
let y;
|
||||
({ y = 5 } = { y: 1 })
|
||||
});
|
||||
|
||||
(function() {
|
||||
let y;
|
||||
({ y:y = 5 } = { y: 1 })
|
||||
});
|
||||
|
||||
(function() {
|
||||
let y0: number;
|
||||
({ y0 = 5 } = { y0: 1 })
|
||||
});
|
||||
|
||||
(function() {
|
||||
let y0: number;
|
||||
({ y0:y0 = 5 } = { y0: 1 })
|
||||
});
|
||||
|
||||
(function() {
|
||||
let y1: string;
|
||||
({ y1 = 5 } = {})
|
||||
});
|
||||
|
||||
(function() {
|
||||
let y1: string;
|
||||
({ y1:y1 = 5 } = {})
|
||||
});
|
||||
|
||||
(function() {
|
||||
let y2: string, y3: { x: string };
|
||||
({ y2 = 5, y3 = { x: 1 } } = {})
|
||||
});
|
||||
|
||||
(function() {
|
||||
let y2: string, y3: { x: string };
|
||||
({ y2:y2 = 5, y3:y3 = { x: 1 } } = {})
|
||||
});
|
||||
|
||||
(function() {
|
||||
let y4: number, y5: { x: number };
|
||||
({ y4 = 5, y5 = { x: 1 } } = {})
|
||||
});
|
||||
|
||||
(function() {
|
||||
let y4: number, y5: { x: number };
|
||||
({ y4:y4 = 5, y5:y5 = { x: 1 } } = {})
|
||||
});
|
||||
|
||||
|
||||
(function() {
|
||||
let z;
|
||||
({ z = { x: 5 } } = { z: { x: 1 } });
|
||||
});
|
||||
|
||||
|
||||
(function() {
|
||||
let z;
|
||||
({ z:z = { x: 5 } } = { z: { x: 1 } });
|
||||
});
|
||||
|
||||
(function() {
|
||||
let a = { s = 5 };
|
||||
});
|
||||
|
||||
function foo({a = 4, b = { x: 5 }}) {
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
// @target: ES6
|
||||
|
||||
|
||||
(function() {
|
||||
var s0;
|
||||
for ({ s0 = 5 } of [{ s0: 1 }]) {
|
||||
}
|
||||
});
|
||||
(function() {
|
||||
var s0;
|
||||
for ({ s0:s0 = 5 } of [{ s0: 1 }]) {
|
||||
}
|
||||
});
|
||||
|
||||
(function() {
|
||||
var s1;
|
||||
for ({ s1 = 5 } of [{}]) {
|
||||
}
|
||||
});
|
||||
|
||||
(function() {
|
||||
var s1;
|
||||
for ({ s1:s1 = 5 } of [{}]) {
|
||||
}
|
||||
});
|
||||
|
||||
(function() {
|
||||
var s2;
|
||||
for ({ s2 = 5 } of [{ s2: "" }]) {
|
||||
}
|
||||
});
|
||||
|
||||
(function() {
|
||||
var s2;
|
||||
for ({ s2:s2 = 5 } of [{ s2: "" }]) {
|
||||
}
|
||||
});
|
||||
|
||||
(function() {
|
||||
var s3: string;
|
||||
for ({ s3 = 5 } of [{ s3: "" }]) {
|
||||
}
|
||||
});
|
||||
|
||||
(function() {
|
||||
var s3: string;
|
||||
for ({ s3:s3 = 5 } of [{ s3: "" }]) {
|
||||
}
|
||||
});
|
||||
|
||||
(function() {
|
||||
let y;
|
||||
({ y = 5 } = { y: 1 })
|
||||
});
|
||||
|
||||
(function() {
|
||||
let y;
|
||||
({ y:y = 5 } = { y: 1 })
|
||||
});
|
||||
|
||||
(function() {
|
||||
let y0: number;
|
||||
({ y0 = 5 } = { y0: 1 })
|
||||
});
|
||||
|
||||
(function() {
|
||||
let y0: number;
|
||||
({ y0:y0 = 5 } = { y0: 1 })
|
||||
});
|
||||
|
||||
(function() {
|
||||
let y1: string;
|
||||
({ y1 = 5 } = {})
|
||||
});
|
||||
|
||||
(function() {
|
||||
let y1: string;
|
||||
({ y1:y1 = 5 } = {})
|
||||
});
|
||||
|
||||
(function() {
|
||||
let y2: string, y3: { x: string };
|
||||
({ y2 = 5, y3 = { x: 1 } } = {})
|
||||
});
|
||||
|
||||
(function() {
|
||||
let y2: string, y3: { x: string };
|
||||
({ y2:y2 = 5, y3:y3 = { x: 1 } } = {})
|
||||
});
|
||||
|
||||
(function() {
|
||||
let y4: number, y5: { x: number };
|
||||
({ y4 = 5, y5 = { x: 1 } } = {})
|
||||
});
|
||||
|
||||
(function() {
|
||||
let y4: number, y5: { x: number };
|
||||
({ y4:y4 = 5, y5:y5 = { x: 1 } } = {})
|
||||
});
|
||||
|
||||
|
||||
(function() {
|
||||
let z;
|
||||
({ z = { x: 5 } } = { z: { x: 1 } });
|
||||
});
|
||||
|
||||
|
||||
(function() {
|
||||
let z;
|
||||
({ z:z = { x: 5 } } = { z: { x: 1 } });
|
||||
});
|
||||
|
||||
(function() {
|
||||
let a = { s = 5 };
|
||||
});
|
||||
|
||||
function foo({a = 4, b = { x: 5 }}) {
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
// @target: ES6
|
||||
// @noEmitHelpers: true
|
||||
// @experimentalAsyncFunctions: true
|
||||
declare class Thenable { then(): void; }
|
||||
declare let a: any;
|
||||
declare let obj: { then: string; };
|
||||
declare let thenable: Thenable;
|
||||
async function fn1() { } // valid: Promise<void>
|
||||
async function fn2(): { } { } // error
|
||||
async function fn3(): any { } // error
|
||||
async function fn4(): number { } // error
|
||||
async function fn5(): PromiseLike<void> { } // error
|
||||
async function fn6(): Thenable { } // error
|
||||
async function fn7() { return; } // valid: Promise<void>
|
||||
async function fn8() { return 1; } // valid: Promise<number>
|
||||
async function fn9() { return null; } // valid: Promise<any>
|
||||
async function fn10() { return undefined; } // valid: Promise<any>
|
||||
async function fn11() { return a; } // valid: Promise<any>
|
||||
async function fn12() { return obj; } // valid: Promise<{ then: string; }>
|
||||
async function fn13() { return thenable; } // error
|
||||
async function fn14() { await 1; } // valid: Promise<void>
|
||||
async function fn15() { await null; } // valid: Promise<void>
|
||||
async function fn16() { await undefined; } // valid: Promise<void>
|
||||
async function fn17() { await a; } // valid: Promise<void>
|
||||
async function fn18() { await obj; } // valid: Promise<void>
|
||||
async function fn19() { await thenable; } // error
|
||||
@@ -0,0 +1,4 @@
|
||||
// @target:es6
|
||||
export default class {
|
||||
static z: string = "Foo";
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// @module: commonjs
|
||||
// @target: ES5
|
||||
|
||||
export default function f();
|
||||
export default function f(x: string);
|
||||
export default function f(...args: any[]) {
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
// @target: es6
|
||||
// @module: commonjs
|
||||
|
||||
// @filename: t1.ts
|
||||
var v = 1;
|
||||
function f() { }
|
||||
class C {
|
||||
}
|
||||
interface I {
|
||||
}
|
||||
enum E {
|
||||
A, B, C
|
||||
}
|
||||
const enum D {
|
||||
A, B, C
|
||||
}
|
||||
module M {
|
||||
export var x;
|
||||
}
|
||||
module N {
|
||||
export interface I {
|
||||
}
|
||||
}
|
||||
type T = number;
|
||||
import a = M.x;
|
||||
|
||||
export { v, f, C, I, E, D, M, N, T, a };
|
||||
|
||||
// @filename: t2.ts
|
||||
export { v, f, C, I, E, D, M, N, T, a } from "./t1";
|
||||
|
||||
// @filename: t3.ts
|
||||
import { v, f, C, I, E, D, M, N, T, a } from "./t1";
|
||||
export { v, f, C, I, E, D, M, N, T, a };
|
||||
@@ -0,0 +1,13 @@
|
||||
// @target: es6
|
||||
// @module: commonjs
|
||||
|
||||
// @filename: t1.ts
|
||||
export var x = "x";
|
||||
export var y = "y";
|
||||
|
||||
// @filename: t2.ts
|
||||
export { x as y, y as x } from "./t1";
|
||||
|
||||
// @filename: t3.ts
|
||||
import { x, y } from "./t1";
|
||||
export { x as y, y as x };
|
||||
@@ -0,0 +1,34 @@
|
||||
// @target: es6
|
||||
// @module: commonjs
|
||||
|
||||
// @filename: t1.ts
|
||||
export var v = 1;
|
||||
export function f() { }
|
||||
export class C {
|
||||
}
|
||||
export interface I {
|
||||
}
|
||||
export enum E {
|
||||
A, B, C
|
||||
}
|
||||
export const enum D {
|
||||
A, B, C
|
||||
}
|
||||
export module M {
|
||||
export var x;
|
||||
}
|
||||
export module N {
|
||||
export interface I {
|
||||
}
|
||||
}
|
||||
export type T = number;
|
||||
export import a = M.x;
|
||||
|
||||
export { v as v1, f as f1, C as C1, I as I1, E as E1, D as D1, M as M1, N as N1, T as T1, a as a1 };
|
||||
|
||||
// @filename: t2.ts
|
||||
export { v1 as v, f1 as f, C1 as C, I1 as I, E1 as E, D1 as D, M1 as M, N1 as N, T1 as T, a1 as a } from "./t1";
|
||||
|
||||
// @filename: t3.ts
|
||||
import { v1 as v, f1 as f, C1 as C, I1 as I, E1 as E, D1 as D, M1 as M, N1 as N, T1 as T, a1 as a } from "./t1";
|
||||
export { v, f, C, I, E, D, M, N, T, a };
|
||||
@@ -0,0 +1,39 @@
|
||||
// @target: es6
|
||||
// @module: commonjs
|
||||
|
||||
// @filename: t1.ts
|
||||
export default "hello";
|
||||
|
||||
// @filename: t2.ts
|
||||
import a = require("./t1");
|
||||
a.default;
|
||||
import b from "./t1";
|
||||
b;
|
||||
import * as c from "./t1";
|
||||
c.default;
|
||||
import { default as d } from "./t1";
|
||||
d;
|
||||
import e1, * as e2 from "./t1";
|
||||
e1;
|
||||
e2.default;
|
||||
import f1, { default as f2 } from "./t1";
|
||||
f1;
|
||||
f2;
|
||||
import "./t1";
|
||||
|
||||
// @filename: t3.ts
|
||||
import a = require("./t1");
|
||||
a.default;
|
||||
import b from "./t1";
|
||||
b;
|
||||
import * as c from "./t1";
|
||||
c.default;
|
||||
import { default as d } from "./t1";
|
||||
d;
|
||||
import e1, * as e2 from "./t1";
|
||||
e1;
|
||||
e2.default;
|
||||
import f1, { default as f2 } from "./t1";
|
||||
f1;
|
||||
f2;
|
||||
export { a, b, c, d, e1, e2, f1, f2 };
|
||||
@@ -0,0 +1,8 @@
|
||||
// @module: commonjs
|
||||
// @target: ES5
|
||||
|
||||
export default class C {
|
||||
}
|
||||
|
||||
export default class C {
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// @module: commonjs
|
||||
// @target: ES5
|
||||
|
||||
export default function f() {
|
||||
}
|
||||
|
||||
export default function f() {
|
||||
}
|
||||
26
tests/cases/conformance/jsx/tsxPreserveEmit1.tsx
Normal file
26
tests/cases/conformance/jsx/tsxPreserveEmit1.tsx
Normal file
@@ -0,0 +1,26 @@
|
||||
//@module: amd
|
||||
//@jsx: preserve
|
||||
//@target: ES5
|
||||
|
||||
//@Filename: react.d.ts
|
||||
declare module 'react' {
|
||||
var x: any;
|
||||
export = x;
|
||||
}
|
||||
|
||||
declare module ReactRouter {
|
||||
var Route: any;
|
||||
interface Thing { }
|
||||
}
|
||||
declare module 'react-router' {
|
||||
export = ReactRouter;
|
||||
}
|
||||
|
||||
//@Filename: test.tsx
|
||||
// Should emit 'react-router' in the AMD dependency list
|
||||
import React = require('react');
|
||||
import ReactRouter = require('react-router');
|
||||
|
||||
import Route = ReactRouter.Route;
|
||||
|
||||
var routes = <Route />;
|
||||
@@ -2,12 +2,16 @@
|
||||
////var x = `sadasdasdasdasfegsfd
|
||||
/////*1*/rasdesgeryt35t35y35 e4 ergt er 35t 3535 `;
|
||||
////var y = `1${2}/*2*/3`;
|
||||
////let z= `foo`/*3*/
|
||||
////let w= `bar${3}`/*4*/
|
||||
////
|
||||
/////*formatStart*/
|
||||
////let z= `foo`;/*3*/
|
||||
////let w= `bar${3}`;/*4*/
|
||||
////String.raw
|
||||
//// `template`/*5*/
|
||||
////String.raw`foo`/*6*/
|
||||
////String.raw `bar${3}`/*7*/
|
||||
//// `template`;/*5*/
|
||||
////String.raw`foo`;/*6*/
|
||||
////String.raw `bar${3}`;/*7*/
|
||||
////`Write ${ JSON.stringify("") } and ${ (765) } and ${ 346 }`;/*spaceInside*/
|
||||
/////*formatEnd*/
|
||||
|
||||
|
||||
goTo.marker("1");
|
||||
@@ -18,19 +22,19 @@ edit.insert("\r\n");
|
||||
verify.indentationIs(0);
|
||||
verify.currentLineContentIs("3`;")
|
||||
|
||||
format.selection("formatStart", "formatEnd");
|
||||
|
||||
goTo.marker("3");
|
||||
edit.insert(";");
|
||||
verify.currentLineContentIs("let z = `foo`;");
|
||||
goTo.marker("4");
|
||||
edit.insert(";");
|
||||
verify.currentLineContentIs("let w = `bar${3}`;");
|
||||
|
||||
goTo.marker("5");
|
||||
edit.insert(";");
|
||||
verify.currentLineContentIs(" `template`;");
|
||||
goTo.marker("6");
|
||||
edit.insert(";");
|
||||
verify.currentLineContentIs("String.raw `foo`;");
|
||||
goTo.marker("7");
|
||||
edit.insert(";");
|
||||
verify.currentLineContentIs("String.raw `bar${3}`;");
|
||||
verify.currentLineContentIs("String.raw `bar${3}`;");
|
||||
|
||||
goTo.marker("spaceInside");
|
||||
verify.currentLineContentIs('`Write ${JSON.stringify("")} and ${(765)} and ${346}`;');
|
||||
@@ -68,6 +68,13 @@ enum EmitReturnStatus {
|
||||
EmitErrorsEncountered = 4 // Emitter errors occurred during emitting process
|
||||
}
|
||||
|
||||
// This is a duplicate of the indentstyle in services.ts to expose it to testcases in fourslash
|
||||
enum IndentStyle {
|
||||
None,
|
||||
Block,
|
||||
Smart,
|
||||
}
|
||||
|
||||
module FourSlashInterface {
|
||||
|
||||
export interface Marker {
|
||||
@@ -278,8 +285,8 @@ module FourSlashInterface {
|
||||
FourSlash.currentTestState.verifyIndentationAtCurrentPosition(numberOfSpaces);
|
||||
}
|
||||
|
||||
public indentationAtPositionIs(fileName: string, position: number, numberOfSpaces: number) {
|
||||
FourSlash.currentTestState.verifyIndentationAtPosition(fileName, position, numberOfSpaces);
|
||||
public indentationAtPositionIs(fileName: string, position: number, numberOfSpaces: number, indentStyle = IndentStyle.Smart) {
|
||||
FourSlash.currentTestState.verifyIndentationAtPosition(fileName, position, numberOfSpaces, indentStyle);
|
||||
}
|
||||
|
||||
public textAtCaretIs(text: string) {
|
||||
|
||||
183
tests/cases/fourslash/indentationBlock.ts
Normal file
183
tests/cases/fourslash/indentationBlock.ts
Normal file
@@ -0,0 +1,183 @@
|
||||
/// <reference path="fourslash.ts"/>
|
||||
|
||||
////
|
||||
////module classes {
|
||||
////{| "indent": 0 |}
|
||||
//// class Bar {
|
||||
////{| "indent": 4 |}
|
||||
////
|
||||
//// constructor() {
|
||||
////{| "indent": 8 |}
|
||||
//// }
|
||||
////
|
||||
//// private foo: string = "";
|
||||
////{| "indent": 8 |}
|
||||
////
|
||||
//// private f() {
|
||||
//// var a: any[] = [[1, 2], [3, 4], 5];
|
||||
////{| "indent": 12 |}
|
||||
//// return ((1 + 1));
|
||||
//// }
|
||||
////
|
||||
////{| "indent": 8 |}
|
||||
//// private f2() {
|
||||
//// if (true) { } { };
|
||||
//// }
|
||||
//// }
|
||||
////}
|
||||
////
|
||||
////
|
||||
////module interfaces {
|
||||
////{| "indent": 0 |}
|
||||
//// interface Foo {
|
||||
////{| "indent": 4 |}
|
||||
////
|
||||
//// x: number;
|
||||
////{| "indent": 8 |}
|
||||
////
|
||||
//// foo(): number;
|
||||
////{| "indent": 8 |}
|
||||
//// }
|
||||
////}
|
||||
////
|
||||
////
|
||||
////module nestedModules {
|
||||
//// module Foo2 {
|
||||
////{| "indent": 4 |}
|
||||
//// function f() {
|
||||
//// }
|
||||
////{| "indent": 8 |}
|
||||
//// var x: number;
|
||||
////{| "indent": 8 |}
|
||||
//// }
|
||||
////}
|
||||
////
|
||||
////
|
||||
////module Enums {
|
||||
//// enum Foo3 {
|
||||
////{| "indent": 4 |}
|
||||
//// val1,
|
||||
////{| "indent": 8 |}
|
||||
//// val2,
|
||||
////{| "indent": 8 |}
|
||||
//// }
|
||||
////{| "indent": 4 |}
|
||||
////}
|
||||
////
|
||||
////
|
||||
////function controlStatements() {
|
||||
//// for (var i = 0; i < 10; i++) {
|
||||
////{| "indent": 4 |}
|
||||
//// }
|
||||
////
|
||||
//// for (var e in foo.bar) {
|
||||
////{| "indent": 4 |}
|
||||
//// }
|
||||
////
|
||||
//// with (foo.bar) {
|
||||
////{| "indent": 4 |}
|
||||
//// }
|
||||
////
|
||||
//// while (false) {
|
||||
////{| "indent": 4 |}
|
||||
//// }
|
||||
////
|
||||
//// do {
|
||||
////{| "indent": 4 |}
|
||||
//// } while (false);
|
||||
////
|
||||
//// switch (foo.bar) {
|
||||
////{| "indent": 4 |}
|
||||
//// }
|
||||
////
|
||||
//// switch (foo.bar) {
|
||||
////{| "indent": 4 |}
|
||||
//// case 1:
|
||||
////{| "indent": 8 |}
|
||||
//// break;
|
||||
//// default:
|
||||
////{| "indent": 8 |}
|
||||
//// break;
|
||||
//// }
|
||||
////}
|
||||
////
|
||||
////
|
||||
////function tryCatch() {
|
||||
////{| "indent": 0 |}
|
||||
//// try {
|
||||
////{| "indent": 4 |}
|
||||
//// }
|
||||
////{| "indent": 4 |}
|
||||
//// catch (err) {
|
||||
////{| "indent": 4 |}
|
||||
//// }
|
||||
////{| "indent": 4 |}
|
||||
////}
|
||||
////
|
||||
////
|
||||
////function tryFinally() {
|
||||
////{| "indent": 0 |}
|
||||
//// try {
|
||||
////{| "indent": 4 |}
|
||||
//// }
|
||||
////{| "indent": 4 |}
|
||||
//// finally {
|
||||
////{| "indent": 4 |}
|
||||
//// }
|
||||
////{| "indent": 4 |}
|
||||
////}
|
||||
////
|
||||
////
|
||||
////function tryCatchFinally() {
|
||||
////{| "indent": 0 |}
|
||||
//// try {
|
||||
////{| "indent": 4 |}
|
||||
//// }
|
||||
////{| "indent": 4 |}
|
||||
//// catch (err) {
|
||||
////{| "indent": 4 |}
|
||||
//// }
|
||||
////{| "indent": 4 |}
|
||||
//// finally {
|
||||
////{| "indent": 4 |}
|
||||
//// }
|
||||
////{| "indent": 4 |}
|
||||
////}
|
||||
////
|
||||
////
|
||||
////class indentBeforeCurly
|
||||
////{| "indent": 0 |}
|
||||
////{| "indent": 0 |}{
|
||||
////{| "indent": 0 |}
|
||||
////}
|
||||
////
|
||||
////
|
||||
////function argumentsListIndentation(bar,
|
||||
//// blah,
|
||||
//// {| "indent": 13 |}
|
||||
////);
|
||||
////
|
||||
////
|
||||
////function blockIndentAfterIndentedParameter1(bar,
|
||||
//// blah) {
|
||||
////{| "indent": 13 |}
|
||||
////}
|
||||
////
|
||||
////
|
||||
////function blockIndentAfterIndentedParameter2(bar,
|
||||
//// blah) {
|
||||
//// if (foo) {
|
||||
////{| "indent": 4 |}
|
||||
//// }
|
||||
////}
|
||||
////
|
||||
////
|
||||
////// Note: Do not add more tests at the end of this file, as
|
||||
////// the purpose of this test is to verity smart indent
|
||||
////// works for unterminated function arguments at the end of a file.
|
||||
////function unterminatedListIndentation(a,
|
||||
////{| "indent": 0 |}
|
||||
|
||||
test.markers().forEach(marker => {
|
||||
verify.indentationAtPositionIs(marker.fileName, marker.position, marker.data.indent, IndentStyle.Block);
|
||||
});
|
||||
183
tests/cases/fourslash/indentationNone.ts
Normal file
183
tests/cases/fourslash/indentationNone.ts
Normal file
@@ -0,0 +1,183 @@
|
||||
/// <reference path="fourslash.ts"/>
|
||||
|
||||
////
|
||||
////module classes {
|
||||
////{| "indent": 0 |}
|
||||
//// class Bar {
|
||||
////{| "indent": 0 |}
|
||||
////
|
||||
//// constructor() {
|
||||
////{| "indent": 0 |}
|
||||
//// }
|
||||
////
|
||||
//// private foo: string = "";
|
||||
////{| "indent": 0 |}
|
||||
////
|
||||
//// private f() {
|
||||
//// var a: any[] = [[1, 2], [3, 4], 5];
|
||||
////{| "indent": 0 |}
|
||||
//// return ((1 + 1));
|
||||
//// }
|
||||
////
|
||||
////{| "indent": 0 |}
|
||||
//// private f2() {
|
||||
//// if (true) { } { };
|
||||
//// }
|
||||
//// }
|
||||
////}
|
||||
////
|
||||
////
|
||||
////module interfaces {
|
||||
////{| "indent": 0 |}
|
||||
//// interface Foo {
|
||||
////{| "indent": 0 |}
|
||||
////
|
||||
//// x: number;
|
||||
////{| "indent": 0 |}
|
||||
////
|
||||
//// foo(): number;
|
||||
////{| "indent": 0 |}
|
||||
//// }
|
||||
////}
|
||||
////
|
||||
////
|
||||
////module nestedModules {
|
||||
//// module Foo2 {
|
||||
////{| "indent": 0 |}
|
||||
//// function f() {
|
||||
//// }
|
||||
////{| "indent": 0 |}
|
||||
//// var x: number;
|
||||
////{| "indent": 0 |}
|
||||
//// }
|
||||
////}
|
||||
////
|
||||
////
|
||||
////module Enums {
|
||||
//// enum Foo3 {
|
||||
////{| "indent": 0 |}
|
||||
//// val1,
|
||||
////{| "indent": 0 |}
|
||||
//// val2,
|
||||
////{| "indent": 0 |}
|
||||
//// }
|
||||
////{| "indent": 0 |}
|
||||
////}
|
||||
////
|
||||
////
|
||||
////function controlStatements() {
|
||||
//// for (var i = 0; i < 10; i++) {
|
||||
////{| "indent": 0 |}
|
||||
//// }
|
||||
////
|
||||
//// for (var e in foo.bar) {
|
||||
////{| "indent": 0 |}
|
||||
//// }
|
||||
////
|
||||
//// with (foo.bar) {
|
||||
////{| "indent": 0 |}
|
||||
//// }
|
||||
////
|
||||
//// while (false) {
|
||||
////{| "indent": 0 |}
|
||||
//// }
|
||||
////
|
||||
//// do {
|
||||
////{| "indent": 0 |}
|
||||
//// } while (false);
|
||||
////
|
||||
//// switch (foo.bar) {
|
||||
////{| "indent": 0 |}
|
||||
//// }
|
||||
////
|
||||
//// switch (foo.bar) {
|
||||
////{| "indent": 0 |}
|
||||
//// case 1:
|
||||
////{| "indent": 0 |}
|
||||
//// break;
|
||||
//// default:
|
||||
////{| "indent": 0 |}
|
||||
//// break;
|
||||
//// }
|
||||
////}
|
||||
////
|
||||
////
|
||||
////function tryCatch() {
|
||||
////{| "indent": 0 |}
|
||||
//// try {
|
||||
////{| "indent": 0 |}
|
||||
//// }
|
||||
////{| "indent": 0 |}
|
||||
//// catch (err) {
|
||||
////{| "indent": 0 |}
|
||||
//// }
|
||||
////{| "indent": 0 |}
|
||||
////}
|
||||
////
|
||||
////
|
||||
////function tryFinally() {
|
||||
////{| "indent": 0 |}
|
||||
//// try {
|
||||
////{| "indent": 0 |}
|
||||
//// }
|
||||
////{| "indent": 0 |}
|
||||
//// finally {
|
||||
////{| "indent": 0 |}
|
||||
//// }
|
||||
////{| "indent": 0 |}
|
||||
////}
|
||||
////
|
||||
////
|
||||
////function tryCatchFinally() {
|
||||
////{| "indent": 0 |}
|
||||
//// try {
|
||||
////{| "indent": 0 |}
|
||||
//// }
|
||||
////{| "indent": 0 |}
|
||||
//// catch (err) {
|
||||
////{| "indent": 0 |}
|
||||
//// }
|
||||
////{| "indent": 0 |}
|
||||
//// finally {
|
||||
////{| "indent": 0 |}
|
||||
//// }
|
||||
////{| "indent": 0 |}
|
||||
////}
|
||||
////
|
||||
////
|
||||
////class indentBeforeCurly
|
||||
////{| "indent": 0 |}
|
||||
////{| "indent": 0 |}{
|
||||
////{| "indent": 0 |}
|
||||
////}
|
||||
////
|
||||
////
|
||||
////function argumentsListIndentation(bar,
|
||||
//// blah,
|
||||
//// {| "indent": 0 |}
|
||||
////);
|
||||
////
|
||||
////
|
||||
////function blockIndentAfterIndentedParameter1(bar,
|
||||
//// blah) {
|
||||
////{| "indent": 0 |}
|
||||
////}
|
||||
////
|
||||
////
|
||||
////function blockIndentAfterIndentedParameter2(bar,
|
||||
//// blah) {
|
||||
//// if (foo) {
|
||||
////{| "indent": 0 |}
|
||||
//// }
|
||||
////}
|
||||
////
|
||||
////
|
||||
////// Note: Do not add more tests at the end of this file, as
|
||||
////// the purpose of this test is to verity smart indent
|
||||
////// works for unterminated function arguments at the end of a file.
|
||||
////function unterminatedListIndentation(a,
|
||||
////{| "indent": 0 |}
|
||||
|
||||
test.markers().forEach(marker => {
|
||||
verify.indentationAtPositionIs(marker.fileName, marker.position, marker.data.indent, IndentStyle.None);
|
||||
});
|
||||
@@ -43,7 +43,7 @@ module ts {
|
||||
}
|
||||
|
||||
if (canUseOldTranspile) {
|
||||
let diagnostics: Diagnostic[] = [];
|
||||
let diagnostics: Diagnostic[] = [];
|
||||
let transpileResult = transpile(input, transpileOptions.compilerOptions, transpileOptions.fileName, diagnostics, transpileOptions.moduleName);
|
||||
checkDiagnostics(diagnostics, testSettings.expectedDiagnosticCodes);
|
||||
if (testSettings.expectedOutput) {
|
||||
@@ -57,10 +57,10 @@ module ts {
|
||||
}
|
||||
|
||||
if (!transpileOptions.fileName) {
|
||||
transpileOptions.fileName = "file.ts";
|
||||
transpileOptions.fileName = transpileOptions.compilerOptions.jsx ? "file.tsx" : "file.ts";
|
||||
}
|
||||
|
||||
transpileOptions.compilerOptions.sourceMap = true;
|
||||
transpileOptions.compilerOptions.sourceMap = true;
|
||||
let transpileModuleResultWithSourceMap = transpileModule(input, transpileOptions);
|
||||
assert.isTrue(transpileModuleResultWithSourceMap.sourceMapText !== undefined);
|
||||
|
||||
@@ -68,7 +68,7 @@ module ts {
|
||||
let expectedSourceMappingUrlLine = `//# sourceMappingURL=${expectedSourceMapFileName}`;
|
||||
|
||||
if (testSettings.expectedOutput !== undefined) {
|
||||
assert.equal(transpileModuleResultWithSourceMap.outputText, testSettings.expectedOutput + expectedSourceMappingUrlLine);
|
||||
assert.equal(transpileModuleResultWithSourceMap.outputText, testSettings.expectedOutput + expectedSourceMappingUrlLine);
|
||||
}
|
||||
else {
|
||||
// expected output is not set, just verify that output text has sourceMappingURL as a last line
|
||||
@@ -78,7 +78,7 @@ module ts {
|
||||
assert.equal(output, expectedSourceMappingUrlLine);
|
||||
}
|
||||
else {
|
||||
let suffix = getNewLineCharacter(transpileOptions.compilerOptions) + expectedSourceMappingUrlLine
|
||||
let suffix = getNewLineCharacter(transpileOptions.compilerOptions) + expectedSourceMappingUrlLine
|
||||
assert.isTrue(output.indexOf(suffix, output.length - suffix.length) !== -1);
|
||||
}
|
||||
}
|
||||
@@ -274,5 +274,14 @@ var x = 0;`,
|
||||
it("Supports backslashes in file name", () => {
|
||||
test("var x", { expectedOutput: "var x;\r\n", options: { fileName: "a\\b.ts" }});
|
||||
});
|
||||
|
||||
it("transpile file as 'tsx' if 'jsx' is specified", () => {
|
||||
let input = `var x = <div/>`;
|
||||
let output = `var x = React.createElement("div", null);\n`;
|
||||
test(input, {
|
||||
expectedOutput: output,
|
||||
options: { compilerOptions: { jsx: JsxEmit.React, newLine: NewLineKind.LineFeed } }
|
||||
})
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user