mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Accepted baselines.
This commit is contained in:
@@ -1,17 +0,0 @@
|
||||
tests/cases/conformance/types/stringLiteral/stringLiteralTypesAndParenthesizedExpressions01.ts(4,5): error TS2322: Type 'string' is not assignable to type '"foo"'.
|
||||
tests/cases/conformance/types/stringLiteral/stringLiteralTypesAndParenthesizedExpressions01.ts(6,5): error TS2322: Type 'string' is not assignable to type '"foo"'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesAndParenthesizedExpressions01.ts (2 errors) ====
|
||||
|
||||
declare function myRandBool(): boolean;
|
||||
|
||||
let a: "foo" = ("foo");
|
||||
~
|
||||
!!! error TS2322: Type 'string' is not assignable to type '"foo"'.
|
||||
let b: "foo" | "bar" = ("foo");
|
||||
let c: "foo" = (myRandBool ? "foo" : ("foo"));
|
||||
~
|
||||
!!! error TS2322: Type 'string' is not assignable to type '"foo"'.
|
||||
let d: "foo" | "bar" = (myRandBool ? "foo" : ("bar"));
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
=== tests/cases/conformance/types/stringLiteral/stringLiteralTypesAndParenthesizedExpressions01.ts ===
|
||||
|
||||
declare function myRandBool(): boolean;
|
||||
>myRandBool : Symbol(myRandBool, Decl(stringLiteralTypesAndParenthesizedExpressions01.ts, 0, 0))
|
||||
|
||||
let a: "foo" = ("foo");
|
||||
>a : Symbol(a, Decl(stringLiteralTypesAndParenthesizedExpressions01.ts, 3, 3))
|
||||
|
||||
let b: "foo" | "bar" = ("foo");
|
||||
>b : Symbol(b, Decl(stringLiteralTypesAndParenthesizedExpressions01.ts, 4, 3))
|
||||
|
||||
let c: "foo" = (myRandBool ? "foo" : ("foo"));
|
||||
>c : Symbol(c, Decl(stringLiteralTypesAndParenthesizedExpressions01.ts, 5, 3))
|
||||
>myRandBool : Symbol(myRandBool, Decl(stringLiteralTypesAndParenthesizedExpressions01.ts, 0, 0))
|
||||
|
||||
let d: "foo" | "bar" = (myRandBool ? "foo" : ("bar"));
|
||||
>d : Symbol(d, Decl(stringLiteralTypesAndParenthesizedExpressions01.ts, 6, 3))
|
||||
>myRandBool : Symbol(myRandBool, Decl(stringLiteralTypesAndParenthesizedExpressions01.ts, 0, 0))
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
=== tests/cases/conformance/types/stringLiteral/stringLiteralTypesAndParenthesizedExpressions01.ts ===
|
||||
|
||||
declare function myRandBool(): boolean;
|
||||
>myRandBool : () => boolean
|
||||
|
||||
let a: "foo" = ("foo");
|
||||
>a : "foo"
|
||||
>("foo") : "foo"
|
||||
>"foo" : "foo"
|
||||
|
||||
let b: "foo" | "bar" = ("foo");
|
||||
>b : "foo" | "bar"
|
||||
>("foo") : "foo"
|
||||
>"foo" : "foo"
|
||||
|
||||
let c: "foo" = (myRandBool ? "foo" : ("foo"));
|
||||
>c : "foo"
|
||||
>(myRandBool ? "foo" : ("foo")) : "foo"
|
||||
>myRandBool ? "foo" : ("foo") : "foo"
|
||||
>myRandBool : () => boolean
|
||||
>"foo" : "foo"
|
||||
>("foo") : "foo"
|
||||
>"foo" : "foo"
|
||||
|
||||
let d: "foo" | "bar" = (myRandBool ? "foo" : ("bar"));
|
||||
>d : "foo" | "bar"
|
||||
>(myRandBool ? "foo" : ("bar")) : "foo" | "bar"
|
||||
>myRandBool ? "foo" : ("bar") : "foo" | "bar"
|
||||
>myRandBool : () => boolean
|
||||
>"foo" : "foo"
|
||||
>("bar") : "bar"
|
||||
>"bar" : "bar"
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
//// [stringLiteralTypesAsTypeParameterConstraint01.ts]
|
||||
|
||||
function foo<T extends "foo">(f: (x: T) => T) {
|
||||
return f;
|
||||
}
|
||||
|
||||
function bar<T extends "foo" | "bar">(f: (x: T) => T) {
|
||||
return f;
|
||||
}
|
||||
|
||||
let f = foo(x => x);
|
||||
let fResult = f("foo");
|
||||
|
||||
let g = foo((x => x));
|
||||
let gResult = g("foo");
|
||||
|
||||
let h = bar(x => x);
|
||||
let hResult = h("foo");
|
||||
hResult = h("bar");
|
||||
|
||||
//// [stringLiteralTypesAsTypeParameterConstraint01.js]
|
||||
function foo(f) {
|
||||
return f;
|
||||
}
|
||||
function bar(f) {
|
||||
return f;
|
||||
}
|
||||
var f = foo(function (x) { return x; });
|
||||
var fResult = f("foo");
|
||||
var g = foo((function (x) { return x; }));
|
||||
var gResult = g("foo");
|
||||
var h = bar(function (x) { return x; });
|
||||
var hResult = h("foo");
|
||||
hResult = h("bar");
|
||||
|
||||
|
||||
//// [stringLiteralTypesAsTypeParameterConstraint01.d.ts]
|
||||
declare function foo<T extends "foo">(f: (x: T) => T): (x: T) => T;
|
||||
declare function bar<T extends "foo" | "bar">(f: (x: T) => T): (x: T) => T;
|
||||
declare let f: (x: "foo") => "foo";
|
||||
declare let fResult: "foo";
|
||||
declare let g: (x: "foo") => "foo";
|
||||
declare let gResult: "foo";
|
||||
declare let h: (x: "foo" | "bar") => "foo" | "bar";
|
||||
declare let hResult: "foo" | "bar";
|
||||
|
||||
|
||||
//// [DtsFileErrors]
|
||||
|
||||
|
||||
tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTypeParameterConstraint01.d.ts(3,16): error TS2382: Specialized overload signature is not assignable to any non-specialized signature.
|
||||
tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTypeParameterConstraint01.d.ts(5,16): error TS2382: Specialized overload signature is not assignable to any non-specialized signature.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTypeParameterConstraint01.d.ts (2 errors) ====
|
||||
declare function foo<T extends "foo">(f: (x: T) => T): (x: T) => T;
|
||||
declare function bar<T extends "foo" | "bar">(f: (x: T) => T): (x: T) => T;
|
||||
declare let f: (x: "foo") => "foo";
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2382: Specialized overload signature is not assignable to any non-specialized signature.
|
||||
declare let fResult: "foo";
|
||||
declare let g: (x: "foo") => "foo";
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2382: Specialized overload signature is not assignable to any non-specialized signature.
|
||||
declare let gResult: "foo";
|
||||
declare let h: (x: "foo" | "bar") => "foo" | "bar";
|
||||
declare let hResult: "foo" | "bar";
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
=== tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTypeParameterConstraint01.ts ===
|
||||
|
||||
function foo<T extends "foo">(f: (x: T) => T) {
|
||||
>foo : Symbol(foo, Decl(stringLiteralTypesAsTypeParameterConstraint01.ts, 0, 0))
|
||||
>T : Symbol(T, Decl(stringLiteralTypesAsTypeParameterConstraint01.ts, 1, 13))
|
||||
>f : Symbol(f, Decl(stringLiteralTypesAsTypeParameterConstraint01.ts, 1, 30))
|
||||
>x : Symbol(x, Decl(stringLiteralTypesAsTypeParameterConstraint01.ts, 1, 34))
|
||||
>T : Symbol(T, Decl(stringLiteralTypesAsTypeParameterConstraint01.ts, 1, 13))
|
||||
>T : Symbol(T, Decl(stringLiteralTypesAsTypeParameterConstraint01.ts, 1, 13))
|
||||
|
||||
return f;
|
||||
>f : Symbol(f, Decl(stringLiteralTypesAsTypeParameterConstraint01.ts, 1, 30))
|
||||
}
|
||||
|
||||
function bar<T extends "foo" | "bar">(f: (x: T) => T) {
|
||||
>bar : Symbol(bar, Decl(stringLiteralTypesAsTypeParameterConstraint01.ts, 3, 1))
|
||||
>T : Symbol(T, Decl(stringLiteralTypesAsTypeParameterConstraint01.ts, 5, 13))
|
||||
>f : Symbol(f, Decl(stringLiteralTypesAsTypeParameterConstraint01.ts, 5, 38))
|
||||
>x : Symbol(x, Decl(stringLiteralTypesAsTypeParameterConstraint01.ts, 5, 42))
|
||||
>T : Symbol(T, Decl(stringLiteralTypesAsTypeParameterConstraint01.ts, 5, 13))
|
||||
>T : Symbol(T, Decl(stringLiteralTypesAsTypeParameterConstraint01.ts, 5, 13))
|
||||
|
||||
return f;
|
||||
>f : Symbol(f, Decl(stringLiteralTypesAsTypeParameterConstraint01.ts, 5, 38))
|
||||
}
|
||||
|
||||
let f = foo(x => x);
|
||||
>f : Symbol(f, Decl(stringLiteralTypesAsTypeParameterConstraint01.ts, 9, 3))
|
||||
>foo : Symbol(foo, Decl(stringLiteralTypesAsTypeParameterConstraint01.ts, 0, 0))
|
||||
>x : Symbol(x, Decl(stringLiteralTypesAsTypeParameterConstraint01.ts, 9, 12))
|
||||
>x : Symbol(x, Decl(stringLiteralTypesAsTypeParameterConstraint01.ts, 9, 12))
|
||||
|
||||
let fResult = f("foo");
|
||||
>fResult : Symbol(fResult, Decl(stringLiteralTypesAsTypeParameterConstraint01.ts, 10, 3))
|
||||
>f : Symbol(f, Decl(stringLiteralTypesAsTypeParameterConstraint01.ts, 9, 3))
|
||||
|
||||
let g = foo((x => x));
|
||||
>g : Symbol(g, Decl(stringLiteralTypesAsTypeParameterConstraint01.ts, 12, 3))
|
||||
>foo : Symbol(foo, Decl(stringLiteralTypesAsTypeParameterConstraint01.ts, 0, 0))
|
||||
>x : Symbol(x, Decl(stringLiteralTypesAsTypeParameterConstraint01.ts, 12, 13))
|
||||
>x : Symbol(x, Decl(stringLiteralTypesAsTypeParameterConstraint01.ts, 12, 13))
|
||||
|
||||
let gResult = g("foo");
|
||||
>gResult : Symbol(gResult, Decl(stringLiteralTypesAsTypeParameterConstraint01.ts, 13, 3))
|
||||
>g : Symbol(g, Decl(stringLiteralTypesAsTypeParameterConstraint01.ts, 12, 3))
|
||||
|
||||
let h = bar(x => x);
|
||||
>h : Symbol(h, Decl(stringLiteralTypesAsTypeParameterConstraint01.ts, 15, 3))
|
||||
>bar : Symbol(bar, Decl(stringLiteralTypesAsTypeParameterConstraint01.ts, 3, 1))
|
||||
>x : Symbol(x, Decl(stringLiteralTypesAsTypeParameterConstraint01.ts, 15, 12))
|
||||
>x : Symbol(x, Decl(stringLiteralTypesAsTypeParameterConstraint01.ts, 15, 12))
|
||||
|
||||
let hResult = h("foo");
|
||||
>hResult : Symbol(hResult, Decl(stringLiteralTypesAsTypeParameterConstraint01.ts, 16, 3))
|
||||
>h : Symbol(h, Decl(stringLiteralTypesAsTypeParameterConstraint01.ts, 15, 3))
|
||||
|
||||
hResult = h("bar");
|
||||
>hResult : Symbol(hResult, Decl(stringLiteralTypesAsTypeParameterConstraint01.ts, 16, 3))
|
||||
>h : Symbol(h, Decl(stringLiteralTypesAsTypeParameterConstraint01.ts, 15, 3))
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
=== tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTypeParameterConstraint01.ts ===
|
||||
|
||||
function foo<T extends "foo">(f: (x: T) => T) {
|
||||
>foo : <T extends "foo">(f: (x: T) => T) => (x: T) => T
|
||||
>T : T
|
||||
>f : (x: T) => T
|
||||
>x : T
|
||||
>T : T
|
||||
>T : T
|
||||
|
||||
return f;
|
||||
>f : (x: T) => T
|
||||
}
|
||||
|
||||
function bar<T extends "foo" | "bar">(f: (x: T) => T) {
|
||||
>bar : <T extends "foo" | "bar">(f: (x: T) => T) => (x: T) => T
|
||||
>T : T
|
||||
>f : (x: T) => T
|
||||
>x : T
|
||||
>T : T
|
||||
>T : T
|
||||
|
||||
return f;
|
||||
>f : (x: T) => T
|
||||
}
|
||||
|
||||
let f = foo(x => x);
|
||||
>f : (x: "foo") => "foo"
|
||||
>foo(x => x) : (x: "foo") => "foo"
|
||||
>foo : <T extends "foo">(f: (x: T) => T) => (x: T) => T
|
||||
>x => x : (x: "foo") => "foo"
|
||||
>x : "foo"
|
||||
>x : "foo"
|
||||
|
||||
let fResult = f("foo");
|
||||
>fResult : "foo"
|
||||
>f("foo") : "foo"
|
||||
>f : (x: "foo") => "foo"
|
||||
>"foo" : "foo"
|
||||
|
||||
let g = foo((x => x));
|
||||
>g : (x: "foo") => "foo"
|
||||
>foo((x => x)) : (x: "foo") => "foo"
|
||||
>foo : <T extends "foo">(f: (x: T) => T) => (x: T) => T
|
||||
>(x => x) : (x: "foo") => "foo"
|
||||
>x => x : (x: "foo") => "foo"
|
||||
>x : "foo"
|
||||
>x : "foo"
|
||||
|
||||
let gResult = g("foo");
|
||||
>gResult : "foo"
|
||||
>g("foo") : "foo"
|
||||
>g : (x: "foo") => "foo"
|
||||
>"foo" : "foo"
|
||||
|
||||
let h = bar(x => x);
|
||||
>h : (x: "foo" | "bar") => "foo" | "bar"
|
||||
>bar(x => x) : (x: "foo" | "bar") => "foo" | "bar"
|
||||
>bar : <T extends "foo" | "bar">(f: (x: T) => T) => (x: T) => T
|
||||
>x => x : (x: "foo" | "bar") => "foo" | "bar"
|
||||
>x : "foo" | "bar"
|
||||
>x : "foo" | "bar"
|
||||
|
||||
let hResult = h("foo");
|
||||
>hResult : "foo" | "bar"
|
||||
>h("foo") : "foo" | "bar"
|
||||
>h : (x: "foo" | "bar") => "foo" | "bar"
|
||||
>"foo" : "foo"
|
||||
|
||||
hResult = h("bar");
|
||||
>hResult = h("bar") : "foo" | "bar"
|
||||
>hResult : "foo" | "bar"
|
||||
>h("bar") : "foo" | "bar"
|
||||
>h : (x: "foo" | "bar") => "foo" | "bar"
|
||||
>"bar" : "bar"
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTypeParameterConstraint02.ts(6,13): error TS2345: Argument of type '(y: "foo" | "bar") => string' is not assignable to parameter of type '(x: "foo") => "foo"'.
|
||||
Type 'string' is not assignable to type '"foo"'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesAsTypeParameterConstraint02.ts (1 errors) ====
|
||||
|
||||
function foo<T extends "foo">(f: (x: T) => T) {
|
||||
return f;
|
||||
}
|
||||
|
||||
let f = foo((y: "foo" | "bar") => y === "foo" ? y : "foo");
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '(y: "foo" | "bar") => string' is not assignable to parameter of type '(x: "foo") => "foo"'.
|
||||
!!! error TS2345: Type 'string' is not assignable to type '"foo"'.
|
||||
let fResult = f("foo");
|
||||
@@ -0,0 +1,21 @@
|
||||
//// [stringLiteralTypesAsTypeParameterConstraint02.ts]
|
||||
|
||||
function foo<T extends "foo">(f: (x: T) => T) {
|
||||
return f;
|
||||
}
|
||||
|
||||
let f = foo((y: "foo" | "bar") => y === "foo" ? y : "foo");
|
||||
let fResult = f("foo");
|
||||
|
||||
//// [stringLiteralTypesAsTypeParameterConstraint02.js]
|
||||
function foo(f) {
|
||||
return f;
|
||||
}
|
||||
var f = foo(function (y) { return y === "foo" ? y : "foo"; });
|
||||
var fResult = f("foo");
|
||||
|
||||
|
||||
//// [stringLiteralTypesAsTypeParameterConstraint02.d.ts]
|
||||
declare function foo<T extends "foo">(f: (x: T) => T): (x: T) => T;
|
||||
declare let f: any;
|
||||
declare let fResult: any;
|
||||
Reference in New Issue
Block a user