Skip to content

Commit 33a5727

Browse files
committed
Fix newlines, add test from DT
1 parent 429b88f commit 33a5727

8 files changed

+161
-1
lines changed

tests/baselines/reference/contextualOverloadListFromArrayUnion.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ series([
6262
} else {
6363
console.log(results)
6464
}
65-
})
65+
})
66+
6667

6768
//// [one.js]
6869
export const yThen = y.map(item => item.length);

tests/baselines/reference/contextualOverloadListFromArrayUnion.symbols

+1
Original file line numberDiff line numberDiff line change
@@ -185,3 +185,4 @@ series([
185185
>results : Symbol(results, Decl(three.ts, 49, 10))
186186
}
187187
})
188+

tests/baselines/reference/contextualOverloadListFromArrayUnion.types

+1
Original file line numberDiff line numberDiff line change
@@ -209,3 +209,4 @@ series([
209209
>results : unknown[] | null
210210
}
211211
})
212+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
tests/cases/compiler/contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.ts(13,20): error TS7006: Parameter 'match' implicitly has an 'any' type.
2+
3+
4+
==== tests/cases/compiler/contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.ts (1 errors) ====
5+
// must target esnext for `String.normalize` to exist
6+
type Validate = (text: string, pos: number, self: Rule) => number | boolean;
7+
interface FullRule {
8+
validate: string | RegExp | Validate;
9+
normalize?: (match: {x: string}) => void;
10+
}
11+
12+
type Rule = string | FullRule;
13+
14+
const obj: {field: Rule} = {
15+
field: {
16+
validate: (_t, _p, _s) => false,
17+
normalize: match => match.x,
18+
~~~~~
19+
!!! error TS7006: Parameter 'match' implicitly has an 'any' type.
20+
}
21+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//// [contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.ts]
2+
// must target esnext for `String.normalize` to exist
3+
type Validate = (text: string, pos: number, self: Rule) => number | boolean;
4+
interface FullRule {
5+
validate: string | RegExp | Validate;
6+
normalize?: (match: {x: string}) => void;
7+
}
8+
9+
type Rule = string | FullRule;
10+
11+
const obj: {field: Rule} = {
12+
field: {
13+
validate: (_t, _p, _s) => false,
14+
normalize: match => match.x,
15+
}
16+
};
17+
18+
//// [contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.js]
19+
"use strict";
20+
const obj = {
21+
field: {
22+
validate: (_t, _p, _s) => false,
23+
normalize: match => match.x,
24+
}
25+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
=== tests/cases/compiler/contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.ts ===
2+
// must target esnext for `String.normalize` to exist
3+
type Validate = (text: string, pos: number, self: Rule) => number | boolean;
4+
>Validate : Symbol(Validate, Decl(contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.ts, 0, 0))
5+
>text : Symbol(text, Decl(contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.ts, 1, 17))
6+
>pos : Symbol(pos, Decl(contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.ts, 1, 30))
7+
>self : Symbol(self, Decl(contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.ts, 1, 43))
8+
>Rule : Symbol(Rule, Decl(contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.ts, 5, 1))
9+
10+
interface FullRule {
11+
>FullRule : Symbol(FullRule, Decl(contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.ts, 1, 76))
12+
13+
validate: string | RegExp | Validate;
14+
>validate : Symbol(FullRule.validate, Decl(contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.ts, 2, 20))
15+
>RegExp : Symbol(RegExp, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.regexp.d.ts, --, --) ... and 1 more)
16+
>Validate : Symbol(Validate, Decl(contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.ts, 0, 0))
17+
18+
normalize?: (match: {x: string}) => void;
19+
>normalize : Symbol(FullRule.normalize, Decl(contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.ts, 3, 41))
20+
>match : Symbol(match, Decl(contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.ts, 4, 17))
21+
>x : Symbol(x, Decl(contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.ts, 4, 25))
22+
}
23+
24+
type Rule = string | FullRule;
25+
>Rule : Symbol(Rule, Decl(contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.ts, 5, 1))
26+
>FullRule : Symbol(FullRule, Decl(contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.ts, 1, 76))
27+
28+
const obj: {field: Rule} = {
29+
>obj : Symbol(obj, Decl(contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.ts, 9, 5))
30+
>field : Symbol(field, Decl(contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.ts, 9, 12))
31+
>Rule : Symbol(Rule, Decl(contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.ts, 5, 1))
32+
33+
field: {
34+
>field : Symbol(field, Decl(contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.ts, 9, 28))
35+
36+
validate: (_t, _p, _s) => false,
37+
>validate : Symbol(validate, Decl(contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.ts, 10, 12))
38+
>_t : Symbol(_t, Decl(contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.ts, 11, 19))
39+
>_p : Symbol(_p, Decl(contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.ts, 11, 22))
40+
>_s : Symbol(_s, Decl(contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.ts, 11, 26))
41+
42+
normalize: match => match.x,
43+
>normalize : Symbol(normalize, Decl(contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.ts, 11, 40))
44+
>match : Symbol(match, Decl(contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.ts, 12, 18))
45+
>match : Symbol(match, Decl(contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.ts, 12, 18))
46+
}
47+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
=== tests/cases/compiler/contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.ts ===
2+
// must target esnext for `String.normalize` to exist
3+
type Validate = (text: string, pos: number, self: Rule) => number | boolean;
4+
>Validate : Validate
5+
>text : string
6+
>pos : number
7+
>self : Rule
8+
9+
interface FullRule {
10+
validate: string | RegExp | Validate;
11+
>validate : string | RegExp | Validate
12+
13+
normalize?: (match: {x: string}) => void;
14+
>normalize : ((match: { x: string;}) => void) | undefined
15+
>match : { x: string; }
16+
>x : string
17+
}
18+
19+
type Rule = string | FullRule;
20+
>Rule : Rule
21+
22+
const obj: {field: Rule} = {
23+
>obj : { field: Rule; }
24+
>field : Rule
25+
>{ field: { validate: (_t, _p, _s) => false, normalize: match => match.x, }} : { field: { validate: (_t: string, _p: number, _s: Rule) => false; normalize: (match: any) => any; }; }
26+
27+
field: {
28+
>field : { validate: (_t: string, _p: number, _s: Rule) => false; normalize: (match: any) => any; }
29+
>{ validate: (_t, _p, _s) => false, normalize: match => match.x, } : { validate: (_t: string, _p: number, _s: Rule) => false; normalize: (match: any) => any; }
30+
31+
validate: (_t, _p, _s) => false,
32+
>validate : (_t: string, _p: number, _s: Rule) => false
33+
>(_t, _p, _s) => false : (_t: string, _p: number, _s: Rule) => false
34+
>_t : string
35+
>_p : number
36+
>_s : Rule
37+
>false : false
38+
39+
normalize: match => match.x,
40+
>normalize : (match: any) => any
41+
>match => match.x : (match: any) => any
42+
>match : any
43+
>match.x : any
44+
>match : any
45+
>x : any
46+
}
47+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// @strict: true
2+
// @target: esnext
3+
// must target esnext for `String.normalize` to exist
4+
type Validate = (text: string, pos: number, self: Rule) => number | boolean;
5+
interface FullRule {
6+
validate: string | RegExp | Validate;
7+
normalize?: (match: {x: string}) => void;
8+
}
9+
10+
type Rule = string | FullRule;
11+
12+
const obj: {field: Rule} = {
13+
field: {
14+
validate: (_t, _p, _s) => false,
15+
normalize: match => match.x,
16+
}
17+
};

0 commit comments

Comments
 (0)