5a1d30815b
* When noImplicitAny is set, combine multiple contextual overloads into a single signature, rather than producing `any` and an error * Amalgamate intersection composite signature return types as intersections, rather than the prior exclusively union behavior * Add another example from an issue, albeit slightly modified * Fix newlines, add test from DT * Interior remodelling
26 lines
680 B
TypeScript
26 lines
680 B
TypeScript
//// [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,
|
|
}
|
|
};
|