|
| 1 | +//// [declarationEmitGlobalThisPreserved.ts] |
| 2 | +// Adding this makes tooltips fail too. |
| 3 | +// declare global { |
| 4 | +// namespace isNaN { |
| 5 | +// const prop: number; |
| 6 | +// } |
| 7 | +// } |
| 8 | + |
| 9 | +// Broken inference cases. |
| 10 | + |
| 11 | +export const a1 = (isNaN: typeof globalThis.isNaN): typeof globalThis.isNaN => isNaN; |
| 12 | +export const a2 = (isNaN: typeof globalThis.isNaN, bar?: typeof globalThis.isNaN): typeof globalThis.isNaN => bar ?? isNaN; |
| 13 | +export const a3 = (isNaN: number, bar: typeof globalThis.isNaN): typeof globalThis.isNaN => bar; |
| 14 | +export const a4 = (isNaN: number): typeof globalThis.isNaN => globalThis.isNaN; |
| 15 | + |
| 16 | +export const aObj = { |
| 17 | + a1: (isNaN: typeof globalThis.isNaN): typeof globalThis.isNaN => isNaN, |
| 18 | + a2: (isNaN: typeof globalThis.isNaN, bar?: typeof globalThis.isNaN): typeof globalThis.isNaN => bar ?? isNaN, |
| 19 | + a3: (isNaN: number, bar: typeof globalThis.isNaN): typeof globalThis.isNaN => bar, |
| 20 | + a4: (isNaN: number): typeof globalThis.isNaN => globalThis.isNaN, |
| 21 | +} |
| 22 | + |
| 23 | +export type a4Return = ReturnType<ReturnType<typeof a4>>; |
| 24 | +export type a4oReturn = ReturnType<ReturnType<typeof aObj['a4']>>; |
| 25 | + |
| 26 | +export const b1 = (isNaN: typeof globalThis.isNaN) => isNaN; |
| 27 | +export const b2 = (isNaN: typeof globalThis.isNaN, bar?: typeof globalThis.isNaN) => bar ?? isNaN; |
| 28 | +export const b3 = (isNaN: number, bar: typeof globalThis.isNaN) => bar; |
| 29 | +export const b4 = (isNaN: number) => globalThis.isNaN; |
| 30 | + |
| 31 | +export const bObj = { |
| 32 | + b1: (isNaN: typeof globalThis.isNaN) => isNaN, |
| 33 | + b2: (isNaN: typeof globalThis.isNaN, bar?: typeof globalThis.isNaN) => bar ?? isNaN, |
| 34 | + b3: (isNaN: number, bar: typeof globalThis.isNaN) => bar, |
| 35 | + b4: (isNaN: number) => globalThis.isNaN, |
| 36 | +} |
| 37 | + |
| 38 | +export type b4Return = ReturnType<ReturnType<typeof b4>>; |
| 39 | +export type b4oReturn = ReturnType<ReturnType<typeof bObj['b4']>>; |
| 40 | + |
| 41 | +export function c1(isNaN: typeof globalThis.isNaN) { return isNaN } |
| 42 | +export function c2(isNaN: typeof globalThis.isNaN, bar?: typeof globalThis.isNaN) { return bar ?? isNaN } |
| 43 | +export function c3(isNaN: number, bar: typeof globalThis.isNaN) { return bar } |
| 44 | +export function c4(isNaN: number) { return globalThis.isNaN; } |
| 45 | + |
| 46 | +export const cObj = { |
| 47 | + c1(isNaN: typeof globalThis.isNaN) { return isNaN }, |
| 48 | + c2(isNaN: typeof globalThis.isNaN, bar?: typeof globalThis.isNaN) { return bar ?? isNaN }, |
| 49 | + c3(isNaN: number, bar: typeof globalThis.isNaN) { return bar }, |
| 50 | + c4(isNaN: number) { return globalThis.isNaN; }, |
| 51 | +} |
| 52 | + |
| 53 | +export type c4Return = ReturnType<ReturnType<typeof c4>>; |
| 54 | +export type c4oReturn = ReturnType<ReturnType<typeof cObj['c4']>>; |
| 55 | + |
| 56 | +export function d1() { |
| 57 | + const fn = (isNaN: typeof globalThis.isNaN): typeof globalThis.isNaN => isNaN; |
| 58 | + return function() { return fn }; |
| 59 | +} |
| 60 | + |
| 61 | +export function d2() { |
| 62 | + const fn = (isNaN: typeof globalThis.isNaN, bar?: typeof globalThis.isNaN): typeof globalThis.isNaN => bar ?? isNaN; |
| 63 | + return function() { return fn }; |
| 64 | +} |
| 65 | + |
| 66 | +export function d3() { |
| 67 | + const fn = (isNaN: number, bar: typeof globalThis.isNaN): typeof globalThis.isNaN => bar; |
| 68 | + return function() { return fn }; |
| 69 | +} |
| 70 | + |
| 71 | +export function d4() { |
| 72 | + const fn = (isNaN: number): typeof globalThis.isNaN => globalThis.isNaN; |
| 73 | + return function() { return fn }; |
| 74 | +} |
| 75 | + |
| 76 | +export type d4Return = ReturnType<ReturnType<ReturnType<ReturnType<typeof d4>>>>; |
| 77 | + |
| 78 | +export class A { |
| 79 | + method1(isNaN: typeof globalThis.isNaN) { return isNaN } |
| 80 | + method2(isNaN: typeof globalThis.isNaN, bar?: typeof globalThis.isNaN) { return bar ?? isNaN } |
| 81 | + method3(isNaN: number, bar: typeof globalThis.isNaN) { return bar } |
| 82 | + method4(isNaN: number) { return globalThis.isNaN; } |
| 83 | +} |
| 84 | + |
| 85 | +export function fromParameter(isNaN: number, bar: typeof globalThis.isNaN) { |
| 86 | + return function() { return { bar } }; |
| 87 | +} |
| 88 | + |
| 89 | +// Non-inference cases. |
| 90 | + |
| 91 | +export const explicitlyTypedVariable: (isNaN: typeof globalThis.isNaN) => typeof globalThis.isNaN = (isNaN) => isNaN; |
| 92 | + |
| 93 | +export function explicitlyTypedFunction(isNaN: typeof globalThis.isNaN): typeof globalThis.isNaN { |
| 94 | + return isNaN; |
| 95 | +}; |
| 96 | + |
| 97 | +export type AsObjectProperty = { |
| 98 | + isNaN: typeof globalThis.isNaN; |
| 99 | +} |
| 100 | + |
| 101 | +export class AsClassProperty { |
| 102 | + isNaN?: typeof globalThis.isNaN; |
| 103 | +} |
| 104 | + |
| 105 | +export type AsFunctionType = (isNaN: typeof globalThis.isNaN) => typeof globalThis.isNaN; |
| 106 | + |
| 107 | + |
| 108 | + |
| 109 | + |
| 110 | + |
| 111 | +//// [declarationEmitGlobalThisPreserved.d.ts] |
| 112 | +export declare const a1: (isNaN: typeof globalThis.isNaN) => typeof globalThis.isNaN; |
| 113 | +export declare const a2: (isNaN: typeof globalThis.isNaN, bar?: typeof globalThis.isNaN) => typeof globalThis.isNaN; |
| 114 | +export declare const a3: (isNaN: number, bar: typeof globalThis.isNaN) => typeof globalThis.isNaN; |
| 115 | +export declare const a4: (isNaN: number) => typeof globalThis.isNaN; |
| 116 | +export declare const aObj: { |
| 117 | + a1: (isNaN: typeof globalThis.isNaN) => typeof globalThis.isNaN; |
| 118 | + a2: (isNaN: typeof globalThis.isNaN, bar?: typeof globalThis.isNaN) => typeof globalThis.isNaN; |
| 119 | + a3: (isNaN: number, bar: typeof globalThis.isNaN) => typeof globalThis.isNaN; |
| 120 | + a4: (isNaN: number) => typeof globalThis.isNaN; |
| 121 | +}; |
| 122 | +export type a4Return = ReturnType<ReturnType<typeof a4>>; |
| 123 | +export type a4oReturn = ReturnType<ReturnType<typeof aObj['a4']>>; |
| 124 | +export declare const b1: (isNaN: typeof globalThis.isNaN) => typeof globalThis.isNaN; |
| 125 | +export declare const b2: (isNaN: typeof globalThis.isNaN, bar?: typeof globalThis.isNaN) => typeof globalThis.isNaN; |
| 126 | +export declare const b3: (isNaN: number, bar: typeof globalThis.isNaN) => typeof globalThis.isNaN; |
| 127 | +export declare const b4: (isNaN: number) => typeof globalThis.isNaN; |
| 128 | +export declare const bObj: { |
| 129 | + b1: (isNaN: typeof globalThis.isNaN) => typeof globalThis.isNaN; |
| 130 | + b2: (isNaN: typeof globalThis.isNaN, bar?: typeof globalThis.isNaN) => typeof globalThis.isNaN; |
| 131 | + b3: (isNaN: number, bar: typeof globalThis.isNaN) => typeof globalThis.isNaN; |
| 132 | + b4: (isNaN: number) => typeof globalThis.isNaN; |
| 133 | +}; |
| 134 | +export type b4Return = ReturnType<ReturnType<typeof b4>>; |
| 135 | +export type b4oReturn = ReturnType<ReturnType<typeof bObj['b4']>>; |
| 136 | +export declare function c1(isNaN: typeof globalThis.isNaN): typeof globalThis.isNaN; |
| 137 | +export declare function c2(isNaN: typeof globalThis.isNaN, bar?: typeof globalThis.isNaN): typeof globalThis.isNaN; |
| 138 | +export declare function c3(isNaN: number, bar: typeof globalThis.isNaN): typeof globalThis.isNaN; |
| 139 | +export declare function c4(isNaN: number): typeof globalThis.isNaN; |
| 140 | +export declare const cObj: { |
| 141 | + c1(isNaN: typeof globalThis.isNaN): typeof globalThis.isNaN; |
| 142 | + c2(isNaN: typeof globalThis.isNaN, bar?: typeof globalThis.isNaN): typeof globalThis.isNaN; |
| 143 | + c3(isNaN: number, bar: typeof globalThis.isNaN): typeof globalThis.isNaN; |
| 144 | + c4(isNaN: number): typeof globalThis.isNaN; |
| 145 | +}; |
| 146 | +export type c4Return = ReturnType<ReturnType<typeof c4>>; |
| 147 | +export type c4oReturn = ReturnType<ReturnType<typeof cObj['c4']>>; |
| 148 | +export declare function d1(): () => (isNaN: typeof globalThis.isNaN) => typeof globalThis.isNaN; |
| 149 | +export declare function d2(): () => (isNaN: typeof globalThis.isNaN, bar?: typeof globalThis.isNaN) => typeof globalThis.isNaN; |
| 150 | +export declare function d3(): () => (isNaN: number, bar: typeof globalThis.isNaN) => typeof globalThis.isNaN; |
| 151 | +export declare function d4(): () => (isNaN: number) => typeof globalThis.isNaN; |
| 152 | +export type d4Return = ReturnType<ReturnType<ReturnType<ReturnType<typeof d4>>>>; |
| 153 | +export declare class A { |
| 154 | + method1(isNaN: typeof globalThis.isNaN): typeof globalThis.isNaN; |
| 155 | + method2(isNaN: typeof globalThis.isNaN, bar?: typeof globalThis.isNaN): typeof globalThis.isNaN; |
| 156 | + method3(isNaN: number, bar: typeof globalThis.isNaN): typeof globalThis.isNaN; |
| 157 | + method4(isNaN: number): typeof globalThis.isNaN; |
| 158 | +} |
| 159 | +export declare function fromParameter(isNaN: number, bar: typeof globalThis.isNaN): () => { |
| 160 | + bar: typeof globalThis.isNaN; |
| 161 | +}; |
| 162 | +export declare const explicitlyTypedVariable: (isNaN: typeof globalThis.isNaN) => typeof globalThis.isNaN; |
| 163 | +export declare function explicitlyTypedFunction(isNaN: typeof globalThis.isNaN): typeof globalThis.isNaN; |
| 164 | +export type AsObjectProperty = { |
| 165 | + isNaN: typeof globalThis.isNaN; |
| 166 | +}; |
| 167 | +export declare class AsClassProperty { |
| 168 | + isNaN?: typeof globalThis.isNaN; |
| 169 | +} |
| 170 | +export type AsFunctionType = (isNaN: typeof globalThis.isNaN) => typeof globalThis.isNaN; |
0 commit comments