From c68947e0fbbbe3c47c8d7608b6ee0d04d6325d38 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Mon, 29 Feb 2016 10:07:12 -0800 Subject: [PATCH 1/5] Contextually type initializers of binding elements Previously they were not contextually typed, which meant that lambdas got completely incorrect types, and that types that rely on contextual typing, like tuples and string literal types, did not work correctly. --- src/compiler/checker.ts | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index c2a14e5b9a0..03b74110962 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2604,7 +2604,7 @@ namespace ts { return name.kind === SyntaxKind.ComputedPropertyName && !isStringOrNumericLiteral((name).expression.kind); } - // Return the inferred type for a binding element + /** Return the inferred type for a binding element */ function getTypeForBindingElement(declaration: BindingElement): Type { const pattern = declaration.parent; const parentType = getTypeForBindingElementParent(pattern.parent); @@ -2630,6 +2630,9 @@ namespace ts { // computed properties with non-literal names are treated as 'any' return anyType; } + if (declaration.initializer) { + getContextualType(declaration.initializer); + } // Use type of the specified property, or otherwise, for a numeric name, the type of the numeric index signature, // or otherwise the type of the string index signature. @@ -7825,11 +7828,14 @@ namespace ts { return undefined; } - // In a variable, parameter or property declaration with a type annotation, the contextual type of an initializer - // expression is the type of the variable, parameter or property. Otherwise, in a parameter declaration of a - // contextually typed function expression, the contextual type of an initializer expression is the contextual type - // of the parameter. Otherwise, in a variable or parameter declaration with a binding pattern name, the contextual - // type of an initializer expression is the type implied by the binding pattern. + // In a variable, parameter or property declaration with a type annotation, + // the contextual type of an initializer expression is the type of the variable, parameter or property. + // Otherwise, in a parameter declaration of a contextually typed function expression, + // the contextual type of an initializer expression is the contextual type of the parameter. + // Otherwise, in a variable or parameter declaration with a binding pattern name, + // the contextual type of an initializer expression is the type implied by the binding pattern. + // Otherwise, in a binding pattern inside a variable or parameter declaration, + // the contextual type of an initializer expression is the type annotation of the containing declaration, if present. function getContextualTypeForInitializerExpression(node: Expression): Type { const declaration = node.parent; if (node === declaration.initializer) { @@ -7845,6 +7851,16 @@ namespace ts { if (isBindingPattern(declaration.name)) { return getTypeFromBindingPattern(declaration.name, /*includePatternInType*/ true); } + if (isBindingPattern(declaration.parent)) { + const parentDeclaration = declaration.parent.parent; + const name = declaration.propertyName || declaration.name; + if (isVariableLike(parentDeclaration) && + parentDeclaration.type && + (name.kind === SyntaxKind.Identifier || name.kind == SyntaxKind.StringLiteral)) { + const text = (name).text; + return getTypeOfPropertyOfType(getTypeFromTypeNode(parentDeclaration.type), text); + } + } } return undefined; } From 0d372413948391409abe28c9846ac9c1eb63f5c8 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Mon, 29 Feb 2016 10:15:23 -0800 Subject: [PATCH 2/5] Add test cases and baselines. --- .../contextuallyTypedBindingInitializer.js | 41 +++++++++ ...ontextuallyTypedBindingInitializer.symbols | 73 ++++++++++++++++ .../contextuallyTypedBindingInitializer.types | 85 +++++++++++++++++++ ...TypedBindingInitializerNegative.errors.txt | 59 +++++++++++++ ...extuallyTypedBindingInitializerNegative.js | 41 +++++++++ .../contextuallyTypedBindingInitializer.ts | 25 ++++++ ...extuallyTypedBindingInitializerNegative.ts | 25 ++++++ 7 files changed, 349 insertions(+) create mode 100644 tests/baselines/reference/contextuallyTypedBindingInitializer.js create mode 100644 tests/baselines/reference/contextuallyTypedBindingInitializer.symbols create mode 100644 tests/baselines/reference/contextuallyTypedBindingInitializer.types create mode 100644 tests/baselines/reference/contextuallyTypedBindingInitializerNegative.errors.txt create mode 100644 tests/baselines/reference/contextuallyTypedBindingInitializerNegative.js create mode 100644 tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializer.ts create mode 100644 tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts diff --git a/tests/baselines/reference/contextuallyTypedBindingInitializer.js b/tests/baselines/reference/contextuallyTypedBindingInitializer.js new file mode 100644 index 00000000000..771e83812a5 --- /dev/null +++ b/tests/baselines/reference/contextuallyTypedBindingInitializer.js @@ -0,0 +1,41 @@ +//// [contextuallyTypedBindingInitializer.ts] +interface Show { + show: (x: number) => string; +} +function f({ show = v => v.toString() }: Show) {} + +interface Nested { + nested: Show +} +function ff({ nested = { show: v => v.toString() } }: Nested) {} + +interface Tuples { + prop: [string, number]; +} +function g({ prop = ["hello", 1234] }: Tuples) {} + +interface StringUnion { + prop: "foo" | "bar"; +} +function h({ prop = "foo" }: StringUnion) {} + +interface StringIdentity { + stringIdentity(s: string): string; +} +let { stringIdentity: id = arg => arg }: StringIdentity = { stringIdentity: x => x}; + + +//// [contextuallyTypedBindingInitializer.js] +function f(_a) { + var _b = _a.show, show = _b === void 0 ? function (v) { return v.toString(); } : _b; +} +function ff(_a) { + var _b = _a.nested, nested = _b === void 0 ? { show: function (v) { return v.toString(); } } : _b; +} +function g(_a) { + var _b = _a.prop, prop = _b === void 0 ? ["hello", 1234] : _b; +} +function h(_a) { + var _b = _a.prop, prop = _b === void 0 ? "foo" : _b; +} +var _a = { stringIdentity: function (x) { return x; } }.stringIdentity, id = _a === void 0 ? function (arg) { return arg; } : _a; diff --git a/tests/baselines/reference/contextuallyTypedBindingInitializer.symbols b/tests/baselines/reference/contextuallyTypedBindingInitializer.symbols new file mode 100644 index 00000000000..22e1e031a0f --- /dev/null +++ b/tests/baselines/reference/contextuallyTypedBindingInitializer.symbols @@ -0,0 +1,73 @@ +=== tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializer.ts === +interface Show { +>Show : Symbol(Show, Decl(contextuallyTypedBindingInitializer.ts, 0, 0)) + + show: (x: number) => string; +>show : Symbol(show, Decl(contextuallyTypedBindingInitializer.ts, 0, 16)) +>x : Symbol(x, Decl(contextuallyTypedBindingInitializer.ts, 1, 11)) +} +function f({ show = v => v.toString() }: Show) {} +>f : Symbol(f, Decl(contextuallyTypedBindingInitializer.ts, 2, 1)) +>show : Symbol(show, Decl(contextuallyTypedBindingInitializer.ts, 3, 12)) +>v : Symbol(v, Decl(contextuallyTypedBindingInitializer.ts, 3, 19)) +>v.toString : Symbol(Number.toString, Decl(lib.d.ts, --, --)) +>v : Symbol(v, Decl(contextuallyTypedBindingInitializer.ts, 3, 19)) +>toString : Symbol(Number.toString, Decl(lib.d.ts, --, --)) +>Show : Symbol(Show, Decl(contextuallyTypedBindingInitializer.ts, 0, 0)) + +interface Nested { +>Nested : Symbol(Nested, Decl(contextuallyTypedBindingInitializer.ts, 3, 49)) + + nested: Show +>nested : Symbol(nested, Decl(contextuallyTypedBindingInitializer.ts, 5, 18)) +>Show : Symbol(Show, Decl(contextuallyTypedBindingInitializer.ts, 0, 0)) +} +function ff({ nested = { show: v => v.toString() } }: Nested) {} +>ff : Symbol(ff, Decl(contextuallyTypedBindingInitializer.ts, 7, 1)) +>nested : Symbol(nested, Decl(contextuallyTypedBindingInitializer.ts, 8, 13)) +>show : Symbol(show, Decl(contextuallyTypedBindingInitializer.ts, 8, 24)) +>v : Symbol(v, Decl(contextuallyTypedBindingInitializer.ts, 8, 30)) +>v.toString : Symbol(Number.toString, Decl(lib.d.ts, --, --)) +>v : Symbol(v, Decl(contextuallyTypedBindingInitializer.ts, 8, 30)) +>toString : Symbol(Number.toString, Decl(lib.d.ts, --, --)) +>Nested : Symbol(Nested, Decl(contextuallyTypedBindingInitializer.ts, 3, 49)) + +interface Tuples { +>Tuples : Symbol(Tuples, Decl(contextuallyTypedBindingInitializer.ts, 8, 64)) + + prop: [string, number]; +>prop : Symbol(prop, Decl(contextuallyTypedBindingInitializer.ts, 10, 18)) +} +function g({ prop = ["hello", 1234] }: Tuples) {} +>g : Symbol(g, Decl(contextuallyTypedBindingInitializer.ts, 12, 1)) +>prop : Symbol(prop, Decl(contextuallyTypedBindingInitializer.ts, 13, 12)) +>Tuples : Symbol(Tuples, Decl(contextuallyTypedBindingInitializer.ts, 8, 64)) + +interface StringUnion { +>StringUnion : Symbol(StringUnion, Decl(contextuallyTypedBindingInitializer.ts, 13, 49)) + + prop: "foo" | "bar"; +>prop : Symbol(prop, Decl(contextuallyTypedBindingInitializer.ts, 15, 23)) +} +function h({ prop = "foo" }: StringUnion) {} +>h : Symbol(h, Decl(contextuallyTypedBindingInitializer.ts, 17, 1)) +>prop : Symbol(prop, Decl(contextuallyTypedBindingInitializer.ts, 18, 12)) +>StringUnion : Symbol(StringUnion, Decl(contextuallyTypedBindingInitializer.ts, 13, 49)) + +interface StringIdentity { +>StringIdentity : Symbol(StringIdentity, Decl(contextuallyTypedBindingInitializer.ts, 18, 44)) + + stringIdentity(s: string): string; +>stringIdentity : Symbol(stringIdentity, Decl(contextuallyTypedBindingInitializer.ts, 20, 26)) +>s : Symbol(s, Decl(contextuallyTypedBindingInitializer.ts, 21, 19)) +} +let { stringIdentity: id = arg => arg }: StringIdentity = { stringIdentity: x => x}; +>stringIdentity : Symbol(StringIdentity.stringIdentity, Decl(contextuallyTypedBindingInitializer.ts, 20, 26)) +>id : Symbol(id, Decl(contextuallyTypedBindingInitializer.ts, 23, 5)) +>arg : Symbol(arg, Decl(contextuallyTypedBindingInitializer.ts, 23, 26)) +>arg : Symbol(arg, Decl(contextuallyTypedBindingInitializer.ts, 23, 26)) +>StringIdentity : Symbol(StringIdentity, Decl(contextuallyTypedBindingInitializer.ts, 18, 44)) +>stringIdentity : Symbol(stringIdentity, Decl(contextuallyTypedBindingInitializer.ts, 23, 59)) +>x : Symbol(x, Decl(contextuallyTypedBindingInitializer.ts, 23, 75)) +>x : Symbol(x, Decl(contextuallyTypedBindingInitializer.ts, 23, 75)) + diff --git a/tests/baselines/reference/contextuallyTypedBindingInitializer.types b/tests/baselines/reference/contextuallyTypedBindingInitializer.types new file mode 100644 index 00000000000..991a0fec2ec --- /dev/null +++ b/tests/baselines/reference/contextuallyTypedBindingInitializer.types @@ -0,0 +1,85 @@ +=== tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializer.ts === +interface Show { +>Show : Show + + show: (x: number) => string; +>show : (x: number) => string +>x : number +} +function f({ show = v => v.toString() }: Show) {} +>f : ({ show = v => v.toString() }: Show) => void +>show : (x: number) => string +>v => v.toString() : (v: number) => string +>v : number +>v.toString() : string +>v.toString : (radix?: number) => string +>v : number +>toString : (radix?: number) => string +>Show : Show + +interface Nested { +>Nested : Nested + + nested: Show +>nested : Show +>Show : Show +} +function ff({ nested = { show: v => v.toString() } }: Nested) {} +>ff : ({ nested = { show: v => v.toString() } }: Nested) => void +>nested : Show +>{ show: v => v.toString() } : { show: (v: number) => string; } +>show : (v: number) => string +>v => v.toString() : (v: number) => string +>v : number +>v.toString() : string +>v.toString : (radix?: number) => string +>v : number +>toString : (radix?: number) => string +>Nested : Nested + +interface Tuples { +>Tuples : Tuples + + prop: [string, number]; +>prop : [string, number] +} +function g({ prop = ["hello", 1234] }: Tuples) {} +>g : ({ prop = ["hello", 1234] }: Tuples) => void +>prop : [string, number] +>["hello", 1234] : [string, number] +>"hello" : string +>1234 : number +>Tuples : Tuples + +interface StringUnion { +>StringUnion : StringUnion + + prop: "foo" | "bar"; +>prop : "foo" | "bar" +} +function h({ prop = "foo" }: StringUnion) {} +>h : ({ prop = "foo" }: StringUnion) => void +>prop : "foo" | "bar" +>"foo" : "foo" +>StringUnion : StringUnion + +interface StringIdentity { +>StringIdentity : StringIdentity + + stringIdentity(s: string): string; +>stringIdentity : (s: string) => string +>s : string +} +let { stringIdentity: id = arg => arg }: StringIdentity = { stringIdentity: x => x}; +>stringIdentity : any +>id : (s: string) => string +>arg => arg : (arg: string) => string +>arg : string +>arg : string +>StringIdentity : StringIdentity +>{ stringIdentity: x => x} : { stringIdentity: (x: string) => string; } +>stringIdentity : (x: string) => string +>x => x : (x: string) => string +>x : string +>x : string + diff --git a/tests/baselines/reference/contextuallyTypedBindingInitializerNegative.errors.txt b/tests/baselines/reference/contextuallyTypedBindingInitializerNegative.errors.txt new file mode 100644 index 00000000000..604113183b7 --- /dev/null +++ b/tests/baselines/reference/contextuallyTypedBindingInitializerNegative.errors.txt @@ -0,0 +1,59 @@ +tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts(4,20): error TS2322: Type '(v: number) => number' is not assignable to type '(x: number) => string'. + Type 'number' is not assignable to type 'string'. +tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts(9,23): error TS2322: Type '{ show: (v: number) => number; }' is not assignable to type 'Show'. + Types of property 'show' are incompatible. + Type '(v: number) => number' is not assignable to type '(x: number) => string'. + Type 'number' is not assignable to type 'string'. +tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts(14,23): error TS2322: Type '(arg: string) => number' is not assignable to type '(s: string) => string'. + Type 'number' is not assignable to type 'string'. +tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts(19,14): error TS2322: Type '[number, number]' is not assignable to type '[string, number]'. + Types of property '0' are incompatible. + Type 'number' is not assignable to type 'string'. +tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts(24,14): error TS2322: Type '"baz"' is not assignable to type '"foo" | "bar"'. + Type '"baz"' is not assignable to type '"bar"'. + + +==== tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts (5 errors) ==== + interface Show { + show: (x: number) => string; + } + function f({ show: showRename = v => v }: Show) {} + ~~~~~~~~~~ +!!! error TS2322: Type '(v: number) => number' is not assignable to type '(x: number) => string'. +!!! error TS2322: Type 'number' is not assignable to type 'string'. + + interface Nested { + nested: Show + } + function ff({ nested: nestedRename = { show: v => v } }: Nested) {} + ~~~~~~~~~~~~ +!!! error TS2322: Type '{ show: (v: number) => number; }' is not assignable to type 'Show'. +!!! error TS2322: Types of property 'show' are incompatible. +!!! error TS2322: Type '(v: number) => number' is not assignable to type '(x: number) => string'. +!!! error TS2322: Type 'number' is not assignable to type 'string'. + + interface StringIdentity { + stringIdentity(s: string): string; + } + let { stringIdentity: id = arg => arg.length }: StringIdentity = { stringIdentity: x => x}; + ~~ +!!! error TS2322: Type '(arg: string) => number' is not assignable to type '(s: string) => string'. +!!! error TS2322: Type 'number' is not assignable to type 'string'. + + interface Tuples { + prop: [string, number]; + } + function g({ prop = [101, 1234] }: Tuples) {} + ~~~~ +!!! error TS2322: Type '[number, number]' is not assignable to type '[string, number]'. +!!! error TS2322: Types of property '0' are incompatible. +!!! error TS2322: Type 'number' is not assignable to type 'string'. + + interface StringUnion { + prop: "foo" | "bar"; + } + function h({ prop = "baz" }: StringUnion) {} + ~~~~ +!!! error TS2322: Type '"baz"' is not assignable to type '"foo" | "bar"'. +!!! error TS2322: Type '"baz"' is not assignable to type '"bar"'. + \ No newline at end of file diff --git a/tests/baselines/reference/contextuallyTypedBindingInitializerNegative.js b/tests/baselines/reference/contextuallyTypedBindingInitializerNegative.js new file mode 100644 index 00000000000..77249a4ae50 --- /dev/null +++ b/tests/baselines/reference/contextuallyTypedBindingInitializerNegative.js @@ -0,0 +1,41 @@ +//// [contextuallyTypedBindingInitializerNegative.ts] +interface Show { + show: (x: number) => string; +} +function f({ show: showRename = v => v }: Show) {} + +interface Nested { + nested: Show +} +function ff({ nested: nestedRename = { show: v => v } }: Nested) {} + +interface StringIdentity { + stringIdentity(s: string): string; +} +let { stringIdentity: id = arg => arg.length }: StringIdentity = { stringIdentity: x => x}; + +interface Tuples { + prop: [string, number]; +} +function g({ prop = [101, 1234] }: Tuples) {} + +interface StringUnion { + prop: "foo" | "bar"; +} +function h({ prop = "baz" }: StringUnion) {} + + +//// [contextuallyTypedBindingInitializerNegative.js] +function f(_a) { + var _b = _a.show, showRename = _b === void 0 ? function (v) { return v; } : _b; +} +function ff(_a) { + var _b = _a.nested, nestedRename = _b === void 0 ? { show: function (v) { return v; } } : _b; +} +var _a = { stringIdentity: function (x) { return x; } }.stringIdentity, id = _a === void 0 ? function (arg) { return arg.length; } : _a; +function g(_a) { + var _b = _a.prop, prop = _b === void 0 ? [101, 1234] : _b; +} +function h(_a) { + var _b = _a.prop, prop = _b === void 0 ? "baz" : _b; +} diff --git a/tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializer.ts b/tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializer.ts new file mode 100644 index 00000000000..b135c35e1a2 --- /dev/null +++ b/tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializer.ts @@ -0,0 +1,25 @@ +// @noImplicitAny: true +interface Show { + show: (x: number) => string; +} +function f({ show = v => v.toString() }: Show) {} + +interface Nested { + nested: Show +} +function ff({ nested = { show: v => v.toString() } }: Nested) {} + +interface Tuples { + prop: [string, number]; +} +function g({ prop = ["hello", 1234] }: Tuples) {} + +interface StringUnion { + prop: "foo" | "bar"; +} +function h({ prop = "foo" }: StringUnion) {} + +interface StringIdentity { + stringIdentity(s: string): string; +} +let { stringIdentity: id = arg => arg }: StringIdentity = { stringIdentity: x => x}; diff --git a/tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts b/tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts new file mode 100644 index 00000000000..b1c4a0f4273 --- /dev/null +++ b/tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts @@ -0,0 +1,25 @@ +// @noImplicitAny: true +interface Show { + show: (x: number) => string; +} +function f({ show: showRename = v => v }: Show) {} + +interface Nested { + nested: Show +} +function ff({ nested: nestedRename = { show: v => v } }: Nested) {} + +interface StringIdentity { + stringIdentity(s: string): string; +} +let { stringIdentity: id = arg => arg.length }: StringIdentity = { stringIdentity: x => x}; + +interface Tuples { + prop: [string, number]; +} +function g({ prop = [101, 1234] }: Tuples) {} + +interface StringUnion { + prop: "foo" | "bar"; +} +function h({ prop = "baz" }: StringUnion) {} From 70e9e0974a56dadaa6f21cfacf7a8196545c7f14 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Mon, 29 Feb 2016 11:04:10 -0800 Subject: [PATCH 3/5] Update baselines after merging with master --- .../reference/contextuallyTypedBindingInitializer.types | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/baselines/reference/contextuallyTypedBindingInitializer.types b/tests/baselines/reference/contextuallyTypedBindingInitializer.types index 991a0fec2ec..25402623510 100644 --- a/tests/baselines/reference/contextuallyTypedBindingInitializer.types +++ b/tests/baselines/reference/contextuallyTypedBindingInitializer.types @@ -7,7 +7,7 @@ interface Show { >x : number } function f({ show = v => v.toString() }: Show) {} ->f : ({ show = v => v.toString() }: Show) => void +>f : ({show}: Show) => void >show : (x: number) => string >v => v.toString() : (v: number) => string >v : number @@ -25,7 +25,7 @@ interface Nested { >Show : Show } function ff({ nested = { show: v => v.toString() } }: Nested) {} ->ff : ({ nested = { show: v => v.toString() } }: Nested) => void +>ff : ({nested}: Nested) => void >nested : Show >{ show: v => v.toString() } : { show: (v: number) => string; } >show : (v: number) => string @@ -44,7 +44,7 @@ interface Tuples { >prop : [string, number] } function g({ prop = ["hello", 1234] }: Tuples) {} ->g : ({ prop = ["hello", 1234] }: Tuples) => void +>g : ({prop}: Tuples) => void >prop : [string, number] >["hello", 1234] : [string, number] >"hello" : string @@ -58,7 +58,7 @@ interface StringUnion { >prop : "foo" | "bar" } function h({ prop = "foo" }: StringUnion) {} ->h : ({ prop = "foo" }: StringUnion) => void +>h : ({prop}: StringUnion) => void >prop : "foo" | "bar" >"foo" : "foo" >StringUnion : StringUnion From 42cc5656806c6229abbccadabd1e5ea24f70ab1d Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Mon, 29 Feb 2016 13:09:23 -0800 Subject: [PATCH 4/5] Support string literals+computed property names With tests and associated baseline updates --- src/compiler/checker.ts | 8 +- .../contextuallyTypedBindingInitializer.js | 10 + ...ontextuallyTypedBindingInitializer.symbols | 78 +++-- .../contextuallyTypedBindingInitializer.types | 25 ++ ...TypedBindingInitializerNegative.errors.txt | 22 +- ...extuallyTypedBindingInitializerNegative.js | 8 + .../contextuallyTypedBindingInitializer.ts | 4 + ...extuallyTypedBindingInitializerNegative.ts | 2 + tests/webTestServer.js | 288 ++++++++++++++++++ tests/webTestServer.js.map | 1 + 10 files changed, 409 insertions(+), 37 deletions(-) create mode 100644 tests/webTestServer.js create mode 100644 tests/webTestServer.js.map diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 03b74110962..0b8208621f5 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7856,9 +7856,11 @@ namespace ts { const name = declaration.propertyName || declaration.name; if (isVariableLike(parentDeclaration) && parentDeclaration.type && - (name.kind === SyntaxKind.Identifier || name.kind == SyntaxKind.StringLiteral)) { - const text = (name).text; - return getTypeOfPropertyOfType(getTypeFromTypeNode(parentDeclaration.type), text); + !isBindingPattern(name)) { + const text = getTextOfPropertyName(name); + if (text) { + return getTypeOfPropertyOfType(getTypeFromTypeNode(parentDeclaration.type), text); + } } } } diff --git a/tests/baselines/reference/contextuallyTypedBindingInitializer.js b/tests/baselines/reference/contextuallyTypedBindingInitializer.js index 771e83812a5..f2424ce55d7 100644 --- a/tests/baselines/reference/contextuallyTypedBindingInitializer.js +++ b/tests/baselines/reference/contextuallyTypedBindingInitializer.js @@ -3,6 +3,8 @@ interface Show { show: (x: number) => string; } function f({ show = v => v.toString() }: Show) {} +function f2({ "show": showRename = v => v.toString() }: Show) {} +function f3({ ["show"]: showRename = v => v.toString() }: Show) {} interface Nested { nested: Show @@ -23,12 +25,20 @@ interface StringIdentity { stringIdentity(s: string): string; } let { stringIdentity: id = arg => arg }: StringIdentity = { stringIdentity: x => x}; + + //// [contextuallyTypedBindingInitializer.js] function f(_a) { var _b = _a.show, show = _b === void 0 ? function (v) { return v.toString(); } : _b; } +function f2(_a) { + var _b = _a["show"], showRename = _b === void 0 ? function (v) { return v.toString(); } : _b; +} +function f3(_a) { + var _b = "show", _c = _a[_b], showRename = _c === void 0 ? function (v) { return v.toString(); } : _c; +} function ff(_a) { var _b = _a.nested, nested = _b === void 0 ? { show: function (v) { return v.toString(); } } : _b; } diff --git a/tests/baselines/reference/contextuallyTypedBindingInitializer.symbols b/tests/baselines/reference/contextuallyTypedBindingInitializer.symbols index 22e1e031a0f..5530c958e91 100644 --- a/tests/baselines/reference/contextuallyTypedBindingInitializer.symbols +++ b/tests/baselines/reference/contextuallyTypedBindingInitializer.symbols @@ -15,59 +15,79 @@ function f({ show = v => v.toString() }: Show) {} >toString : Symbol(Number.toString, Decl(lib.d.ts, --, --)) >Show : Symbol(Show, Decl(contextuallyTypedBindingInitializer.ts, 0, 0)) +function f2({ "show": showRename = v => v.toString() }: Show) {} +>f2 : Symbol(f2, Decl(contextuallyTypedBindingInitializer.ts, 3, 49)) +>showRename : Symbol(showRename, Decl(contextuallyTypedBindingInitializer.ts, 4, 13)) +>v : Symbol(v, Decl(contextuallyTypedBindingInitializer.ts, 4, 34)) +>v.toString : Symbol(Number.toString, Decl(lib.d.ts, --, --)) +>v : Symbol(v, Decl(contextuallyTypedBindingInitializer.ts, 4, 34)) +>toString : Symbol(Number.toString, Decl(lib.d.ts, --, --)) +>Show : Symbol(Show, Decl(contextuallyTypedBindingInitializer.ts, 0, 0)) + +function f3({ ["show"]: showRename = v => v.toString() }: Show) {} +>f3 : Symbol(f3, Decl(contextuallyTypedBindingInitializer.ts, 4, 64)) +>showRename : Symbol(showRename, Decl(contextuallyTypedBindingInitializer.ts, 5, 13)) +>v : Symbol(v, Decl(contextuallyTypedBindingInitializer.ts, 5, 36)) +>v.toString : Symbol(Number.toString, Decl(lib.d.ts, --, --)) +>v : Symbol(v, Decl(contextuallyTypedBindingInitializer.ts, 5, 36)) +>toString : Symbol(Number.toString, Decl(lib.d.ts, --, --)) +>Show : Symbol(Show, Decl(contextuallyTypedBindingInitializer.ts, 0, 0)) + interface Nested { ->Nested : Symbol(Nested, Decl(contextuallyTypedBindingInitializer.ts, 3, 49)) +>Nested : Symbol(Nested, Decl(contextuallyTypedBindingInitializer.ts, 5, 66)) nested: Show ->nested : Symbol(nested, Decl(contextuallyTypedBindingInitializer.ts, 5, 18)) +>nested : Symbol(nested, Decl(contextuallyTypedBindingInitializer.ts, 7, 18)) >Show : Symbol(Show, Decl(contextuallyTypedBindingInitializer.ts, 0, 0)) } function ff({ nested = { show: v => v.toString() } }: Nested) {} ->ff : Symbol(ff, Decl(contextuallyTypedBindingInitializer.ts, 7, 1)) ->nested : Symbol(nested, Decl(contextuallyTypedBindingInitializer.ts, 8, 13)) ->show : Symbol(show, Decl(contextuallyTypedBindingInitializer.ts, 8, 24)) ->v : Symbol(v, Decl(contextuallyTypedBindingInitializer.ts, 8, 30)) +>ff : Symbol(ff, Decl(contextuallyTypedBindingInitializer.ts, 9, 1)) +>nested : Symbol(nested, Decl(contextuallyTypedBindingInitializer.ts, 10, 13)) +>show : Symbol(show, Decl(contextuallyTypedBindingInitializer.ts, 10, 24)) +>v : Symbol(v, Decl(contextuallyTypedBindingInitializer.ts, 10, 30)) >v.toString : Symbol(Number.toString, Decl(lib.d.ts, --, --)) ->v : Symbol(v, Decl(contextuallyTypedBindingInitializer.ts, 8, 30)) +>v : Symbol(v, Decl(contextuallyTypedBindingInitializer.ts, 10, 30)) >toString : Symbol(Number.toString, Decl(lib.d.ts, --, --)) ->Nested : Symbol(Nested, Decl(contextuallyTypedBindingInitializer.ts, 3, 49)) +>Nested : Symbol(Nested, Decl(contextuallyTypedBindingInitializer.ts, 5, 66)) interface Tuples { ->Tuples : Symbol(Tuples, Decl(contextuallyTypedBindingInitializer.ts, 8, 64)) +>Tuples : Symbol(Tuples, Decl(contextuallyTypedBindingInitializer.ts, 10, 64)) prop: [string, number]; ->prop : Symbol(prop, Decl(contextuallyTypedBindingInitializer.ts, 10, 18)) +>prop : Symbol(prop, Decl(contextuallyTypedBindingInitializer.ts, 12, 18)) } function g({ prop = ["hello", 1234] }: Tuples) {} ->g : Symbol(g, Decl(contextuallyTypedBindingInitializer.ts, 12, 1)) ->prop : Symbol(prop, Decl(contextuallyTypedBindingInitializer.ts, 13, 12)) ->Tuples : Symbol(Tuples, Decl(contextuallyTypedBindingInitializer.ts, 8, 64)) +>g : Symbol(g, Decl(contextuallyTypedBindingInitializer.ts, 14, 1)) +>prop : Symbol(prop, Decl(contextuallyTypedBindingInitializer.ts, 15, 12)) +>Tuples : Symbol(Tuples, Decl(contextuallyTypedBindingInitializer.ts, 10, 64)) interface StringUnion { ->StringUnion : Symbol(StringUnion, Decl(contextuallyTypedBindingInitializer.ts, 13, 49)) +>StringUnion : Symbol(StringUnion, Decl(contextuallyTypedBindingInitializer.ts, 15, 49)) prop: "foo" | "bar"; ->prop : Symbol(prop, Decl(contextuallyTypedBindingInitializer.ts, 15, 23)) +>prop : Symbol(prop, Decl(contextuallyTypedBindingInitializer.ts, 17, 23)) } function h({ prop = "foo" }: StringUnion) {} ->h : Symbol(h, Decl(contextuallyTypedBindingInitializer.ts, 17, 1)) ->prop : Symbol(prop, Decl(contextuallyTypedBindingInitializer.ts, 18, 12)) ->StringUnion : Symbol(StringUnion, Decl(contextuallyTypedBindingInitializer.ts, 13, 49)) +>h : Symbol(h, Decl(contextuallyTypedBindingInitializer.ts, 19, 1)) +>prop : Symbol(prop, Decl(contextuallyTypedBindingInitializer.ts, 20, 12)) +>StringUnion : Symbol(StringUnion, Decl(contextuallyTypedBindingInitializer.ts, 15, 49)) interface StringIdentity { ->StringIdentity : Symbol(StringIdentity, Decl(contextuallyTypedBindingInitializer.ts, 18, 44)) +>StringIdentity : Symbol(StringIdentity, Decl(contextuallyTypedBindingInitializer.ts, 20, 44)) stringIdentity(s: string): string; ->stringIdentity : Symbol(stringIdentity, Decl(contextuallyTypedBindingInitializer.ts, 20, 26)) ->s : Symbol(s, Decl(contextuallyTypedBindingInitializer.ts, 21, 19)) +>stringIdentity : Symbol(stringIdentity, Decl(contextuallyTypedBindingInitializer.ts, 22, 26)) +>s : Symbol(s, Decl(contextuallyTypedBindingInitializer.ts, 23, 19)) } let { stringIdentity: id = arg => arg }: StringIdentity = { stringIdentity: x => x}; ->stringIdentity : Symbol(StringIdentity.stringIdentity, Decl(contextuallyTypedBindingInitializer.ts, 20, 26)) ->id : Symbol(id, Decl(contextuallyTypedBindingInitializer.ts, 23, 5)) ->arg : Symbol(arg, Decl(contextuallyTypedBindingInitializer.ts, 23, 26)) ->arg : Symbol(arg, Decl(contextuallyTypedBindingInitializer.ts, 23, 26)) ->StringIdentity : Symbol(StringIdentity, Decl(contextuallyTypedBindingInitializer.ts, 18, 44)) ->stringIdentity : Symbol(stringIdentity, Decl(contextuallyTypedBindingInitializer.ts, 23, 59)) ->x : Symbol(x, Decl(contextuallyTypedBindingInitializer.ts, 23, 75)) ->x : Symbol(x, Decl(contextuallyTypedBindingInitializer.ts, 23, 75)) +>stringIdentity : Symbol(StringIdentity.stringIdentity, Decl(contextuallyTypedBindingInitializer.ts, 22, 26)) +>id : Symbol(id, Decl(contextuallyTypedBindingInitializer.ts, 25, 5)) +>arg : Symbol(arg, Decl(contextuallyTypedBindingInitializer.ts, 25, 26)) +>arg : Symbol(arg, Decl(contextuallyTypedBindingInitializer.ts, 25, 26)) +>StringIdentity : Symbol(StringIdentity, Decl(contextuallyTypedBindingInitializer.ts, 20, 44)) +>stringIdentity : Symbol(stringIdentity, Decl(contextuallyTypedBindingInitializer.ts, 25, 59)) +>x : Symbol(x, Decl(contextuallyTypedBindingInitializer.ts, 25, 75)) +>x : Symbol(x, Decl(contextuallyTypedBindingInitializer.ts, 25, 75)) + + diff --git a/tests/baselines/reference/contextuallyTypedBindingInitializer.types b/tests/baselines/reference/contextuallyTypedBindingInitializer.types index 25402623510..0d4dfcdd5d9 100644 --- a/tests/baselines/reference/contextuallyTypedBindingInitializer.types +++ b/tests/baselines/reference/contextuallyTypedBindingInitializer.types @@ -17,6 +17,29 @@ function f({ show = v => v.toString() }: Show) {} >toString : (radix?: number) => string >Show : Show +function f2({ "show": showRename = v => v.toString() }: Show) {} +>f2 : ({"show": showRename}: Show) => void +>showRename : (x: number) => string +>v => v.toString() : (v: number) => string +>v : number +>v.toString() : string +>v.toString : (radix?: number) => string +>v : number +>toString : (radix?: number) => string +>Show : Show + +function f3({ ["show"]: showRename = v => v.toString() }: Show) {} +>f3 : ({["show"]: showRename}: Show) => void +>"show" : string +>showRename : (x: number) => string +>v => v.toString() : (v: number) => string +>v : number +>v.toString() : string +>v.toString : (radix?: number) => string +>v : number +>toString : (radix?: number) => string +>Show : Show + interface Nested { >Nested : Nested @@ -83,3 +106,5 @@ let { stringIdentity: id = arg => arg }: StringIdentity = { stringIdentity: x => >x : string >x : string + + diff --git a/tests/baselines/reference/contextuallyTypedBindingInitializerNegative.errors.txt b/tests/baselines/reference/contextuallyTypedBindingInitializerNegative.errors.txt index 604113183b7..689645386c4 100644 --- a/tests/baselines/reference/contextuallyTypedBindingInitializerNegative.errors.txt +++ b/tests/baselines/reference/contextuallyTypedBindingInitializerNegative.errors.txt @@ -1,25 +1,37 @@ tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts(4,20): error TS2322: Type '(v: number) => number' is not assignable to type '(x: number) => string'. Type 'number' is not assignable to type 'string'. -tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts(9,23): error TS2322: Type '{ show: (v: number) => number; }' is not assignable to type 'Show'. +tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts(5,23): error TS2322: Type '(v: number) => number' is not assignable to type '(x: number) => string'. + Type 'number' is not assignable to type 'string'. +tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts(6,25): error TS2322: Type '(v: number) => number' is not assignable to type '(x: number) => string'. + Type 'number' is not assignable to type 'string'. +tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts(11,23): error TS2322: Type '{ show: (v: number) => number; }' is not assignable to type 'Show'. Types of property 'show' are incompatible. Type '(v: number) => number' is not assignable to type '(x: number) => string'. Type 'number' is not assignable to type 'string'. -tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts(14,23): error TS2322: Type '(arg: string) => number' is not assignable to type '(s: string) => string'. +tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts(16,23): error TS2322: Type '(arg: string) => number' is not assignable to type '(s: string) => string'. Type 'number' is not assignable to type 'string'. -tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts(19,14): error TS2322: Type '[number, number]' is not assignable to type '[string, number]'. +tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts(21,14): error TS2322: Type '[number, number]' is not assignable to type '[string, number]'. Types of property '0' are incompatible. Type 'number' is not assignable to type 'string'. -tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts(24,14): error TS2322: Type '"baz"' is not assignable to type '"foo" | "bar"'. +tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts(26,14): error TS2322: Type '"baz"' is not assignable to type '"foo" | "bar"'. Type '"baz"' is not assignable to type '"bar"'. -==== tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts (5 errors) ==== +==== tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts (7 errors) ==== interface Show { show: (x: number) => string; } function f({ show: showRename = v => v }: Show) {} ~~~~~~~~~~ !!! error TS2322: Type '(v: number) => number' is not assignable to type '(x: number) => string'. +!!! error TS2322: Type 'number' is not assignable to type 'string'. + function f2({ "show": showRename = v => v }: Show) {} + ~~~~~~~~~~ +!!! error TS2322: Type '(v: number) => number' is not assignable to type '(x: number) => string'. +!!! error TS2322: Type 'number' is not assignable to type 'string'. + function f3({ ["show"]: showRename = v => v }: Show) {} + ~~~~~~~~~~ +!!! error TS2322: Type '(v: number) => number' is not assignable to type '(x: number) => string'. !!! error TS2322: Type 'number' is not assignable to type 'string'. interface Nested { diff --git a/tests/baselines/reference/contextuallyTypedBindingInitializerNegative.js b/tests/baselines/reference/contextuallyTypedBindingInitializerNegative.js index 77249a4ae50..3f1ed156fdb 100644 --- a/tests/baselines/reference/contextuallyTypedBindingInitializerNegative.js +++ b/tests/baselines/reference/contextuallyTypedBindingInitializerNegative.js @@ -3,6 +3,8 @@ interface Show { show: (x: number) => string; } function f({ show: showRename = v => v }: Show) {} +function f2({ "show": showRename = v => v }: Show) {} +function f3({ ["show"]: showRename = v => v }: Show) {} interface Nested { nested: Show @@ -29,6 +31,12 @@ function h({ prop = "baz" }: StringUnion) {} function f(_a) { var _b = _a.show, showRename = _b === void 0 ? function (v) { return v; } : _b; } +function f2(_a) { + var _b = _a["show"], showRename = _b === void 0 ? function (v) { return v; } : _b; +} +function f3(_a) { + var _b = "show", _c = _a[_b], showRename = _c === void 0 ? function (v) { return v; } : _c; +} function ff(_a) { var _b = _a.nested, nestedRename = _b === void 0 ? { show: function (v) { return v; } } : _b; } diff --git a/tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializer.ts b/tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializer.ts index b135c35e1a2..c02aa5b63e8 100644 --- a/tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializer.ts +++ b/tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializer.ts @@ -3,6 +3,8 @@ interface Show { show: (x: number) => string; } function f({ show = v => v.toString() }: Show) {} +function f2({ "show": showRename = v => v.toString() }: Show) {} +function f3({ ["show"]: showRename = v => v.toString() }: Show) {} interface Nested { nested: Show @@ -23,3 +25,5 @@ interface StringIdentity { stringIdentity(s: string): string; } let { stringIdentity: id = arg => arg }: StringIdentity = { stringIdentity: x => x}; + + diff --git a/tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts b/tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts index b1c4a0f4273..fb71da7b655 100644 --- a/tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts +++ b/tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts @@ -3,6 +3,8 @@ interface Show { show: (x: number) => string; } function f({ show: showRename = v => v }: Show) {} +function f2({ "show": showRename = v => v }: Show) {} +function f3({ ["show"]: showRename = v => v }: Show) {} interface Nested { nested: Show diff --git a/tests/webTestServer.js b/tests/webTestServer.js new file mode 100644 index 00000000000..d2ea8734328 --- /dev/null +++ b/tests/webTestServer.js @@ -0,0 +1,288 @@ +/// +"use strict"; +var http = require("http"); +var fs = require("fs"); +var path = require("path"); +var url = require("url"); +var child_process = require("child_process"); +var os = require("os"); +/// Command line processing /// +if (process.argv[2] == '--help') { + console.log('Runs a node server on port 8888 by default, looking for tests folder in the current directory\n'); + console.log('Syntax: node nodeServer.js [port] [typescriptEnlistmentDirectory] [tests] [--browser] [--verbose]\n'); + console.log('Examples: \n\tnode nodeServer.js 8888 .'); + console.log('\tnode nodeServer.js 3000 D:/src/typescript/public --verbose IE'); +} +function switchToForwardSlashes(path) { + return path.replace(/\\/g, "/").replace(/\/\//g, '/'); +} +var defaultPort = 8888; +var port = process.argv[2] || defaultPort; +var rootDir = switchToForwardSlashes(__dirname + '/../'); +var browser; +if (process.argv[3]) { + browser = process.argv[3]; + if (browser !== 'chrome' && browser !== 'IE') { + console.log('Invalid command line arguments. Got ' + browser + ' but expected chrome, IE or nothing.'); + } +} +var grep = process.argv[4]; +var verbose = false; +if (process.argv[5] == '--verbose') { + verbose = true; +} +else if (process.argv[5] && process.argv[5] !== '--verbose') { + console.log('Invalid command line arguments. Got ' + process.argv[5] + ' but expected --verbose or nothing.'); +} +/// Utils /// +function log(msg) { + if (verbose) { + console.log(msg); + } +} +// Copied from the compiler sources +function dir(path, spec, options) { + options = options || {}; + function filesInFolder(folder) { + var folder = switchToForwardSlashes(folder); + var paths = []; + // Everything after the current directory is relative + var baseDirectoryLength = process.cwd().length + 1; + try { + var files = fs.readdirSync(folder); + for (var i = 0; i < files.length; i++) { + var stat = fs.statSync(folder + "/" + files[i]); + if (options.recursive && stat.isDirectory()) { + paths = paths.concat(filesInFolder(folder + "/" + files[i])); + } + else if (stat.isFile() && (!spec || files[i].match(spec))) { + var relativePath = folder.substring(baseDirectoryLength); + paths.push(relativePath + "/" + files[i]); + } + } + } + catch (err) { + } + return paths; + } + return filesInFolder(path); +} +// fs.rmdirSync won't delete directories with files in it +function deleteFolderRecursive(path) { + if (fs.existsSync(path)) { + fs.readdirSync(path).forEach(function (file, index) { + var curPath = path + "/" + file; + if (fs.statSync(curPath).isDirectory()) { + deleteFolderRecursive(curPath); + } + else { + fs.unlinkSync(curPath); + } + }); + fs.rmdirSync(path); + } +} +; +function writeFile(path, data, opts) { + try { + fs.writeFileSync(path, data); + } + catch (e) { + // assume file was written to a directory that exists, if not, start recursively creating them as necessary + var parts = switchToForwardSlashes(path).split('/'); + for (var i = 0; i < parts.length; i++) { + var subDir = parts.slice(0, i).join('/'); + if (!fs.existsSync(subDir)) { + fs.mkdir(subDir); + } + } + fs.writeFileSync(path, data); + } +} +/// Request Handling /// +function handleResolutionRequest(filePath, res) { + var resolvedPath = path.resolve(filePath, ''); + resolvedPath = resolvedPath.substring(resolvedPath.indexOf('tests')); + resolvedPath = switchToForwardSlashes(resolvedPath); + send('success', res, resolvedPath); + return; +} +function send(result, res, contents, contentType) { + if (contentType === void 0) { contentType = "binary"; } + var responseCode = result === "success" ? 200 : result === "fail" ? 500 : result === 'unknown' ? 404 : parseInt(result); + res.writeHead(responseCode, { "Content-Type": contentType }); + res.end(contents); + return; +} +// Reads the data from a post request and passes it to the given callback +function processPost(req, res, callback) { + var queryData = ""; + if (typeof callback !== 'function') + return null; + if (req.method == 'POST') { + req.on('data', function (data) { + queryData += data; + if (queryData.length > 1e8) { + queryData = ""; + send("413", res, null); + console.log("ERROR: destroying connection"); + req.connection.destroy(); + } + }); + req.on('end', function () { + //res.post = url.parse(req.url).query; + callback(queryData); + }); + } + else { + send("405", res, null); + } +} +var RequestType; +(function (RequestType) { + RequestType[RequestType["GetFile"] = 0] = "GetFile"; + RequestType[RequestType["GetDir"] = 1] = "GetDir"; + RequestType[RequestType["ResolveFile"] = 2] = "ResolveFile"; + RequestType[RequestType["WriteFile"] = 3] = "WriteFile"; + RequestType[RequestType["DeleteFile"] = 4] = "DeleteFile"; + RequestType[RequestType["WriteDir"] = 5] = "WriteDir"; + RequestType[RequestType["DeleteDir"] = 6] = "DeleteDir"; + RequestType[RequestType["AppendFile"] = 7] = "AppendFile"; + RequestType[RequestType["Unknown"] = 8] = "Unknown"; +})(RequestType || (RequestType = {})); +function getRequestOperation(req, filename) { + if (req.method === 'GET' && req.url.indexOf('?') === -1) { + if (req.url.indexOf('.') !== -1) + return RequestType.GetFile; + else + return RequestType.GetDir; + } + else { + var queryData = url.parse(req.url, true).query; + if (req.method === 'GET' && queryData.resolve !== undefined) + return RequestType.ResolveFile; + // mocha uses ?grep= query string as equivalent to the --grep command line option used to filter tests + if (req.method === 'GET' && queryData.grep !== undefined) + return RequestType.GetFile; + if (req.method === 'POST' && queryData.action) { + var path = req.url.substr(0, req.url.lastIndexOf('?')); + var isFile = path.substring(path.lastIndexOf('/')).indexOf('.') !== -1; + switch (queryData.action.toUpperCase()) { + case 'WRITE': + return isFile ? RequestType.WriteFile : RequestType.WriteDir; + case 'DELETE': + return isFile ? RequestType.DeleteFile : RequestType.DeleteDir; + case 'APPEND': + return isFile ? RequestType.AppendFile : RequestType.Unknown; + } + } + return RequestType.Unknown; + } +} +function handleRequestOperation(req, res, operation, reqPath) { + switch (operation) { + case RequestType.GetDir: + var filesInFolder = dir(reqPath, "", { recursive: true }); + send('success', res, filesInFolder.join(',')); + break; + case RequestType.GetFile: + fs.readFile(reqPath, function (err, file) { + var ext = reqPath.substr(reqPath.lastIndexOf('.')); + var contentType = 'binary'; + if (ext === '.js') + contentType = 'text/javascript'; + else if (ext === '.css') + contentType = 'text/javascript'; + else if (ext === '.html') + contentType = 'text/html'; + err + ? send('fail', res, err.message, contentType) + : send('success', res, file, contentType); + }); + break; + case RequestType.ResolveFile: + var resolveRequest = req.url.match(/(.*)\?resolve/); + handleResolutionRequest(resolveRequest[1], res); + break; + case RequestType.WriteFile: + processPost(req, res, function (data) { + writeFile(reqPath, data, { recursive: true }); + }); + send('success', res, null); + break; + case RequestType.WriteDir: + fs.mkdirSync(reqPath); + send('success', res, null); + break; + case RequestType.DeleteFile: + if (fs.existsSync(reqPath)) { + fs.unlinkSync(reqPath); + } + send('success', res, null); + break; + case RequestType.DeleteDir: + if (fs.existsSync(reqPath)) { + fs.rmdirSync(reqPath); + } + send('success', res, null); + break; + case RequestType.AppendFile: + processPost(req, res, function (data) { + fs.appendFileSync(reqPath, data); + }); + send('success', res, null); + break; + case RequestType.Unknown: + default: + send('unknown', res, null); + break; + } +} +console.log("Static file server running at\n => http://localhost:" + port + "/\nCTRL + C to shutdown"); +http.createServer(function (req, res) { + log(req.method + ' ' + req.url); + var uri = url.parse(req.url).pathname; + var reqPath = path.join(process.cwd(), uri); + var operation = getRequestOperation(req, reqPath); + handleRequestOperation(req, res, operation, reqPath); +}).listen(8888); +var browserPath; +if ((browser && browser === 'chrome')) { + var defaultChromePath = ""; + switch (os.platform()) { + case "win32": + case "win64": + defaultChromePath = "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe"; + break; + case "darwin": + defaultChromePath = "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"; + break; + case "linux": + defaultChromePath = "/opt/google/chrome/chrome"; + break; + default: + console.log("default Chrome location is unknown for platform '" + os.platform() + "'"); + break; + } + if (fs.existsSync(defaultChromePath)) { + browserPath = defaultChromePath; + } + else { + browserPath = browser; + } +} +else { + var defaultIEPath = 'C:/Program Files/Internet Explorer/iexplore.exe'; + if (fs.existsSync(defaultIEPath)) { + browserPath = defaultIEPath; + } + else { + browserPath = browser; + } +} +console.log('Using browser: ' + browserPath); +var queryString = grep ? "?grep=" + grep : ''; +child_process.spawn(browserPath, ['http://localhost:' + port + '/tests/webTestResults.html' + queryString], { + stdio: 'inherit' +}); +//# sourceMappingURL=file:///E:/ts/tests/webTestServer.js.map \ No newline at end of file diff --git a/tests/webTestServer.js.map b/tests/webTestServer.js.map new file mode 100644 index 00000000000..5f251582cda --- /dev/null +++ b/tests/webTestServer.js.map @@ -0,0 +1 @@ +{"version":3,"file":"webTestServer.js","sourceRoot":"","sources":["file:///E:/ts/tests/webTestServer.ts"],"names":[],"mappings":"AAAA,yDAAyD;;AAEzD,IAAO,IAAI,WAAW,MAAM,CAAC,CAAC;AAC9B,IAAO,EAAE,WAAW,IAAI,CAAC,CAAC;AAC1B,IAAO,IAAI,WAAW,MAAM,CAAC,CAAC;AAC9B,IAAO,GAAG,WAAW,KAAK,CAAC,CAAC;AAC5B,IAAO,aAAa,WAAW,eAAe,CAAC,CAAC;AAChD,IAAO,EAAE,WAAW,IAAI,CAAC,CAAC;AAE1B,+BAA+B;AAE/B,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC;IAC9B,OAAO,CAAC,GAAG,CAAC,iGAAiG,CAAC,CAAC;IAC/G,OAAO,CAAC,GAAG,CAAC,qGAAqG,CAAC,CAAC;IACnH,OAAO,CAAC,GAAG,CAAC,yCAAyC,CAAC,CAAC;IACvD,OAAO,CAAC,GAAG,CAAC,iEAAiE,CAAC,CAAC;AACnF,CAAC;AAED,gCAAgC,IAAY;IACxC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;AAC1D,CAAC;AAED,IAAI,WAAW,GAAG,IAAI,CAAC;AACvB,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,I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,CAAC,EAAE,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC;QACnC,WAAW,GAAG,iBAAiB,CAAC;IACpC,CAAC;IAAC,IAAI,CAAC,CAAC;QACJ,WAAW,GAAG,OAAO,CAAC;IAC1B,CAAC;AACL,CAAC;AAAC,IAAI,CAAC,CAAC;IACJ,IAAI,aAAa,GAAG,iDAAiD,CAAC;IACtE,EAAE,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;QAC/B,WAAW,GAAG,aAAa,CAAC;IAChC,CAAC;IAAC,IAAI,CAAC,CAAC;QACJ,WAAW,GAAG,OAAO,CAAC;IAC1B,CAAC;AACL,CAAC;AAED,OAAO,CAAC,GAAG,CAAC,iBAAiB,GAAG,WAAW,CAAC,CAAC;AAE7C,IAAI,WAAW,GAAG,IAAI,GAAG,QAAQ,GAAG,IAAI,GAAG,EAAE,CAAC;AAC9C,aAAa,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,mBAAmB,GAAG,IAAI,GAAG,4BAA4B,GAAG,WAAW,CAAC,EAAE;IACxG,KAAK,EAAE,SAAS;CACnB,CAAC,CAAC"} \ No newline at end of file From 4c4bc6112918767b1968580a6b56127f54177354 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Mon, 29 Feb 2016 13:32:17 -0800 Subject: [PATCH 5/5] Remove mistakenly added webTestServer files --- tests/webTestServer.js | 288 ------------------------------------- tests/webTestServer.js.map | 1 - 2 files changed, 289 deletions(-) delete mode 100644 tests/webTestServer.js delete mode 100644 tests/webTestServer.js.map diff --git a/tests/webTestServer.js b/tests/webTestServer.js deleted file mode 100644 index d2ea8734328..00000000000 --- a/tests/webTestServer.js +++ /dev/null @@ -1,288 +0,0 @@ -/// -"use strict"; -var http = require("http"); -var fs = require("fs"); -var path = require("path"); -var url = require("url"); -var child_process = require("child_process"); -var os = require("os"); -/// Command line processing /// -if (process.argv[2] == '--help') { - console.log('Runs a node server on port 8888 by default, looking for tests folder in the current directory\n'); - console.log('Syntax: node nodeServer.js [port] [typescriptEnlistmentDirectory] [tests] [--browser] [--verbose]\n'); - console.log('Examples: \n\tnode nodeServer.js 8888 .'); - console.log('\tnode nodeServer.js 3000 D:/src/typescript/public --verbose IE'); -} -function switchToForwardSlashes(path) { - return path.replace(/\\/g, "/").replace(/\/\//g, '/'); -} -var defaultPort = 8888; -var port = process.argv[2] || defaultPort; -var rootDir = switchToForwardSlashes(__dirname + '/../'); -var browser; -if (process.argv[3]) { - browser = process.argv[3]; - if (browser !== 'chrome' && browser !== 'IE') { - console.log('Invalid command line arguments. Got ' + browser + ' but expected chrome, IE or nothing.'); - } -} -var grep = process.argv[4]; -var verbose = false; -if (process.argv[5] == '--verbose') { - verbose = true; -} -else if (process.argv[5] && process.argv[5] !== '--verbose') { - console.log('Invalid command line arguments. Got ' + process.argv[5] + ' but expected --verbose or nothing.'); -} -/// Utils /// -function log(msg) { - if (verbose) { - console.log(msg); - } -} -// Copied from the compiler sources -function dir(path, spec, options) { - options = options || {}; - function filesInFolder(folder) { - var folder = switchToForwardSlashes(folder); - var paths = []; - // Everything after the current directory is relative - var baseDirectoryLength = process.cwd().length + 1; - try { - var files = fs.readdirSync(folder); - for (var i = 0; i < files.length; i++) { - var stat = fs.statSync(folder + "/" + files[i]); - if (options.recursive && stat.isDirectory()) { - paths = paths.concat(filesInFolder(folder + "/" + files[i])); - } - else if (stat.isFile() && (!spec || files[i].match(spec))) { - var relativePath = folder.substring(baseDirectoryLength); - paths.push(relativePath + "/" + files[i]); - } - } - } - catch (err) { - } - return paths; - } - return filesInFolder(path); -} -// fs.rmdirSync won't delete directories with files in it -function deleteFolderRecursive(path) { - if (fs.existsSync(path)) { - fs.readdirSync(path).forEach(function (file, index) { - var curPath = path + "/" + file; - if (fs.statSync(curPath).isDirectory()) { - deleteFolderRecursive(curPath); - } - else { - fs.unlinkSync(curPath); - } - }); - fs.rmdirSync(path); - } -} -; -function writeFile(path, data, opts) { - try { - fs.writeFileSync(path, data); - } - catch (e) { - // assume file was written to a directory that exists, if not, start recursively creating them as necessary - var parts = switchToForwardSlashes(path).split('/'); - for (var i = 0; i < parts.length; i++) { - var subDir = parts.slice(0, i).join('/'); - if (!fs.existsSync(subDir)) { - fs.mkdir(subDir); - } - } - fs.writeFileSync(path, data); - } -} -/// Request Handling /// -function handleResolutionRequest(filePath, res) { - var resolvedPath = path.resolve(filePath, ''); - resolvedPath = resolvedPath.substring(resolvedPath.indexOf('tests')); - resolvedPath = switchToForwardSlashes(resolvedPath); - send('success', res, resolvedPath); - return; -} -function send(result, res, contents, contentType) { - if (contentType === void 0) { contentType = "binary"; } - var responseCode = result === "success" ? 200 : result === "fail" ? 500 : result === 'unknown' ? 404 : parseInt(result); - res.writeHead(responseCode, { "Content-Type": contentType }); - res.end(contents); - return; -} -// Reads the data from a post request and passes it to the given callback -function processPost(req, res, callback) { - var queryData = ""; - if (typeof callback !== 'function') - return null; - if (req.method == 'POST') { - req.on('data', function (data) { - queryData += data; - if (queryData.length > 1e8) { - queryData = ""; - send("413", res, null); - console.log("ERROR: destroying connection"); - req.connection.destroy(); - } - }); - req.on('end', function () { - //res.post = url.parse(req.url).query; - callback(queryData); - }); - } - else { - send("405", res, null); - } -} -var RequestType; -(function (RequestType) { - RequestType[RequestType["GetFile"] = 0] = "GetFile"; - RequestType[RequestType["GetDir"] = 1] = "GetDir"; - RequestType[RequestType["ResolveFile"] = 2] = "ResolveFile"; - RequestType[RequestType["WriteFile"] = 3] = "WriteFile"; - RequestType[RequestType["DeleteFile"] = 4] = "DeleteFile"; - RequestType[RequestType["WriteDir"] = 5] = "WriteDir"; - RequestType[RequestType["DeleteDir"] = 6] = "DeleteDir"; - RequestType[RequestType["AppendFile"] = 7] = "AppendFile"; - RequestType[RequestType["Unknown"] = 8] = "Unknown"; -})(RequestType || (RequestType = {})); -function getRequestOperation(req, filename) { - if (req.method === 'GET' && req.url.indexOf('?') === -1) { - if (req.url.indexOf('.') !== -1) - return RequestType.GetFile; - else - return RequestType.GetDir; - } - else { - var queryData = url.parse(req.url, true).query; - if (req.method === 'GET' && queryData.resolve !== undefined) - return RequestType.ResolveFile; - // mocha uses ?grep= query string as equivalent to the --grep command line option used to filter tests - if (req.method === 'GET' && queryData.grep !== undefined) - return RequestType.GetFile; - if (req.method === 'POST' && queryData.action) { - var path = req.url.substr(0, req.url.lastIndexOf('?')); - var isFile = path.substring(path.lastIndexOf('/')).indexOf('.') !== -1; - switch (queryData.action.toUpperCase()) { - case 'WRITE': - return isFile ? RequestType.WriteFile : RequestType.WriteDir; - case 'DELETE': - return isFile ? RequestType.DeleteFile : RequestType.DeleteDir; - case 'APPEND': - return isFile ? RequestType.AppendFile : RequestType.Unknown; - } - } - return RequestType.Unknown; - } -} -function handleRequestOperation(req, res, operation, reqPath) { - switch (operation) { - case RequestType.GetDir: - var filesInFolder = dir(reqPath, "", { recursive: true }); - send('success', res, filesInFolder.join(',')); - break; - case RequestType.GetFile: - fs.readFile(reqPath, function (err, file) { - var ext = reqPath.substr(reqPath.lastIndexOf('.')); - var contentType = 'binary'; - if (ext === '.js') - contentType = 'text/javascript'; - else if (ext === '.css') - contentType = 'text/javascript'; - else if (ext === '.html') - contentType = 'text/html'; - err - ? send('fail', res, err.message, contentType) - : send('success', res, file, contentType); - }); - break; - case RequestType.ResolveFile: - var resolveRequest = req.url.match(/(.*)\?resolve/); - handleResolutionRequest(resolveRequest[1], res); - break; - case RequestType.WriteFile: - processPost(req, res, function (data) { - writeFile(reqPath, data, { recursive: true }); - }); - send('success', res, null); - break; - case RequestType.WriteDir: - fs.mkdirSync(reqPath); - send('success', res, null); - break; - case RequestType.DeleteFile: - if (fs.existsSync(reqPath)) { - fs.unlinkSync(reqPath); - } - send('success', res, null); - break; - case RequestType.DeleteDir: - if (fs.existsSync(reqPath)) { - fs.rmdirSync(reqPath); - } - send('success', res, null); - break; - case RequestType.AppendFile: - processPost(req, res, function (data) { - fs.appendFileSync(reqPath, data); - }); - send('success', res, null); - break; - case RequestType.Unknown: - default: - send('unknown', res, null); - break; - } -} -console.log("Static file server running at\n => http://localhost:" + port + "/\nCTRL + C to shutdown"); -http.createServer(function (req, res) { - log(req.method + ' ' + req.url); - var uri = url.parse(req.url).pathname; - var reqPath = path.join(process.cwd(), uri); - var operation = getRequestOperation(req, reqPath); - handleRequestOperation(req, res, operation, reqPath); -}).listen(8888); -var browserPath; -if ((browser && browser === 'chrome')) { - var defaultChromePath = ""; - switch (os.platform()) { - case "win32": - case "win64": - defaultChromePath = "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe"; - break; - case "darwin": - defaultChromePath = "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"; - break; - case "linux": - defaultChromePath = "/opt/google/chrome/chrome"; - break; - default: - console.log("default Chrome location is unknown for platform '" + os.platform() + "'"); - break; - } - if (fs.existsSync(defaultChromePath)) { - browserPath = defaultChromePath; - } - else { - browserPath = browser; - } -} -else { - var defaultIEPath = 'C:/Program Files/Internet Explorer/iexplore.exe'; - if (fs.existsSync(defaultIEPath)) { - browserPath = defaultIEPath; - } - else { - browserPath = browser; - } -} -console.log('Using browser: ' + browserPath); -var queryString = grep ? "?grep=" + grep : ''; -child_process.spawn(browserPath, ['http://localhost:' + port + '/tests/webTestResults.html' + queryString], { - stdio: 'inherit' -}); -//# sourceMappingURL=file:///E:/ts/tests/webTestServer.js.map \ No newline at end of file diff --git a/tests/webTestServer.js.map b/tests/webTestServer.js.map deleted file mode 100644 index 5f251582cda..00000000000 --- a/tests/webTestServer.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"webTestServer.js","sourceRoot":"","sources":["file:///E:/ts/tests/webTestServer.ts"],"names":[],"mappings":"AAAA,yDAAyD;;AAEzD,IAAO,IAAI,WAAW,MAAM,CAAC,CAAC;AAC9B,IAAO,EAAE,WAAW,IAAI,CAAC,CAAC;AAC1B,IAAO,IAAI,WAAW,MAAM,CAAC,CAAC;AAC9B,IAAO,GAAG,WAAW,KAAK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