Skip to content

Commit

Permalink
Fix newlines, add test from DT
Browse files Browse the repository at this point in the history
  • Loading branch information
weswigham committed Feb 4, 2021
1 parent 429b88f commit 33a5727
Show file tree
Hide file tree
Showing 8 changed files with 161 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ series([
} else {
console.log(results)
}
})
})


//// [one.js]
export const yThen = y.map(item => item.length);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,3 +185,4 @@ series([
>results : Symbol(results, Decl(three.ts, 49, 10))
}
})

Original file line number Diff line number Diff line change
Expand Up @@ -209,3 +209,4 @@ series([
>results : unknown[] | null
}
})

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
tests/cases/compiler/contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.ts(13,20): error TS7006: Parameter 'match' implicitly has an 'any' type.


==== tests/cases/compiler/contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.ts (1 errors) ====
// must target esnext for `String.normalize` to exist
type Validate = (text: string, pos: number, self: Rule) => number | boolean;
interface FullRule {
validate: string | RegExp | Validate;
normalize?: (match: {x: string}) => void;
}

type Rule = string | FullRule;

const obj: {field: Rule} = {
field: {
validate: (_t, _p, _s) => false,
normalize: match => match.x,
~~~~~
!!! error TS7006: Parameter 'match' implicitly has an 'any' type.
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//// [contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.ts]
// must target esnext for `String.normalize` to exist
type Validate = (text: string, pos: number, self: Rule) => number | boolean;
interface FullRule {
validate: string | RegExp | Validate;
normalize?: (match: {x: string}) => void;
}

type Rule = string | FullRule;

const obj: {field: Rule} = {
field: {
validate: (_t, _p, _s) => false,
normalize: match => match.x,
}
};

//// [contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.js]
"use strict";
const obj = {
field: {
validate: (_t, _p, _s) => false,
normalize: match => match.x,
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
=== tests/cases/compiler/contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.ts ===
// must target esnext for `String.normalize` to exist
type Validate = (text: string, pos: number, self: Rule) => number | boolean;
>Validate : Symbol(Validate, Decl(contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.ts, 0, 0))
>text : Symbol(text, Decl(contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.ts, 1, 17))
>pos : Symbol(pos, Decl(contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.ts, 1, 30))
>self : Symbol(self, Decl(contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.ts, 1, 43))
>Rule : Symbol(Rule, Decl(contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.ts, 5, 1))

interface FullRule {
>FullRule : Symbol(FullRule, Decl(contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.ts, 1, 76))

validate: string | RegExp | Validate;
>validate : Symbol(FullRule.validate, Decl(contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.ts, 2, 20))
>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)
>Validate : Symbol(Validate, Decl(contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.ts, 0, 0))

normalize?: (match: {x: string}) => void;
>normalize : Symbol(FullRule.normalize, Decl(contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.ts, 3, 41))
>match : Symbol(match, Decl(contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.ts, 4, 17))
>x : Symbol(x, Decl(contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.ts, 4, 25))
}

type Rule = string | FullRule;
>Rule : Symbol(Rule, Decl(contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.ts, 5, 1))
>FullRule : Symbol(FullRule, Decl(contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.ts, 1, 76))

const obj: {field: Rule} = {
>obj : Symbol(obj, Decl(contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.ts, 9, 5))
>field : Symbol(field, Decl(contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.ts, 9, 12))
>Rule : Symbol(Rule, Decl(contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.ts, 5, 1))

field: {
>field : Symbol(field, Decl(contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.ts, 9, 28))

validate: (_t, _p, _s) => false,
>validate : Symbol(validate, Decl(contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.ts, 10, 12))
>_t : Symbol(_t, Decl(contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.ts, 11, 19))
>_p : Symbol(_p, Decl(contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.ts, 11, 22))
>_s : Symbol(_s, Decl(contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.ts, 11, 26))

normalize: match => match.x,
>normalize : Symbol(normalize, Decl(contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.ts, 11, 40))
>match : Symbol(match, Decl(contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.ts, 12, 18))
>match : Symbol(match, Decl(contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.ts, 12, 18))
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
=== tests/cases/compiler/contextualOverloadListFromUnionWithPrimitiveNoImplicitAny.ts ===
// must target esnext for `String.normalize` to exist
type Validate = (text: string, pos: number, self: Rule) => number | boolean;
>Validate : Validate
>text : string
>pos : number
>self : Rule

interface FullRule {
validate: string | RegExp | Validate;
>validate : string | RegExp | Validate

normalize?: (match: {x: string}) => void;
>normalize : ((match: { x: string;}) => void) | undefined
>match : { x: string; }
>x : string
}

type Rule = string | FullRule;
>Rule : Rule

const obj: {field: Rule} = {
>obj : { field: Rule; }
>field : Rule
>{ field: { validate: (_t, _p, _s) => false, normalize: match => match.x, }} : { field: { validate: (_t: string, _p: number, _s: Rule) => false; normalize: (match: any) => any; }; }

field: {
>field : { validate: (_t: string, _p: number, _s: Rule) => false; normalize: (match: any) => any; }
>{ validate: (_t, _p, _s) => false, normalize: match => match.x, } : { validate: (_t: string, _p: number, _s: Rule) => false; normalize: (match: any) => any; }

validate: (_t, _p, _s) => false,
>validate : (_t: string, _p: number, _s: Rule) => false
>(_t, _p, _s) => false : (_t: string, _p: number, _s: Rule) => false
>_t : string
>_p : number
>_s : Rule
>false : false

normalize: match => match.x,
>normalize : (match: any) => any
>match => match.x : (match: any) => any
>match : any
>match.x : any
>match : any
>x : any
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// @strict: true
// @target: esnext
// must target esnext for `String.normalize` to exist
type Validate = (text: string, pos: number, self: Rule) => number | boolean;
interface FullRule {
validate: string | RegExp | Validate;
normalize?: (match: {x: string}) => void;
}

type Rule = string | FullRule;

const obj: {field: Rule} = {
field: {
validate: (_t, _p, _s) => false,
normalize: match => match.x,
}
};

0 comments on commit 33a5727

Please sign in to comment.