mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Reuse type nodes from optional parameters even when not written as a union with undefined (#48605)
* Reuse type nodes from optional parameters and properties even when not written as a union with `undefined` * Remove newly unneeded NodeBuilderFlag * Update public API * Update baselines from main
This commit is contained in:
+12
-10
@@ -5915,9 +5915,6 @@ namespace ts {
|
||||
if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) {
|
||||
parameterType = getOptionalType(parameterType);
|
||||
}
|
||||
if ((context.flags & NodeBuilderFlags.NoUndefinedOptionalParameterType) && parameterDeclaration && !isJSDocParameterTag(parameterDeclaration) && isOptionalUninitializedParameter(parameterDeclaration)) {
|
||||
parameterType = getTypeWithFacts(parameterType, TypeFacts.NEUndefined);
|
||||
}
|
||||
const parameterTypeNode = serializeTypeForDeclaration(context, parameterType, parameterSymbol, context.enclosingDeclaration, privateSymbolVisitor, bundledImports);
|
||||
|
||||
const modifiers = !(context.flags & NodeBuilderFlags.OmitParameterModifiers) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers ? parameterDeclaration.modifiers.map(factory.cloneNode) : undefined;
|
||||
@@ -6544,7 +6541,7 @@ namespace ts {
|
||||
if (declWithExistingAnnotation && !isFunctionLikeDeclaration(declWithExistingAnnotation) && !isGetAccessorDeclaration(declWithExistingAnnotation)) {
|
||||
// try to reuse the existing annotation
|
||||
const existing = getEffectiveTypeAnnotationNode(declWithExistingAnnotation)!;
|
||||
if (getTypeFromTypeNode(existing) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) {
|
||||
if (typeNodeIsEquivalentToType(existing, declWithExistingAnnotation, type) && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) {
|
||||
const result = serializeExistingTypeNode(context, existing, includePrivateSymbol, bundled);
|
||||
if (result) {
|
||||
return result;
|
||||
@@ -6562,6 +6559,17 @@ namespace ts {
|
||||
return result;
|
||||
}
|
||||
|
||||
function typeNodeIsEquivalentToType(typeNode: TypeNode, annotatedDeclaration: Declaration, type: Type) {
|
||||
const typeFromTypeNode = getTypeFromTypeNode(typeNode);
|
||||
if (typeFromTypeNode === type) {
|
||||
return true;
|
||||
}
|
||||
if (isParameter(annotatedDeclaration) && annotatedDeclaration.questionToken) {
|
||||
return getTypeWithFacts(type, TypeFacts.NEUndefined) === typeFromTypeNode;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function serializeReturnTypeForSignature(context: NodeBuilderContext, type: Type, signature: Signature, includePrivateSymbol?: (s: Symbol) => void, bundled?: boolean) {
|
||||
if (!isErrorType(type) && context.enclosingDeclaration) {
|
||||
const annotation = signature.declaration && getEffectiveReturnTypeNode(signature.declaration);
|
||||
@@ -42579,12 +42587,6 @@ namespace ts {
|
||||
hasSyntacticModifier(parameter, ModifierFlags.ParameterPropertyModifier);
|
||||
}
|
||||
|
||||
function isOptionalUninitializedParameter(parameter: ParameterDeclaration) {
|
||||
return !!strictNullChecks &&
|
||||
isOptionalParameter(parameter) &&
|
||||
!parameter.initializer;
|
||||
}
|
||||
|
||||
function isExpandoFunctionDeclaration(node: Declaration): boolean {
|
||||
const declaration = getParseTreeNode(node, isFunctionDeclaration);
|
||||
if (!declaration) {
|
||||
|
||||
@@ -4490,7 +4490,6 @@ namespace ts {
|
||||
UseAliasDefinedOutsideCurrentScope = 1 << 14, // Allow non-visible aliases
|
||||
UseSingleQuotesForStringLiteralType = 1 << 28, // Use single quotes for string literal type
|
||||
NoTypeReduction = 1 << 29, // Don't call getReducedType
|
||||
NoUndefinedOptionalParameterType = 1 << 30, // Do not add undefined to optional parameter type
|
||||
|
||||
// Error handling
|
||||
AllowThisInObjectLiteral = 1 << 15,
|
||||
|
||||
@@ -7654,4 +7654,8 @@ namespace ts {
|
||||
|
||||
return state > States.NodeModules ? { topLevelNodeModulesIndex, topLevelPackageNameIndex, packageRootIndex, fileNameIndex } : undefined;
|
||||
}
|
||||
|
||||
export function getParameterTypeNode(parameter: ParameterDeclaration | JSDocParameterTag) {
|
||||
return parameter.kind === SyntaxKind.JSDocParameterTag ? parameter.typeExpression?.type : parameter.type;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,7 +194,6 @@ namespace ts.codefix {
|
||||
const scriptTarget = getEmitScriptTarget(program.getCompilerOptions());
|
||||
const flags =
|
||||
NodeBuilderFlags.NoTruncation
|
||||
| NodeBuilderFlags.NoUndefinedOptionalParameterType
|
||||
| NodeBuilderFlags.SuppressAnyReturnType
|
||||
| NodeBuilderFlags.AllowEmptyTuple
|
||||
| (quotePreference === QuotePreference.Single ? NodeBuilderFlags.UseSingleQuotesForStringLiteralType : NodeBuilderFlags.None);
|
||||
|
||||
@@ -2394,7 +2394,6 @@ declare namespace ts {
|
||||
UseAliasDefinedOutsideCurrentScope = 16384,
|
||||
UseSingleQuotesForStringLiteralType = 268435456,
|
||||
NoTypeReduction = 536870912,
|
||||
NoUndefinedOptionalParameterType = 1073741824,
|
||||
AllowThisInObjectLiteral = 32768,
|
||||
AllowQualifiedNameInPlaceOfIdentifier = 65536,
|
||||
/** @deprecated AllowQualifedNameInPlaceOfIdentifier. Use AllowQualifiedNameInPlaceOfIdentifier instead. */
|
||||
|
||||
@@ -2394,7 +2394,6 @@ declare namespace ts {
|
||||
UseAliasDefinedOutsideCurrentScope = 16384,
|
||||
UseSingleQuotesForStringLiteralType = 268435456,
|
||||
NoTypeReduction = 536870912,
|
||||
NoUndefinedOptionalParameterType = 1073741824,
|
||||
AllowThisInObjectLiteral = 32768,
|
||||
AllowQualifiedNameInPlaceOfIdentifier = 65536,
|
||||
/** @deprecated AllowQualifedNameInPlaceOfIdentifier. Use AllowQualifiedNameInPlaceOfIdentifier instead. */
|
||||
|
||||
@@ -19,7 +19,7 @@ type BadFlatArray<Arr, Depth extends number> = {obj: {
|
||||
>1 : 1
|
||||
|
||||
declare function flat<A, D extends number = 1>(
|
||||
>flat : <A, D extends number = 1>(arr: A, depth?: D | undefined) => BadFlatArray<A, D>[]
|
||||
>flat : <A, D extends number = 1>(arr: A, depth?: D) => BadFlatArray<A, D>[]
|
||||
|
||||
arr: A,
|
||||
>arr : A
|
||||
|
||||
@@ -270,7 +270,7 @@ namespace Debug {
|
||||
>Debug : typeof Debug
|
||||
|
||||
export declare function assert(value: unknown, message?: string): asserts value;
|
||||
>assert : (value: unknown, message?: string | undefined) => asserts value
|
||||
>assert : (value: unknown, message?: string) => asserts value
|
||||
>value : unknown
|
||||
>message : string | undefined
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ declare function resolve2<T>(value: T): Windows.Foundation.IPromise<T>;
|
||||
>Foundation : any
|
||||
|
||||
async function sample2(x?: number) {
|
||||
>sample2 : (x?: number | undefined) => Promise<void>
|
||||
>sample2 : (x?: number) => Promise<void>
|
||||
>x : number | undefined
|
||||
|
||||
let x1 = await resolve1(x);
|
||||
|
||||
@@ -110,7 +110,7 @@ function test3(items: string[] | number[]) {
|
||||
}
|
||||
|
||||
function test4(
|
||||
>test4 : (arg1: ((...objs: { x: number;}[]) => number) | ((...objs: { y: number;}[]) => number), arg2: ((a: { x: number;}, b: object) => number) | ((a: object, b: { x: number;}) => number), arg3: ((a: { x: number;}, ...objs: { y: number;}[]) => number) | ((...objs: { x: number;}[]) => number), arg4: ((a?: { x: number; } | undefined, b?: { x: number; } | undefined) => number) | ((a?: { y: number; } | undefined) => number), arg5: ((a?: { x: number; } | undefined, ...b: { x: number;}[]) => number) | ((a?: { y: number; } | undefined) => number), arg6: ((a?: { x: number; } | undefined, b?: { x: number; } | undefined) => number) | ((...a: { y: number;}[]) => number)) => void
|
||||
>test4 : (arg1: ((...objs: { x: number;}[]) => number) | ((...objs: { y: number;}[]) => number), arg2: ((a: { x: number;}, b: object) => number) | ((a: object, b: { x: number;}) => number), arg3: ((a: { x: number;}, ...objs: { y: number;}[]) => number) | ((...objs: { x: number;}[]) => number), arg4: ((a?: { x: number;}, b?: { x: number;}) => number) | ((a?: { y: number;}) => number), arg5: ((a?: { x: number;}, ...b: { x: number;}[]) => number) | ((a?: { y: number;}) => number), arg6: ((a?: { x: number;}, b?: { x: number;}) => number) | ((...a: { y: number;}[]) => number)) => void
|
||||
|
||||
arg1: ((...objs: {x: number}[]) => number) | ((...objs: {y: number}[]) => number),
|
||||
>arg1 : ((...objs: { x: number;}[]) => number) | ((...objs: { y: number;}[]) => number)
|
||||
@@ -138,7 +138,7 @@ function test4(
|
||||
>x : number
|
||||
|
||||
arg4: ((a?: {x: number}, b?: {x: number}) => number) | ((a?: {y: number}) => number),
|
||||
>arg4 : ((a?: { x: number; } | undefined, b?: { x: number; } | undefined) => number) | ((a?: { y: number; } | undefined) => number)
|
||||
>arg4 : ((a?: { x: number;}, b?: { x: number;}) => number) | ((a?: { y: number;}) => number)
|
||||
>a : { x: number; } | undefined
|
||||
>x : number
|
||||
>b : { x: number; } | undefined
|
||||
@@ -147,7 +147,7 @@ function test4(
|
||||
>y : number
|
||||
|
||||
arg5: ((a?: {x: number}, ...b: {x: number}[]) => number) | ((a?: {y: number}) => number),
|
||||
>arg5 : ((a?: { x: number; } | undefined, ...b: { x: number;}[]) => number) | ((a?: { y: number; } | undefined) => number)
|
||||
>arg5 : ((a?: { x: number;}, ...b: { x: number;}[]) => number) | ((a?: { y: number;}) => number)
|
||||
>a : { x: number; } | undefined
|
||||
>x : number
|
||||
>b : { x: number; }[]
|
||||
@@ -156,7 +156,7 @@ function test4(
|
||||
>y : number
|
||||
|
||||
arg6: ((a?: {x: number}, b?: {x: number}) => number) | ((...a: {y: number}[]) => number),
|
||||
>arg6 : ((a?: { x: number; } | undefined, b?: { x: number; } | undefined) => number) | ((...a: { y: number;}[]) => number)
|
||||
>arg6 : ((a?: { x: number;}, b?: { x: number;}) => number) | ((...a: { y: number;}[]) => number)
|
||||
>a : { x: number; } | undefined
|
||||
>x : number
|
||||
>b : { x: number; } | undefined
|
||||
@@ -339,7 +339,7 @@ function test5() {
|
||||
|
||||
// Pair of non-like intrinsics
|
||||
function render(url?: string): React.ReactNode {
|
||||
>render : (url?: string | undefined) => React.ReactNode
|
||||
>render : (url?: string) => React.ReactNode
|
||||
>url : string | undefined
|
||||
>React : any
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ function fn1(x: number | undefined = x > 0 ? x : 0) { }
|
||||
|
||||
// Report from user
|
||||
function fn2(x?: string = someCondition ? 'value1' : x) { }
|
||||
>fn2 : (x?: string | undefined) => void
|
||||
>fn2 : (x?: string) => void
|
||||
>x : string | undefined
|
||||
>someCondition ? 'value1' : x : string | undefined
|
||||
>someCondition : any
|
||||
|
||||
@@ -21,7 +21,7 @@ declare function id4<T extends (x: { foo?: number }) => any>(input: T): T;
|
||||
>input : T
|
||||
|
||||
declare function id5<T extends (x?: number) => any>(input: T): T;
|
||||
>id5 : <T extends (x?: number | undefined) => any>(input: T) => T
|
||||
>id5 : <T extends (x?: number) => any>(input: T) => T
|
||||
>x : number | undefined
|
||||
>input : T
|
||||
|
||||
|
||||
@@ -532,7 +532,7 @@ function f27(outer: { obj: { kind: 'foo', foo: string } | { kind: 'bar', bar: nu
|
||||
}
|
||||
|
||||
function f28(obj?: { kind: 'foo', foo: string } | { kind: 'bar', bar: number }) {
|
||||
>f28 : (obj?: { kind: 'foo'; foo: string; } | { kind: 'bar'; bar: number; } | undefined) => void
|
||||
>f28 : (obj?: { kind: 'foo'; foo: string;} | { kind: 'bar'; bar: number;}) => void
|
||||
>obj : { kind: 'foo'; foo: string; } | { kind: 'bar'; bar: number; } | undefined
|
||||
>kind : "foo"
|
||||
>foo : string
|
||||
|
||||
@@ -10,7 +10,7 @@ const boo: Foo = { bar: 'bar' };
|
||||
>'bar' : "bar"
|
||||
|
||||
function a(aboo1?: Foo) {
|
||||
>a : (aboo1?: Foo | undefined) => void
|
||||
>a : (aboo1?: Foo) => void
|
||||
>aboo1 : Foo | undefined
|
||||
|
||||
if (!aboo1) return;
|
||||
|
||||
@@ -1882,7 +1882,7 @@ type Shape =
|
||||
>radius : number
|
||||
|
||||
function getArea(shape?: Shape) {
|
||||
>getArea : (shape?: Shape | undefined) => number
|
||||
>getArea : (shape?: Shape) => number
|
||||
>shape : Shape | undefined
|
||||
|
||||
switch (shape?.type) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
=== tests/cases/compiler/defaultParameterAddsUndefinedWithStrictNullChecks.ts ===
|
||||
function f(addUndefined1 = "J", addUndefined2?: number) {
|
||||
>f : (addUndefined1?: string, addUndefined2?: number | undefined) => number
|
||||
>f : (addUndefined1?: string, addUndefined2?: number) => number
|
||||
>addUndefined1 : string
|
||||
>"J" : "J"
|
||||
>addUndefined2 : number | undefined
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
=== tests/cases/compiler/destructureOptionalParameter.ts ===
|
||||
declare function f1({ a, b }?: { a: number, b: string }): void;
|
||||
>f1 : ({ a, b }?: { a: number; b: string; } | undefined) => void
|
||||
>f1 : ({ a, b }?: { a: number; b: string;}) => void
|
||||
>a : number
|
||||
>b : string
|
||||
>a : number
|
||||
|
||||
@@ -61,7 +61,7 @@ function f1(options?: { color?: string, width?: number }) {
|
||||
}
|
||||
|
||||
function f2(options?: [string?, number?]) {
|
||||
>f2 : (options?: [(string | undefined)?, (number | undefined)?] | undefined) => void
|
||||
>f2 : (options?: [string?, number?]) => void
|
||||
>options : [(string | undefined)?, (number | undefined)?] | undefined
|
||||
|
||||
let [str, num] = options || [];
|
||||
@@ -133,7 +133,7 @@ function f3(options?: { color: string, width: number }) {
|
||||
}
|
||||
|
||||
function f4(options?: [string, number]) {
|
||||
>f4 : (options?: [string, number] | undefined) => void
|
||||
>f4 : (options?: [string, number]) => void
|
||||
>options : [string, number] | undefined
|
||||
|
||||
let [str, num] = options || [];
|
||||
|
||||
@@ -801,7 +801,7 @@ const fn20 = pipe((_a?: {}) => 1);
|
||||
>fn20 : (_a?: {} | undefined) => number
|
||||
>pipe((_a?: {}) => 1) : (_a?: {} | undefined) => number
|
||||
>pipe : { <A extends any[], B>(ab: (...args: A) => B): (...args: A) => B; <A extends any[], B, C>(ab: (...args: A) => B, bc: (b: B) => C): (...args: A) => C; <A extends any[], B, C, D>(ab: (...args: A) => B, bc: (b: B) => C, cd: (c: C) => D): (...args: A) => D; }
|
||||
>(_a?: {}) => 1 : (_a?: {} | undefined) => number
|
||||
>(_a?: {}) => 1 : (_a?: {}) => number
|
||||
>_a : {} | undefined
|
||||
>1 : 1
|
||||
|
||||
@@ -968,7 +968,7 @@ const fn62 = pipe(
|
||||
// Repro from #30297
|
||||
|
||||
declare function foo2<T, U = T>(fn: T, a?: U, b?: U): [T, U];
|
||||
>foo2 : <T, U = T>(fn: T, a?: U | undefined, b?: U | undefined) => [T, U]
|
||||
>foo2 : <T, U = T>(fn: T, a?: U, b?: U) => [T, U]
|
||||
>fn : T
|
||||
>a : U | undefined
|
||||
>b : U | undefined
|
||||
|
||||
@@ -570,7 +570,7 @@ f23();
|
||||
>f23 : () => string[]
|
||||
|
||||
declare const g20: (x: number, y?: string, z?: boolean) => string[];
|
||||
>g20 : (x: number, y?: string | undefined, z?: boolean | undefined) => string[]
|
||||
>g20 : (x: number, y?: string, z?: boolean) => string[]
|
||||
>x : number
|
||||
>y : string | undefined
|
||||
>z : boolean | undefined
|
||||
|
||||
@@ -11,7 +11,7 @@ type MyMap<M extends object> = {
|
||||
}
|
||||
|
||||
declare function g<T>(value?: T): void;
|
||||
>g : <T>(value?: T | undefined) => void
|
||||
>g : <T>(value?: T) => void
|
||||
>value : T | undefined
|
||||
|
||||
function f1<M extends object>(mymap: MyMap<M>, k: keyof M) {
|
||||
|
||||
@@ -60,7 +60,7 @@ interface Person {
|
||||
}
|
||||
|
||||
declare function selectJohn<K = Person>(props?: SelectProps<Person, K>): SelectResult<Person, K>;
|
||||
>selectJohn : <K = Person>(props?: SelectProps<Person, K> | undefined) => SelectResult<Person, K>
|
||||
>selectJohn : <K = Person>(props?: SelectProps<Person, K>) => SelectResult<Person, K>
|
||||
>props : SelectProps<Person, K> | undefined
|
||||
|
||||
const [person] = selectJohn();
|
||||
@@ -91,7 +91,7 @@ declare function makeTuple<T1>(arg: T1): [T1];
|
||||
>arg : T1
|
||||
|
||||
declare function stringy<T = string>(arg?: T): T;
|
||||
>stringy : <T = string>(arg?: T | undefined) => T
|
||||
>stringy : <T = string>(arg?: T) => T
|
||||
>arg : T | undefined
|
||||
|
||||
const isStringTuple = makeTuple(stringy()); // [string]
|
||||
|
||||
@@ -15,7 +15,7 @@ abstract class SomeAbstractClass<C, M, R> extends SomeBaseClass {
|
||||
>SomeBaseClass : SomeBaseClass
|
||||
|
||||
foo!: (r?: R) => void;
|
||||
>foo : (r?: R | undefined) => void
|
||||
>foo : (r?: R) => void
|
||||
>r : R | undefined
|
||||
|
||||
bar!: (r?: any) => void;
|
||||
@@ -72,7 +72,7 @@ interface BaseType<T1, T2> {
|
||||
>c : T1
|
||||
|
||||
useT2(r?: T2): void;
|
||||
>useT2 : (r?: T2 | undefined) => void
|
||||
>useT2 : (r?: T2) => void
|
||||
>r : T2 | undefined
|
||||
|
||||
unrelatedButSomehowRelevant(r?: any): void;
|
||||
@@ -99,7 +99,7 @@ interface StructuralVersion {
|
||||
>c : number
|
||||
|
||||
useT2(r?: boolean): void;
|
||||
>useT2 : (r?: boolean | undefined) => void
|
||||
>useT2 : (r?: boolean) => void
|
||||
>r : boolean | undefined
|
||||
|
||||
unrelatedButSomehowRelevant(r?: any): void;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
=== tests/cases/compiler/index.d.ts ===
|
||||
export declare function foo({a}?: {
|
||||
>foo : ({ a }?: { a?: string | undefined; } | undefined) => void
|
||||
>foo : ({ a }?: { a?: string;}) => void
|
||||
>a : string | undefined
|
||||
|
||||
a?: string;
|
||||
|
||||
@@ -138,7 +138,7 @@ class Foo {
|
||||
}
|
||||
|
||||
private async bar(node: CommitFileNode | ResultsFileNode | StashFileNode | StatusFileNode, options?: {}) {
|
||||
>bar : (node: CommitFileNode | ResultsFileNode | StashFileNode | StatusFileNode, options?: {} | undefined) => Promise<undefined>
|
||||
>bar : (node: CommitFileNode | ResultsFileNode | StashFileNode | StatusFileNode, options?: {}) => Promise<undefined>
|
||||
>node : CommitFileNode | ResultsFileNode | StashFileNode | StatusFileNode
|
||||
>options : {} | undefined
|
||||
|
||||
|
||||
@@ -216,7 +216,7 @@ declare const TabbedShowLayout: {
|
||||
};
|
||||
} & ((props?: {
|
||||
elem: string;
|
||||
} | undefined) => JSX.Element);
|
||||
}) => JSX.Element);
|
||||
//// [jsDeclarationsReactComponents4.d.ts]
|
||||
export default TabbedShowLayout;
|
||||
declare function TabbedShowLayout(prop: {
|
||||
|
||||
@@ -90,7 +90,7 @@ import { JSXInternal } from '..';
|
||||
>JSXInternal : any
|
||||
|
||||
export function jsx(
|
||||
>jsx : { (type: string, props: JSXInternal.HTMLAttributes & JSXInternal.SVGAttributes & Record<string, any> & { children?: ComponentChild;}, key?: string | undefined): VNode<any>; <P>(type: ComponentType<P>, props: P & { children?: ComponentChild | undefined; }, key?: string | undefined): VNode<any>; }
|
||||
>jsx : { (type: string, props: JSXInternal.HTMLAttributes & JSXInternal.SVGAttributes & Record<string, any> & { children?: ComponentChild;}, key?: string): VNode<any>; <P>(type: ComponentType<P>, props: P & { children?: ComponentChild | undefined; }, key?: string | undefined): VNode<any>; }
|
||||
|
||||
type: string,
|
||||
>type : string
|
||||
@@ -110,7 +110,7 @@ export function jsx(
|
||||
|
||||
): VNode<any>;
|
||||
export function jsx<P>(
|
||||
>jsx : { (type: string, props: JSXInternal.HTMLAttributes<{}> & JSXInternal.SVGAttributes<{}> & Record<string, any> & { children?: ComponentChild | undefined; }, key?: string | undefined): VNode<any>; <P>(type: ComponentType<P>, props: Attributes & P & { children?: ComponentChild;}, key?: string | undefined): VNode<any>; }
|
||||
>jsx : { (type: string, props: JSXInternal.HTMLAttributes<{}> & JSXInternal.SVGAttributes<{}> & Record<string, any> & { children?: ComponentChild | undefined; }, key?: string | undefined): VNode<any>; <P>(type: ComponentType<P>, props: Attributes & P & { children?: ComponentChild;}, key?: string): VNode<any>; }
|
||||
|
||||
type: ComponentType<P>,
|
||||
>type : ComponentType<P>
|
||||
@@ -125,7 +125,7 @@ export function jsx<P>(
|
||||
): VNode<any>;
|
||||
|
||||
export function jsxs(
|
||||
>jsxs : { (type: string, props: JSXInternal.HTMLAttributes & JSXInternal.SVGAttributes & Record<string, any> & { children?: ComponentChild[];}, key?: string | undefined): VNode<any>; <P>(type: ComponentType<P>, props: P & { children?: ComponentChild[] | undefined; }, key?: string | undefined): VNode<any>; }
|
||||
>jsxs : { (type: string, props: JSXInternal.HTMLAttributes & JSXInternal.SVGAttributes & Record<string, any> & { children?: ComponentChild[];}, key?: string): VNode<any>; <P>(type: ComponentType<P>, props: P & { children?: ComponentChild[] | undefined; }, key?: string | undefined): VNode<any>; }
|
||||
|
||||
type: string,
|
||||
>type : string
|
||||
@@ -145,7 +145,7 @@ export function jsxs(
|
||||
|
||||
): VNode<any>;
|
||||
export function jsxs<P>(
|
||||
>jsxs : { (type: string, props: JSXInternal.HTMLAttributes<{}> & JSXInternal.SVGAttributes<{}> & Record<string, any> & { children?: ComponentChild[] | undefined; }, key?: string | undefined): VNode<any>; <P>(type: ComponentType<P>, props: Attributes & P & { children?: ComponentChild[];}, key?: string | undefined): VNode<any>; }
|
||||
>jsxs : { (type: string, props: JSXInternal.HTMLAttributes<{}> & JSXInternal.SVGAttributes<{}> & Record<string, any> & { children?: ComponentChild[] | undefined; }, key?: string | undefined): VNode<any>; <P>(type: ComponentType<P>, props: Attributes & P & { children?: ComponentChild[];}, key?: string): VNode<any>; }
|
||||
|
||||
type: ComponentType<P>,
|
||||
>type : ComponentType<P>
|
||||
@@ -160,7 +160,7 @@ export function jsxs<P>(
|
||||
): VNode<any>;
|
||||
|
||||
export function jsxDEV(
|
||||
>jsxDEV : { (type: string, props: JSXInternal.HTMLAttributes & JSXInternal.SVGAttributes & Record<string, any> & { children?: ComponentChildren;}, key?: string | undefined): VNode<any>; <P>(type: ComponentType<P>, props: P & { children?: ComponentChildren | undefined; }, key?: string | undefined): VNode<any>; }
|
||||
>jsxDEV : { (type: string, props: JSXInternal.HTMLAttributes & JSXInternal.SVGAttributes & Record<string, any> & { children?: ComponentChildren;}, key?: string): VNode<any>; <P>(type: ComponentType<P>, props: P & { children?: ComponentChildren | undefined; }, key?: string | undefined): VNode<any>; }
|
||||
|
||||
type: string,
|
||||
>type : string
|
||||
@@ -180,7 +180,7 @@ export function jsxDEV(
|
||||
|
||||
): VNode<any>;
|
||||
export function jsxDEV<P>(
|
||||
>jsxDEV : { (type: string, props: JSXInternal.HTMLAttributes<{}> & JSXInternal.SVGAttributes<{}> & Record<string, any> & { children?: ComponentChildren | undefined; }, key?: string | undefined): VNode<any>; <P>(type: ComponentType<P>, props: Attributes & P & { children?: ComponentChildren;}, key?: string | undefined): VNode<any>; }
|
||||
>jsxDEV : { (type: string, props: JSXInternal.HTMLAttributes<{}> & JSXInternal.SVGAttributes<{}> & Record<string, any> & { children?: ComponentChildren | undefined; }, key?: string | undefined): VNode<any>; <P>(type: ComponentType<P>, props: Attributes & P & { children?: ComponentChildren;}, key?: string): VNode<any>; }
|
||||
|
||||
type: ComponentType<P>,
|
||||
>type : ComponentType<P>
|
||||
|
||||
@@ -90,7 +90,7 @@ import { JSXInternal } from '..';
|
||||
>JSXInternal : any
|
||||
|
||||
export function jsx(
|
||||
>jsx : { (type: string, props: JSXInternal.HTMLAttributes & JSXInternal.SVGAttributes & Record<string, any> & { children?: ComponentChild;}, key?: string | undefined): VNode<any>; <P>(type: ComponentType<P>, props: P & { children?: ComponentChild | undefined; }, key?: string | undefined): VNode<any>; }
|
||||
>jsx : { (type: string, props: JSXInternal.HTMLAttributes & JSXInternal.SVGAttributes & Record<string, any> & { children?: ComponentChild;}, key?: string): VNode<any>; <P>(type: ComponentType<P>, props: P & { children?: ComponentChild | undefined; }, key?: string | undefined): VNode<any>; }
|
||||
|
||||
type: string,
|
||||
>type : string
|
||||
@@ -110,7 +110,7 @@ export function jsx(
|
||||
|
||||
): VNode<any>;
|
||||
export function jsx<P>(
|
||||
>jsx : { (type: string, props: JSXInternal.HTMLAttributes<{}> & JSXInternal.SVGAttributes<{}> & Record<string, any> & { children?: ComponentChild | undefined; }, key?: string | undefined): VNode<any>; <P>(type: ComponentType<P>, props: Attributes & P & { children?: ComponentChild;}, key?: string | undefined): VNode<any>; }
|
||||
>jsx : { (type: string, props: JSXInternal.HTMLAttributes<{}> & JSXInternal.SVGAttributes<{}> & Record<string, any> & { children?: ComponentChild | undefined; }, key?: string | undefined): VNode<any>; <P>(type: ComponentType<P>, props: Attributes & P & { children?: ComponentChild;}, key?: string): VNode<any>; }
|
||||
|
||||
type: ComponentType<P>,
|
||||
>type : ComponentType<P>
|
||||
@@ -125,7 +125,7 @@ export function jsx<P>(
|
||||
): VNode<any>;
|
||||
|
||||
export function jsxs(
|
||||
>jsxs : { (type: string, props: JSXInternal.HTMLAttributes & JSXInternal.SVGAttributes & Record<string, any> & { children?: ComponentChild[];}, key?: string | undefined): VNode<any>; <P>(type: ComponentType<P>, props: P & { children?: ComponentChild[] | undefined; }, key?: string | undefined): VNode<any>; }
|
||||
>jsxs : { (type: string, props: JSXInternal.HTMLAttributes & JSXInternal.SVGAttributes & Record<string, any> & { children?: ComponentChild[];}, key?: string): VNode<any>; <P>(type: ComponentType<P>, props: P & { children?: ComponentChild[] | undefined; }, key?: string | undefined): VNode<any>; }
|
||||
|
||||
type: string,
|
||||
>type : string
|
||||
@@ -145,7 +145,7 @@ export function jsxs(
|
||||
|
||||
): VNode<any>;
|
||||
export function jsxs<P>(
|
||||
>jsxs : { (type: string, props: JSXInternal.HTMLAttributes<{}> & JSXInternal.SVGAttributes<{}> & Record<string, any> & { children?: ComponentChild[] | undefined; }, key?: string | undefined): VNode<any>; <P>(type: ComponentType<P>, props: Attributes & P & { children?: ComponentChild[];}, key?: string | undefined): VNode<any>; }
|
||||
>jsxs : { (type: string, props: JSXInternal.HTMLAttributes<{}> & JSXInternal.SVGAttributes<{}> & Record<string, any> & { children?: ComponentChild[] | undefined; }, key?: string | undefined): VNode<any>; <P>(type: ComponentType<P>, props: Attributes & P & { children?: ComponentChild[];}, key?: string): VNode<any>; }
|
||||
|
||||
type: ComponentType<P>,
|
||||
>type : ComponentType<P>
|
||||
@@ -160,7 +160,7 @@ export function jsxs<P>(
|
||||
): VNode<any>;
|
||||
|
||||
export function jsxDEV(
|
||||
>jsxDEV : { (type: string, props: JSXInternal.HTMLAttributes & JSXInternal.SVGAttributes & Record<string, any> & { children?: ComponentChildren;}, key?: string | undefined): VNode<any>; <P>(type: ComponentType<P>, props: P & { children?: ComponentChildren | undefined; }, key?: string | undefined): VNode<any>; }
|
||||
>jsxDEV : { (type: string, props: JSXInternal.HTMLAttributes & JSXInternal.SVGAttributes & Record<string, any> & { children?: ComponentChildren;}, key?: string): VNode<any>; <P>(type: ComponentType<P>, props: P & { children?: ComponentChildren | undefined; }, key?: string | undefined): VNode<any>; }
|
||||
|
||||
type: string,
|
||||
>type : string
|
||||
@@ -180,7 +180,7 @@ export function jsxDEV(
|
||||
|
||||
): VNode<any>;
|
||||
export function jsxDEV<P>(
|
||||
>jsxDEV : { (type: string, props: JSXInternal.HTMLAttributes<{}> & JSXInternal.SVGAttributes<{}> & Record<string, any> & { children?: ComponentChildren | undefined; }, key?: string | undefined): VNode<any>; <P>(type: ComponentType<P>, props: Attributes & P & { children?: ComponentChildren;}, key?: string | undefined): VNode<any>; }
|
||||
>jsxDEV : { (type: string, props: JSXInternal.HTMLAttributes<{}> & JSXInternal.SVGAttributes<{}> & Record<string, any> & { children?: ComponentChildren | undefined; }, key?: string | undefined): VNode<any>; <P>(type: ComponentType<P>, props: Attributes & P & { children?: ComponentChildren;}, key?: string): VNode<any>; }
|
||||
|
||||
type: ComponentType<P>,
|
||||
>type : ComponentType<P>
|
||||
|
||||
@@ -90,7 +90,7 @@ import { JSXInternal } from '..';
|
||||
>JSXInternal : any
|
||||
|
||||
export function jsx(
|
||||
>jsx : { (type: string, props: JSXInternal.HTMLAttributes & JSXInternal.SVGAttributes & Record<string, any> & { children?: ComponentChild;}, key?: string | undefined): VNode<any>; <P>(type: ComponentType<P>, props: P & { children?: ComponentChild | undefined; }, key?: string | undefined): VNode<any>; }
|
||||
>jsx : { (type: string, props: JSXInternal.HTMLAttributes & JSXInternal.SVGAttributes & Record<string, any> & { children?: ComponentChild;}, key?: string): VNode<any>; <P>(type: ComponentType<P>, props: P & { children?: ComponentChild | undefined; }, key?: string | undefined): VNode<any>; }
|
||||
|
||||
type: string,
|
||||
>type : string
|
||||
@@ -110,7 +110,7 @@ export function jsx(
|
||||
|
||||
): VNode<any>;
|
||||
export function jsx<P>(
|
||||
>jsx : { (type: string, props: JSXInternal.HTMLAttributes<{}> & JSXInternal.SVGAttributes<{}> & Record<string, any> & { children?: ComponentChild | undefined; }, key?: string | undefined): VNode<any>; <P>(type: ComponentType<P>, props: Attributes & P & { children?: ComponentChild;}, key?: string | undefined): VNode<any>; }
|
||||
>jsx : { (type: string, props: JSXInternal.HTMLAttributes<{}> & JSXInternal.SVGAttributes<{}> & Record<string, any> & { children?: ComponentChild | undefined; }, key?: string | undefined): VNode<any>; <P>(type: ComponentType<P>, props: Attributes & P & { children?: ComponentChild;}, key?: string): VNode<any>; }
|
||||
|
||||
type: ComponentType<P>,
|
||||
>type : ComponentType<P>
|
||||
@@ -126,7 +126,7 @@ export function jsx<P>(
|
||||
|
||||
|
||||
export function jsxs(
|
||||
>jsxs : { (type: string, props: JSXInternal.HTMLAttributes & JSXInternal.SVGAttributes & Record<string, any> & { children?: ComponentChild[];}, key?: string | undefined): VNode<any>; <P>(type: ComponentType<P>, props: P & { children?: ComponentChild[] | undefined; }, key?: string | undefined): VNode<any>; }
|
||||
>jsxs : { (type: string, props: JSXInternal.HTMLAttributes & JSXInternal.SVGAttributes & Record<string, any> & { children?: ComponentChild[];}, key?: string): VNode<any>; <P>(type: ComponentType<P>, props: P & { children?: ComponentChild[] | undefined; }, key?: string | undefined): VNode<any>; }
|
||||
|
||||
type: string,
|
||||
>type : string
|
||||
@@ -146,7 +146,7 @@ export function jsxs(
|
||||
|
||||
): VNode<any>;
|
||||
export function jsxs<P>(
|
||||
>jsxs : { (type: string, props: JSXInternal.HTMLAttributes<{}> & JSXInternal.SVGAttributes<{}> & Record<string, any> & { children?: ComponentChild[] | undefined; }, key?: string | undefined): VNode<any>; <P>(type: ComponentType<P>, props: Attributes & P & { children?: ComponentChild[];}, key?: string | undefined): VNode<any>; }
|
||||
>jsxs : { (type: string, props: JSXInternal.HTMLAttributes<{}> & JSXInternal.SVGAttributes<{}> & Record<string, any> & { children?: ComponentChild[] | undefined; }, key?: string | undefined): VNode<any>; <P>(type: ComponentType<P>, props: Attributes & P & { children?: ComponentChild[];}, key?: string): VNode<any>; }
|
||||
|
||||
type: ComponentType<P>,
|
||||
>type : ComponentType<P>
|
||||
@@ -162,7 +162,7 @@ export function jsxs<P>(
|
||||
|
||||
|
||||
export function jsxDEV(
|
||||
>jsxDEV : { (type: string, props: JSXInternal.HTMLAttributes & JSXInternal.SVGAttributes & Record<string, any> & { children?: ComponentChildren;}, key?: string | undefined): VNode<any>; <P>(type: ComponentType<P>, props: P & { children?: ComponentChildren | undefined; }, key?: string | undefined): VNode<any>; }
|
||||
>jsxDEV : { (type: string, props: JSXInternal.HTMLAttributes & JSXInternal.SVGAttributes & Record<string, any> & { children?: ComponentChildren;}, key?: string): VNode<any>; <P>(type: ComponentType<P>, props: P & { children?: ComponentChildren | undefined; }, key?: string | undefined): VNode<any>; }
|
||||
|
||||
type: string,
|
||||
>type : string
|
||||
@@ -182,7 +182,7 @@ export function jsxDEV(
|
||||
|
||||
): VNode<any>;
|
||||
export function jsxDEV<P>(
|
||||
>jsxDEV : { (type: string, props: JSXInternal.HTMLAttributes<{}> & JSXInternal.SVGAttributes<{}> & Record<string, any> & { children?: ComponentChildren | undefined; }, key?: string | undefined): VNode<any>; <P>(type: ComponentType<P>, props: Attributes & P & { children?: ComponentChildren;}, key?: string | undefined): VNode<any>; }
|
||||
>jsxDEV : { (type: string, props: JSXInternal.HTMLAttributes<{}> & JSXInternal.SVGAttributes<{}> & Record<string, any> & { children?: ComponentChildren | undefined; }, key?: string | undefined): VNode<any>; <P>(type: ComponentType<P>, props: Attributes & P & { children?: ComponentChildren;}, key?: string): VNode<any>; }
|
||||
|
||||
type: ComponentType<P>,
|
||||
>type : ComponentType<P>
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
//// [tests/cases/conformance/declarationEmit/leaveOptionalParameterAsWritten.ts] ////
|
||||
|
||||
//// [a.ts]
|
||||
export interface Foo {}
|
||||
|
||||
//// [b.ts]
|
||||
import * as a from "./a";
|
||||
declare global {
|
||||
namespace teams {
|
||||
export namespace calling {
|
||||
export import Foo = a.Foo;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//// [c.ts]
|
||||
type Foo = teams.calling.Foo;
|
||||
export const bar = (p?: Foo) => {}
|
||||
|
||||
|
||||
|
||||
//// [a.d.ts]
|
||||
export interface Foo {
|
||||
}
|
||||
//// [b.d.ts]
|
||||
import * as a from "./a";
|
||||
declare global {
|
||||
namespace teams {
|
||||
namespace calling {
|
||||
export import Foo = a.Foo;
|
||||
}
|
||||
}
|
||||
}
|
||||
//// [c.d.ts]
|
||||
declare type Foo = teams.calling.Foo;
|
||||
export declare const bar: (p?: Foo) => void;
|
||||
export {};
|
||||
@@ -0,0 +1,37 @@
|
||||
=== tests/cases/conformance/declarationEmit/a.ts ===
|
||||
export interface Foo {}
|
||||
>Foo : Symbol(Foo, Decl(a.ts, 0, 0))
|
||||
|
||||
=== tests/cases/conformance/declarationEmit/b.ts ===
|
||||
import * as a from "./a";
|
||||
>a : Symbol(a, Decl(b.ts, 0, 6))
|
||||
|
||||
declare global {
|
||||
>global : Symbol(global, Decl(b.ts, 0, 25))
|
||||
|
||||
namespace teams {
|
||||
>teams : Symbol(teams, Decl(b.ts, 1, 16))
|
||||
|
||||
export namespace calling {
|
||||
>calling : Symbol(calling, Decl(b.ts, 2, 19))
|
||||
|
||||
export import Foo = a.Foo;
|
||||
>Foo : Symbol(Foo, Decl(b.ts, 3, 30))
|
||||
>a : Symbol(a, Decl(b.ts, 0, 6))
|
||||
>Foo : Symbol(Foo, Decl(a.ts, 0, 0))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
=== tests/cases/conformance/declarationEmit/c.ts ===
|
||||
type Foo = teams.calling.Foo;
|
||||
>Foo : Symbol(Foo, Decl(c.ts, 0, 0))
|
||||
>teams : Symbol(teams, Decl(b.ts, 1, 16))
|
||||
>calling : Symbol(teams.calling, Decl(b.ts, 2, 19))
|
||||
>Foo : Symbol(teams.calling.Foo, Decl(b.ts, 3, 30))
|
||||
|
||||
export const bar = (p?: Foo) => {}
|
||||
>bar : Symbol(bar, Decl(c.ts, 1, 12))
|
||||
>p : Symbol(p, Decl(c.ts, 1, 20))
|
||||
>Foo : Symbol(Foo, Decl(c.ts, 0, 0))
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
=== tests/cases/conformance/declarationEmit/a.ts ===
|
||||
export interface Foo {}
|
||||
No type information for this code.
|
||||
No type information for this code.=== tests/cases/conformance/declarationEmit/b.ts ===
|
||||
import * as a from "./a";
|
||||
>a : typeof a
|
||||
|
||||
declare global {
|
||||
>global : typeof global
|
||||
|
||||
namespace teams {
|
||||
>teams : typeof teams
|
||||
|
||||
export namespace calling {
|
||||
>calling : typeof calling
|
||||
|
||||
export import Foo = a.Foo;
|
||||
>Foo : any
|
||||
>a : typeof a
|
||||
>Foo : Foo
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
=== tests/cases/conformance/declarationEmit/c.ts ===
|
||||
type Foo = teams.calling.Foo;
|
||||
>Foo : import("tests/cases/conformance/declarationEmit/a").Foo
|
||||
>teams : any
|
||||
>calling : any
|
||||
|
||||
export const bar = (p?: Foo) => {}
|
||||
>bar : (p?: Foo) => void
|
||||
>(p?: Foo) => {} : (p?: Foo) => void
|
||||
>p : import("tests/cases/conformance/declarationEmit/a").Foo | undefined
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
=== tests/cases/conformance/controlFlow/neverReturningFunctions1.ts ===
|
||||
function fail(message?: string): never {
|
||||
>fail : (message?: string | undefined) => never
|
||||
>fail : (message?: string) => never
|
||||
>message : string | undefined
|
||||
|
||||
throw new Error(message);
|
||||
@@ -62,9 +62,9 @@ function f03(x: string) {
|
||||
}
|
||||
|
||||
function f11(x: string | undefined, fail: (message?: string) => never) {
|
||||
>f11 : (x: string | undefined, fail: (message?: string | undefined) => never) => void
|
||||
>f11 : (x: string | undefined, fail: (message?: string) => never) => void
|
||||
>x : string | undefined
|
||||
>fail : (message?: string | undefined) => never
|
||||
>fail : (message?: string) => never
|
||||
>message : string | undefined
|
||||
|
||||
if (x === undefined) fail("undefined argument");
|
||||
@@ -82,9 +82,9 @@ function f11(x: string | undefined, fail: (message?: string) => never) {
|
||||
}
|
||||
|
||||
function f12(x: number, fail: (message?: string) => never): number {
|
||||
>f12 : (x: number, fail: (message?: string | undefined) => never) => number
|
||||
>f12 : (x: number, fail: (message?: string) => never) => number
|
||||
>x : number
|
||||
>fail : (message?: string | undefined) => never
|
||||
>fail : (message?: string) => never
|
||||
>message : string | undefined
|
||||
|
||||
if (x >= 0) return x;
|
||||
@@ -103,9 +103,9 @@ function f12(x: number, fail: (message?: string) => never): number {
|
||||
}
|
||||
|
||||
function f13(x: string, fail: (message?: string) => never) {
|
||||
>f13 : (x: string, fail: (message?: string | undefined) => never) => void
|
||||
>f13 : (x: string, fail: (message?: string) => never) => void
|
||||
>x : string
|
||||
>fail : (message?: string | undefined) => never
|
||||
>fail : (message?: string) => never
|
||||
>message : string | undefined
|
||||
|
||||
x; // string
|
||||
@@ -123,7 +123,7 @@ namespace Debug {
|
||||
>Debug : typeof Debug
|
||||
|
||||
export declare function fail(message?: string): never;
|
||||
>fail : (message?: string | undefined) => never
|
||||
>fail : (message?: string) => never
|
||||
>message : string | undefined
|
||||
}
|
||||
|
||||
@@ -208,7 +208,7 @@ class Test {
|
||||
>Test : Test
|
||||
|
||||
fail(message?: string): never {
|
||||
>fail : (message?: string | undefined) => never
|
||||
>fail : (message?: string) => never
|
||||
>message : string | undefined
|
||||
|
||||
throw new Error(message);
|
||||
@@ -496,7 +496,7 @@ export interface Component<T extends object = any> {
|
||||
>system : any
|
||||
|
||||
init(data?: T): void;
|
||||
>init : (data?: T | undefined) => void
|
||||
>init : (data?: T) => void
|
||||
>data : T | undefined
|
||||
|
||||
pause(): void;
|
||||
|
||||
@@ -5,7 +5,7 @@ interface IListenable {
|
||||
>null : null
|
||||
|
||||
observe(handler: (change: any, oldValue?: any) => void, fireImmediately?: boolean): void
|
||||
>observe : (handler: (change: any, oldValue?: any) => void, fireImmediately?: boolean | undefined) => void
|
||||
>observe : (handler: (change: any, oldValue?: any) => void, fireImmediately?: boolean) => void
|
||||
>handler : (change: any, oldValue?: any) => void
|
||||
>change : any
|
||||
>oldValue : any
|
||||
@@ -62,7 +62,7 @@ export class ObservableValue<T> {
|
||||
>[] : never[]
|
||||
|
||||
observe(handler: (change: any, oldValue?: any) => void, fireImmediately?: boolean) {}
|
||||
>observe : (handler: (change: any, oldValue?: any) => void, fireImmediately?: boolean | undefined) => void
|
||||
>observe : (handler: (change: any, oldValue?: any) => void, fireImmediately?: boolean) => void
|
||||
>handler : (change: any, oldValue?: any) => void
|
||||
>change : any
|
||||
>oldValue : any
|
||||
|
||||
@@ -14,7 +14,7 @@ type ObservedValueOf<O> = O extends ObservableInput<infer T> ? T : never;
|
||||
|
||||
interface Subscribable<T> {
|
||||
subscribe(next?: (value: T) => void, error?: (error: any) => void, complete?: () => void): void;
|
||||
>subscribe : (next?: ((value: T) => void) | undefined, error?: ((error: any) => void) | undefined, complete?: (() => void) | undefined) => void
|
||||
>subscribe : (next?: ((value: T) => void) | undefined, error?: ((error: any) => void) | undefined, complete?: () => void) => void
|
||||
>next : ((value: T) => void) | undefined
|
||||
>value : T
|
||||
>error : ((error: any) => void) | undefined
|
||||
@@ -29,7 +29,7 @@ declare class Observable<T> implements Subscribable<T> {
|
||||
>Observable : Observable<T>
|
||||
|
||||
subscribe(next?: (value: T) => void, error?: (error: any) => void, complete?: () => void): void;
|
||||
>subscribe : (next?: ((value: T) => void) | undefined, error?: ((error: any) => void) | undefined, complete?: (() => void) | undefined) => void
|
||||
>subscribe : (next?: ((value: T) => void) | undefined, error?: ((error: any) => void) | undefined, complete?: () => void) => void
|
||||
>next : ((value: T) => void) | undefined
|
||||
>value : T
|
||||
>error : ((error: any) => void) | undefined
|
||||
|
||||
@@ -9,7 +9,7 @@ let a = {
|
||||
>{ test<K extends keyof Bar> (a: K, b?: Bar[K] | null) { }} : { test<K extends keyof Bar>(a: K, b?: Bar[K] | null | undefined): void; }
|
||||
|
||||
test<K extends keyof Bar> (a: K, b?: Bar[K] | null) { }
|
||||
>test : <K extends keyof Bar>(a: K, b?: Bar[K] | null | undefined) => void
|
||||
>test : <K extends keyof Bar>(a: K, b?: Bar[K] | null) => void
|
||||
>a : K
|
||||
>b : Bar[K] | null | undefined
|
||||
>null : null
|
||||
|
||||
@@ -5,7 +5,7 @@ type Kind = "one" | "two" | "three";
|
||||
>Kind : "one" | "two" | "three"
|
||||
|
||||
declare function getInterfaceFromString<T extends Kind>(options?: { type?: T } & { type?: Kind }): T;
|
||||
>getInterfaceFromString : <T extends Kind>(options?: ({ type?: T | undefined; } & { type?: Kind | undefined; }) | undefined) => T
|
||||
>getInterfaceFromString : <T extends Kind>(options?: { type?: T;} & { type?: Kind;}) => T
|
||||
>options : ({ type?: T | undefined; } & { type?: Kind | undefined; }) | undefined
|
||||
>type : T | undefined
|
||||
>type : Kind | undefined
|
||||
|
||||
@@ -54,7 +54,7 @@ function g2(headerNames: any) {
|
||||
// Object in property or element access is widened when target of assignment
|
||||
|
||||
function foo(options?: { a: string, b: number }) {
|
||||
>foo : (options?: { a: string; b: number; } | undefined) => void
|
||||
>foo : (options?: { a: string; b: number;}) => void
|
||||
>options : { a: string; b: number; } | undefined
|
||||
>a : string
|
||||
>b : number
|
||||
|
||||
@@ -17,7 +17,7 @@ interface Animal {
|
||||
}
|
||||
|
||||
function clonePet(pet: Animal, fullCopy?: boolean) {
|
||||
>clonePet : (pet: Animal, fullCopy?: boolean | undefined) => { name: string; kind: string; age?: number | undefined; location?: string | undefined; owner?: object | undefined; }
|
||||
>clonePet : (pet: Animal, fullCopy?: boolean) => { name: string; kind: string; age?: number | undefined; location?: string | undefined; owner?: object | undefined; }
|
||||
>pet : Animal
|
||||
>fullCopy : boolean | undefined
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ f(undefined)
|
||||
|
||||
|
||||
function g(t?: { a: number } | null): void {
|
||||
>g : (t?: { a: number; } | null | undefined) => void
|
||||
>g : (t?: { a: number;} | null) => void
|
||||
>t : { a: number; } | null | undefined
|
||||
>a : number
|
||||
>null : null
|
||||
|
||||
@@ -7,7 +7,7 @@ declare global {
|
||||
>Model : Model<T, E>
|
||||
|
||||
initialize(attributes?: T, options?: CombinedModelConstructorOptions<E, this>): void;
|
||||
>initialize : (attributes?: T | undefined, options?: CombinedModelConstructorOptions<E, this> | undefined) => void
|
||||
>initialize : (attributes?: T, options?: CombinedModelConstructorOptions<E, this>) => void
|
||||
>attributes : T | undefined
|
||||
>options : CombinedModelConstructorOptions<E, this> | undefined
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ choice(Math.PI);
|
||||
>PI : number
|
||||
|
||||
function sq(n?: number): number {
|
||||
>sq : (n?: number | undefined) => number
|
||||
>sq : (n?: number) => number
|
||||
>n : number | undefined
|
||||
|
||||
const r = n !== undefined && n*n || 0;
|
||||
|
||||
@@ -13,11 +13,11 @@ type Subset<T, U> = { [key in keyof T]: key extends keyof U ? T[key] : never };
|
||||
>Subset : Subset<T, U>
|
||||
|
||||
declare function withBoundary<T extends UserArgs>(args?: Subset<T, UserArgs>): T;
|
||||
>withBoundary : <T extends UserArgs>(args?: Subset<T, UserArgs> | undefined) => T
|
||||
>withBoundary : <T extends UserArgs>(args?: Subset<T, UserArgs>) => T
|
||||
>args : Subset<T, UserArgs> | undefined
|
||||
|
||||
declare function withoutBoundary<T extends UserArgs>(args?: T): T;
|
||||
>withoutBoundary : <T extends UserArgs>(args?: T | undefined) => T
|
||||
>withoutBoundary : <T extends UserArgs>(args?: T) => T
|
||||
>args : T | undefined
|
||||
|
||||
const boundaryResult = withBoundary({
|
||||
|
||||
@@ -72,7 +72,7 @@ let obj1 = {
|
||||
// contextual type.
|
||||
|
||||
type Point = {
|
||||
>Point : { x: number; y: number; z?: number | undefined; moveBy(dx: number, dy: number, dz?: number | undefined): void; }
|
||||
>Point : { x: number; y: number; z?: number | undefined; moveBy(dx: number, dy: number, dz?: number): void; }
|
||||
|
||||
x: number;
|
||||
>x : number
|
||||
@@ -84,7 +84,7 @@ type Point = {
|
||||
>z : number | undefined
|
||||
|
||||
moveBy(dx: number, dy: number, dz?: number): void;
|
||||
>moveBy : (dx: number, dy: number, dz?: number | undefined) => void
|
||||
>moveBy : (dx: number, dy: number, dz?: number) => void
|
||||
>dx : number
|
||||
>dy : number
|
||||
>dz : number | undefined
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
=== tests/cases/compiler/truthinessCallExpressionCoercion.ts ===
|
||||
function onlyErrorsWhenTestingNonNullableFunctionType(required: () => boolean, optional?: () => boolean) {
|
||||
>onlyErrorsWhenTestingNonNullableFunctionType : (required: () => boolean, optional?: (() => boolean) | undefined) => void
|
||||
>onlyErrorsWhenTestingNonNullableFunctionType : (required: () => boolean, optional?: () => boolean) => void
|
||||
>required : () => boolean
|
||||
>optional : (() => boolean) | undefined
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
=== tests/cases/compiler/truthinessCallExpressionCoercion1.ts ===
|
||||
function onlyErrorsWhenTestingNonNullableFunctionType(required: () => boolean, optional?: () => boolean) {
|
||||
>onlyErrorsWhenTestingNonNullableFunctionType : (required: () => boolean, optional?: (() => boolean) | undefined) => void
|
||||
>onlyErrorsWhenTestingNonNullableFunctionType : (required: () => boolean, optional?: () => boolean) => void
|
||||
>required : () => boolean
|
||||
>optional : (() => boolean) | undefined
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ declare class B {
|
||||
}
|
||||
|
||||
function test(required1: () => boolean, required2: () => boolean, b: boolean, optional?: () => boolean) {
|
||||
>test : (required1: () => boolean, required2: () => boolean, b: boolean, optional?: (() => boolean) | undefined) => void
|
||||
>test : (required1: () => boolean, required2: () => boolean, b: boolean, optional?: () => boolean) => void
|
||||
>required1 : () => boolean
|
||||
>required2 : () => boolean
|
||||
>b : boolean
|
||||
|
||||
@@ -15,9 +15,9 @@ declare const val: ReturnVal;
|
||||
>val : ReturnVal
|
||||
|
||||
function run(options: { something?(b?: string): void }) {
|
||||
>run : (options: { something?(b?: string | undefined): void; }) => void
|
||||
>options : { something?(b?: string | undefined): void; }
|
||||
>something : ((b?: string | undefined) => void) | undefined
|
||||
>run : (options: { something?(b?: string): void; }) => void
|
||||
>options : { something?(b?: string): void; }
|
||||
>something : ((b?: string) => void) | undefined
|
||||
>b : string | undefined
|
||||
|
||||
const something = options.something ?? val.something;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
=== tests/cases/conformance/types/union/unionTypeReduction2.ts ===
|
||||
function f1(x: { f(): void }, y: { f(x?: string): void }) {
|
||||
>f1 : (x: { f(): void;}, y: { f(x?: string | undefined): void; }) => void
|
||||
>f1 : (x: { f(): void;}, y: { f(x?: string): void; }) => void
|
||||
>x : { f(): void; }
|
||||
>f : () => void
|
||||
>y : { f(x?: string | undefined): void; }
|
||||
>f : (x?: string | undefined) => void
|
||||
>y : { f(x?: string): void; }
|
||||
>f : (x?: string) => void
|
||||
>x : string | undefined
|
||||
|
||||
let z = !!true ? x : y; // { f(x?: string): void }
|
||||
@@ -31,12 +31,12 @@ function f1(x: { f(): void }, y: { f(x?: string): void }) {
|
||||
}
|
||||
|
||||
function f2(x: { f(x: string | undefined): void }, y: { f(x?: string): void }) {
|
||||
>f2 : (x: { f(x: string | undefined): void; }, y: { f(x?: string | undefined): void; }) => void
|
||||
>f2 : (x: { f(x: string | undefined): void; }, y: { f(x?: string): void; }) => void
|
||||
>x : { f(x: string | undefined): void; }
|
||||
>f : (x: string | undefined) => void
|
||||
>x : string | undefined
|
||||
>y : { f(x?: string | undefined): void; }
|
||||
>f : (x?: string | undefined) => void
|
||||
>y : { f(x?: string): void; }
|
||||
>f : (x?: string) => void
|
||||
>x : string | undefined
|
||||
|
||||
let z = !!true ? x : y; // { f(x?: string): void }
|
||||
@@ -63,9 +63,9 @@ function f2(x: { f(x: string | undefined): void }, y: { f(x?: string): void }) {
|
||||
}
|
||||
|
||||
function f3(x: () => void, y: (x?: string) => void) {
|
||||
>f3 : (x: () => void, y: (x?: string | undefined) => void) => void
|
||||
>f3 : (x: () => void, y: (x?: string) => void) => void
|
||||
>x : () => void
|
||||
>y : (x?: string | undefined) => void
|
||||
>y : (x?: string) => void
|
||||
>x : string | undefined
|
||||
|
||||
let f = !!true ? x : y; // (x?: string) => void
|
||||
@@ -88,10 +88,10 @@ function f3(x: () => void, y: (x?: string) => void) {
|
||||
}
|
||||
|
||||
function f4(x: (x: string | undefined) => void, y: (x?: string) => void) {
|
||||
>f4 : (x: (x: string | undefined) => void, y: (x?: string | undefined) => void) => void
|
||||
>f4 : (x: (x: string | undefined) => void, y: (x?: string) => void) => void
|
||||
>x : (x: string | undefined) => void
|
||||
>x : string | undefined
|
||||
>y : (x?: string | undefined) => void
|
||||
>y : (x?: string) => void
|
||||
>x : string | undefined
|
||||
|
||||
let f = !!true ? x : y; // (x?: string) => void
|
||||
@@ -114,10 +114,10 @@ function f4(x: (x: string | undefined) => void, y: (x?: string) => void) {
|
||||
}
|
||||
|
||||
function f5(x: (x: string | undefined) => void, y: (x?: 'hello') => void) {
|
||||
>f5 : (x: (x: string | undefined) => void, y: (x?: "hello" | undefined) => void) => void
|
||||
>f5 : (x: (x: string | undefined) => void, y: (x?: 'hello') => void) => void
|
||||
>x : (x: string | undefined) => void
|
||||
>x : string | undefined
|
||||
>y : (x?: "hello" | undefined) => void
|
||||
>y : (x?: 'hello') => void
|
||||
>x : "hello" | undefined
|
||||
|
||||
let f = !!true ? x : y; // (x?: 'hello') => void
|
||||
@@ -140,10 +140,10 @@ function f5(x: (x: string | undefined) => void, y: (x?: 'hello') => void) {
|
||||
}
|
||||
|
||||
function f6(x: (x: 'hello' | undefined) => void, y: (x?: string) => void) {
|
||||
>f6 : (x: (x: 'hello' | undefined) => void, y: (x?: string | undefined) => void) => void
|
||||
>f6 : (x: (x: 'hello' | undefined) => void, y: (x?: string) => void) => void
|
||||
>x : (x: 'hello' | undefined) => void
|
||||
>x : "hello" | undefined
|
||||
>y : (x?: string | undefined) => void
|
||||
>y : (x?: string) => void
|
||||
>x : string | undefined
|
||||
|
||||
let f = !!true ? x : y; // (x: 'hello' | undefined) => void
|
||||
@@ -173,10 +173,10 @@ type A = {
|
||||
}
|
||||
|
||||
type B = {
|
||||
>B : { f(x?: string | undefined): void; g(): void; }
|
||||
>B : { f(x?: string): void; g(): void; }
|
||||
|
||||
f(x?: string): void;
|
||||
>f : (x?: string | undefined) => void
|
||||
>f : (x?: string) => void
|
||||
>x : string | undefined
|
||||
|
||||
g(): void;
|
||||
@@ -227,9 +227,9 @@ declare const val: ReturnVal;
|
||||
>val : ReturnVal
|
||||
|
||||
function run(options: { something?(b?: string): void }) {
|
||||
>run : (options: { something?(b?: string | undefined): void; }) => void
|
||||
>options : { something?(b?: string | undefined): void; }
|
||||
>something : ((b?: string | undefined) => void) | undefined
|
||||
>run : (options: { something?(b?: string): void; }) => void
|
||||
>options : { something?(b?: string): void; }
|
||||
>something : ((b?: string) => void) | undefined
|
||||
>b : string | undefined
|
||||
|
||||
const something = options.something ?? val.something;
|
||||
|
||||
@@ -1349,13 +1349,13 @@ const b = a.bind("", 1); // Desc<[boolean], object>
|
||||
// Repro from #39607
|
||||
|
||||
declare function getUser(id: string, options?: { x?: string }): string;
|
||||
>getUser : (id: string, options?: { x?: string | undefined; } | undefined) => string
|
||||
>getUser : (id: string, options?: { x?: string;}) => string
|
||||
>id : string
|
||||
>options : { x?: string | undefined; } | undefined
|
||||
>x : string | undefined
|
||||
|
||||
declare function getOrgUser(id: string, orgId: number, options?: { y?: number, z?: boolean }): void;
|
||||
>getOrgUser : (id: string, orgId: number, options?: { y?: number | undefined; z?: boolean | undefined; } | undefined) => void
|
||||
>getOrgUser : (id: string, orgId: number, options?: { y?: number; z?: boolean;}) => void
|
||||
>id : string
|
||||
>orgId : number
|
||||
>options : { y?: number | undefined; z?: boolean | undefined; } | undefined
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
// @module: esnext
|
||||
// @outDir: dist
|
||||
// @declaration: true
|
||||
// @emitDeclarationOnly: true
|
||||
// @strictNullChecks: true
|
||||
|
||||
// @Filename: a.ts
|
||||
export interface Foo {}
|
||||
|
||||
// @Filename: b.ts
|
||||
import * as a from "./a";
|
||||
declare global {
|
||||
namespace teams {
|
||||
export namespace calling {
|
||||
export import Foo = a.Foo;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// @Filename: c.ts
|
||||
type Foo = teams.calling.Foo;
|
||||
export const bar = (p?: Foo) => {}
|
||||
Reference in New Issue
Block a user