mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
139 lines
4.7 KiB
Plaintext
139 lines
4.7 KiB
Plaintext
//// [tests/cases/compiler/implicitConstParameters.ts] ////
|
|
|
|
=== implicitConstParameters.ts ===
|
|
function doSomething(cb: () => void) {
|
|
>doSomething : Symbol(doSomething, Decl(implicitConstParameters.ts, 0, 0))
|
|
>cb : Symbol(cb, Decl(implicitConstParameters.ts, 0, 21))
|
|
|
|
cb();
|
|
>cb : Symbol(cb, Decl(implicitConstParameters.ts, 0, 21))
|
|
}
|
|
|
|
function fn(x: number | string) {
|
|
>fn : Symbol(fn, Decl(implicitConstParameters.ts, 2, 1))
|
|
>x : Symbol(x, Decl(implicitConstParameters.ts, 4, 12))
|
|
|
|
if (typeof x === 'number') {
|
|
>x : Symbol(x, Decl(implicitConstParameters.ts, 4, 12))
|
|
|
|
doSomething(() => x.toFixed());
|
|
>doSomething : Symbol(doSomething, Decl(implicitConstParameters.ts, 0, 0))
|
|
>x.toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --))
|
|
>x : Symbol(x, Decl(implicitConstParameters.ts, 4, 12))
|
|
>toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --))
|
|
}
|
|
}
|
|
|
|
function f1(x: string | undefined) {
|
|
>f1 : Symbol(f1, Decl(implicitConstParameters.ts, 8, 1))
|
|
>x : Symbol(x, Decl(implicitConstParameters.ts, 10, 12))
|
|
|
|
if (!x) {
|
|
>x : Symbol(x, Decl(implicitConstParameters.ts, 10, 12))
|
|
|
|
return;
|
|
}
|
|
doSomething(() => x.length);
|
|
>doSomething : Symbol(doSomething, Decl(implicitConstParameters.ts, 0, 0))
|
|
>x.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
|
>x : Symbol(x, Decl(implicitConstParameters.ts, 10, 12))
|
|
>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
|
}
|
|
|
|
function f2(x: string | undefined) {
|
|
>f2 : Symbol(f2, Decl(implicitConstParameters.ts, 15, 1))
|
|
>x : Symbol(x, Decl(implicitConstParameters.ts, 17, 12))
|
|
|
|
if (x) {
|
|
>x : Symbol(x, Decl(implicitConstParameters.ts, 17, 12))
|
|
|
|
doSomething(() => {
|
|
>doSomething : Symbol(doSomething, Decl(implicitConstParameters.ts, 0, 0))
|
|
|
|
doSomething(() => x.length);
|
|
>doSomething : Symbol(doSomething, Decl(implicitConstParameters.ts, 0, 0))
|
|
>x.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
|
>x : Symbol(x, Decl(implicitConstParameters.ts, 17, 12))
|
|
>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
|
|
|
});
|
|
}
|
|
}
|
|
|
|
function f3(x: string | undefined) {
|
|
>f3 : Symbol(f3, Decl(implicitConstParameters.ts, 23, 1))
|
|
>x : Symbol(x, Decl(implicitConstParameters.ts, 25, 12))
|
|
|
|
inner();
|
|
>inner : Symbol(inner, Decl(implicitConstParameters.ts, 26, 12))
|
|
|
|
function inner() {
|
|
>inner : Symbol(inner, Decl(implicitConstParameters.ts, 26, 12))
|
|
|
|
if (x) {
|
|
>x : Symbol(x, Decl(implicitConstParameters.ts, 25, 12))
|
|
|
|
doSomething(() => x.length);
|
|
>doSomething : Symbol(doSomething, Decl(implicitConstParameters.ts, 0, 0))
|
|
>x.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
|
>x : Symbol(x, Decl(implicitConstParameters.ts, 25, 12))
|
|
>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
|
}
|
|
}
|
|
}
|
|
|
|
function f4(x: string | undefined) {
|
|
>f4 : Symbol(f4, Decl(implicitConstParameters.ts, 32, 1))
|
|
>x : Symbol(x, Decl(implicitConstParameters.ts, 34, 12))
|
|
|
|
x = "abc";
|
|
>x : Symbol(x, Decl(implicitConstParameters.ts, 34, 12))
|
|
|
|
if (x) {
|
|
>x : Symbol(x, Decl(implicitConstParameters.ts, 34, 12))
|
|
|
|
doSomething(() => x.length);
|
|
>doSomething : Symbol(doSomething, Decl(implicitConstParameters.ts, 0, 0))
|
|
>x.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
|
>x : Symbol(x, Decl(implicitConstParameters.ts, 34, 12))
|
|
>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
|
}
|
|
}
|
|
|
|
function f5(x: string | undefined) {
|
|
>f5 : Symbol(f5, Decl(implicitConstParameters.ts, 39, 1))
|
|
>x : Symbol(x, Decl(implicitConstParameters.ts, 41, 12))
|
|
|
|
if (x) {
|
|
>x : Symbol(x, Decl(implicitConstParameters.ts, 41, 12))
|
|
|
|
doSomething(() => x.length);
|
|
>doSomething : Symbol(doSomething, Decl(implicitConstParameters.ts, 0, 0))
|
|
>x.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
|
>x : Symbol(x, Decl(implicitConstParameters.ts, 41, 12))
|
|
>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
|
}
|
|
x = "abc"; // causes x to be considered non-const
|
|
>x : Symbol(x, Decl(implicitConstParameters.ts, 41, 12))
|
|
}
|
|
|
|
|
|
function f6(x: string | undefined) {
|
|
>f6 : Symbol(f6, Decl(implicitConstParameters.ts, 46, 1))
|
|
>x : Symbol(x, Decl(implicitConstParameters.ts, 49, 12))
|
|
|
|
const y = x || "";
|
|
>y : Symbol(y, Decl(implicitConstParameters.ts, 50, 9))
|
|
>x : Symbol(x, Decl(implicitConstParameters.ts, 49, 12))
|
|
|
|
if (x) {
|
|
>x : Symbol(x, Decl(implicitConstParameters.ts, 49, 12))
|
|
|
|
doSomething(() => y.length);
|
|
>doSomething : Symbol(doSomething, Decl(implicitConstParameters.ts, 0, 0))
|
|
>y.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
|
>y : Symbol(y, Decl(implicitConstParameters.ts, 50, 9))
|
|
>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --))
|
|
}
|
|
}
|