Skip to content

Commit f1ec936

Browse files
committed
oops
1 parent 34ec1c2 commit f1ec936

15 files changed

+443
-0
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
//// [tests/cases/compiler/strictBestCommonSupertype.ts] ////
2+
3+
=== strictBestCommonSupertype.ts ===
4+
// https://github.com/microsoft/typescript-go/issues/1222
5+
6+
class Store<T = object> {
7+
>Store : Symbol(Store, Decl(strictBestCommonSupertype.ts, 0, 0))
8+
>T : Symbol(T, Decl(strictBestCommonSupertype.ts, 2, 12))
9+
10+
select<K>(mapFn: (state: T) => K) {};
11+
>select : Symbol(select, Decl(strictBestCommonSupertype.ts, 2, 25))
12+
>K : Symbol(K, Decl(strictBestCommonSupertype.ts, 3, 11))
13+
>mapFn : Symbol(mapFn, Decl(strictBestCommonSupertype.ts, 3, 14))
14+
>state : Symbol(state, Decl(strictBestCommonSupertype.ts, 3, 22))
15+
>T : Symbol(T, Decl(strictBestCommonSupertype.ts, 2, 12))
16+
>K : Symbol(K, Decl(strictBestCommonSupertype.ts, 3, 11))
17+
}
18+
19+
const store: Store = inject(Store);
20+
>store : Symbol(store, Decl(strictBestCommonSupertype.ts, 6, 5))
21+
>Store : Symbol(Store, Decl(strictBestCommonSupertype.ts, 0, 0))
22+
>inject : Symbol(inject, Decl(strictBestCommonSupertype.ts, 6, 35))
23+
>Store : Symbol(Store, Decl(strictBestCommonSupertype.ts, 0, 0))
24+
25+
function inject<T>(token: ProviderToken<T>): T {
26+
>inject : Symbol(inject, Decl(strictBestCommonSupertype.ts, 6, 35))
27+
>T : Symbol(T, Decl(strictBestCommonSupertype.ts, 8, 16))
28+
>token : Symbol(token, Decl(strictBestCommonSupertype.ts, 8, 19))
29+
>ProviderToken : Symbol(ProviderToken, Decl(strictBestCommonSupertype.ts, 14, 1))
30+
>T : Symbol(T, Decl(strictBestCommonSupertype.ts, 8, 16))
31+
>T : Symbol(T, Decl(strictBestCommonSupertype.ts, 8, 16))
32+
33+
return {} as T;
34+
>T : Symbol(T, Decl(strictBestCommonSupertype.ts, 8, 16))
35+
}
36+
37+
interface Type<T> extends Function {
38+
>Type : Symbol(Type, Decl(strictBestCommonSupertype.ts, 10, 1))
39+
>T : Symbol(T, Decl(strictBestCommonSupertype.ts, 12, 15))
40+
>Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
41+
42+
new (...args: any[]): T;
43+
>args : Symbol(args, Decl(strictBestCommonSupertype.ts, 13, 9))
44+
>T : Symbol(T, Decl(strictBestCommonSupertype.ts, 12, 15))
45+
}
46+
47+
type ProviderToken<T> = Type<T> | AbstractType<T>;
48+
>ProviderToken : Symbol(ProviderToken, Decl(strictBestCommonSupertype.ts, 14, 1))
49+
>T : Symbol(T, Decl(strictBestCommonSupertype.ts, 16, 19))
50+
>Type : Symbol(Type, Decl(strictBestCommonSupertype.ts, 10, 1))
51+
>T : Symbol(T, Decl(strictBestCommonSupertype.ts, 16, 19))
52+
>AbstractType : Symbol(AbstractType, Decl(strictBestCommonSupertype.ts, 16, 50))
53+
>T : Symbol(T, Decl(strictBestCommonSupertype.ts, 16, 19))
54+
55+
interface AbstractType<T> extends Function {
56+
>AbstractType : Symbol(AbstractType, Decl(strictBestCommonSupertype.ts, 16, 50))
57+
>T : Symbol(T, Decl(strictBestCommonSupertype.ts, 18, 23))
58+
>Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
59+
60+
prototype: T;
61+
>prototype : Symbol(prototype, Decl(strictBestCommonSupertype.ts, 18, 44))
62+
>T : Symbol(T, Decl(strictBestCommonSupertype.ts, 18, 23))
63+
}
64+
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
//// [tests/cases/compiler/strictBestCommonSupertype.ts] ////
2+
3+
=== strictBestCommonSupertype.ts ===
4+
// https://github.com/microsoft/typescript-go/issues/1222
5+
6+
class Store<T = object> {
7+
>Store : Store<T>
8+
9+
select<K>(mapFn: (state: T) => K) {};
10+
>select : <K>(mapFn: (state: T) => K) => void
11+
>mapFn : (state: T) => K
12+
>state : T
13+
}
14+
15+
const store: Store = inject(Store);
16+
>store : Store<object>
17+
>inject(Store) : Store<any>
18+
>inject : <T>(token: ProviderToken<T>) => T
19+
>Store : typeof Store
20+
21+
function inject<T>(token: ProviderToken<T>): T {
22+
>inject : <T>(token: ProviderToken<T>) => T
23+
>token : ProviderToken<T>
24+
25+
return {} as T;
26+
>{} as T : T
27+
>{} : {}
28+
}
29+
30+
interface Type<T> extends Function {
31+
new (...args: any[]): T;
32+
>args : any[]
33+
}
34+
35+
type ProviderToken<T> = Type<T> | AbstractType<T>;
36+
>ProviderToken : ProviderToken<T>
37+
38+
interface AbstractType<T> extends Function {
39+
prototype: T;
40+
>prototype : T
41+
}
42+
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
//// [tests/cases/compiler/subpathImportDeclarationEmit.ts] ////
2+
3+
//// [package.json]
4+
{
5+
"name": "pkg",
6+
"type": "module",
7+
"imports": {
8+
"#subpath": "./src/subpath.ts"
9+
},
10+
"exports": {
11+
"./*": "./dist/*"
12+
}
13+
}
14+
15+
//// [subpath.ts]
16+
async function bar(): Promise<string> {
17+
return "bar";
18+
}
19+
export const barrel = { bar };
20+
21+
//// [indirect.ts]
22+
import { barrel } from "#subpath";
23+
const { bar } = barrel;
24+
export { bar };
25+
26+
//// [main.ts]
27+
import { bar } from "./indirect.js";
28+
console.log(await bar());
29+
30+
31+
//// [subpath.js]
32+
async function bar() {
33+
return "bar";
34+
}
35+
export const barrel = { bar };
36+
//// [indirect.js]
37+
import { barrel } from "#subpath";
38+
const { bar } = barrel;
39+
export { bar };
40+
//// [main.js]
41+
import { bar } from "./indirect.js";
42+
console.log(await bar());
43+
44+
45+
//// [subpath.d.ts]
46+
declare function bar(): Promise<string>;
47+
export declare const barrel: {
48+
bar: typeof bar;
49+
};
50+
export {};
51+
//// [indirect.d.ts]
52+
declare const bar: () => Promise<string>;
53+
export { bar };
54+
//// [main.d.ts]
55+
export {};
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//// [tests/cases/compiler/subpathImportDeclarationEmit.ts] ////
2+
3+
=== /src/main.ts ===
4+
import { bar } from "./indirect.js";
5+
>bar : Symbol(bar, Decl(main.ts, 0, 8))
6+
7+
console.log(await bar());
8+
>console.log : Symbol(log, Decl(lib.dom.d.ts, --, --))
9+
>console : Symbol(console, Decl(lib.dom.d.ts, --, --))
10+
>log : Symbol(log, Decl(lib.dom.d.ts, --, --))
11+
>bar : Symbol(bar, Decl(main.ts, 0, 8))
12+
13+
=== /src/subpath.ts ===
14+
async function bar(): Promise<string> {
15+
>bar : Symbol(bar, Decl(subpath.ts, 0, 0))
16+
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --))
17+
18+
return "bar";
19+
}
20+
export const barrel = { bar };
21+
>barrel : Symbol(barrel, Decl(subpath.ts, 3, 12))
22+
>bar : Symbol(bar, Decl(subpath.ts, 3, 23))
23+
24+
=== /src/indirect.ts ===
25+
import { barrel } from "#subpath";
26+
>barrel : Symbol(barrel, Decl(indirect.ts, 0, 8))
27+
28+
const { bar } = barrel;
29+
>bar : Symbol(bar, Decl(indirect.ts, 1, 7))
30+
>barrel : Symbol(barrel, Decl(indirect.ts, 0, 8))
31+
32+
export { bar };
33+
>bar : Symbol(bar, Decl(indirect.ts, 2, 8))
34+
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
//// [tests/cases/compiler/subpathImportDeclarationEmit.ts] ////
2+
3+
=== /src/main.ts ===
4+
import { bar } from "./indirect.js";
5+
>bar : () => Promise<string>
6+
7+
console.log(await bar());
8+
>console.log(await bar()) : void
9+
>console.log : (...data: any[]) => void
10+
>console : Console
11+
>log : (...data: any[]) => void
12+
>await bar() : string
13+
>bar() : Promise<string>
14+
>bar : () => Promise<string>
15+
16+
=== /src/subpath.ts ===
17+
async function bar(): Promise<string> {
18+
>bar : () => Promise<string>
19+
20+
return "bar";
21+
>"bar" : "bar"
22+
}
23+
export const barrel = { bar };
24+
>barrel : { bar: () => Promise<string>; }
25+
>{ bar } : { bar: () => Promise<string>; }
26+
>bar : () => Promise<string>
27+
28+
=== /src/indirect.ts ===
29+
import { barrel } from "#subpath";
30+
>barrel : { bar: () => Promise<string>; }
31+
32+
const { bar } = barrel;
33+
>bar : () => Promise<string>
34+
>barrel : { bar: () => Promise<string>; }
35+
36+
export { bar };
37+
>bar : () => Promise<string>
38+
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
//// [tests/cases/conformance/jsdoc/declarations/jsDeclarationsDefault2.ts] ////
2+
3+
//// [index1.js]
4+
export const _default = class {};
5+
6+
export default 12;
7+
/**
8+
* @typedef {string | number} default
9+
*/
10+
11+
12+
//// [index1.js]
13+
"use strict";
14+
Object.defineProperty(exports, "__esModule", { value: true });
15+
exports._default = void 0;
16+
const _default = class {
17+
};
18+
exports._default = _default;
19+
exports.default = 12;
20+
21+
22+
//// [index1.d.ts]
23+
export declare const _default: {
24+
new (): {};
25+
};
26+
declare const _default_1: number;
27+
export default _default_1;
28+
export type default = string | number;
29+
30+
31+
//// [DtsFileErrors]
32+
33+
34+
out/index1.d.ts(6,1): error TS1128: Declaration or statement expected.
35+
out/index1.d.ts(6,8): error TS2304: Cannot find name 'type'.
36+
out/index1.d.ts(6,13): error TS2457: Type alias name cannot be 'default'.
37+
out/index1.d.ts(6,21): error TS1128: Declaration or statement expected.
38+
out/index1.d.ts(6,23): error TS2693: 'string' only refers to a type, but is being used as a value here.
39+
out/index1.d.ts(6,32): error TS2693: 'number' only refers to a type, but is being used as a value here.
40+
41+
42+
==== out/index1.d.ts (6 errors) ====
43+
export declare const _default: {
44+
new (): {};
45+
};
46+
declare const _default_1: number;
47+
export default _default_1;
48+
export type default = string | number;
49+
~~~~~~
50+
!!! error TS1128: Declaration or statement expected.
51+
~~~~
52+
!!! error TS2304: Cannot find name 'type'.
53+
~~~~~~~
54+
!!! error TS2457: Type alias name cannot be 'default'.
55+
~
56+
!!! error TS1128: Declaration or statement expected.
57+
~~~~~~
58+
!!! error TS2693: 'string' only refers to a type, but is being used as a value here.
59+
~~~~~~
60+
!!! error TS2693: 'number' only refers to a type, but is being used as a value here.
61+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//// [tests/cases/conformance/jsdoc/declarations/jsDeclarationsDefault2.ts] ////
2+
3+
=== index1.js ===
4+
export const _default = class {};
5+
>_default : Symbol(_default, Decl(index1.js, 0, 12))
6+
7+
export default 12;
8+
/**
9+
* @typedef {string | number} default
10+
*/
11+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//// [tests/cases/conformance/jsdoc/declarations/jsDeclarationsDefault2.ts] ////
2+
3+
=== index1.js ===
4+
export const _default = class {};
5+
>_default : typeof _default
6+
>class {} : typeof _default
7+
8+
export default 12;
9+
/**
10+
* @typedef {string | number} default
11+
*/
12+
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//// [tests/cases/conformance/jsdoc/jsdocDestructuringParameterDeclaration.ts] ////
2+
3+
//// [a.js]
4+
/**
5+
* @param {{ a: number; b: string }} args
6+
*/
7+
function f({ a, b }) {}
8+
9+
10+
11+
12+
//// [a.d.ts]
13+
/**
14+
* @param {{ a: number; b: string }} args
15+
*/
16+
declare function f({ a, b }: {
17+
a: number;
18+
b: string;
19+
}): void;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//// [tests/cases/conformance/jsdoc/jsdocDestructuringParameterDeclaration.ts] ////
2+
3+
=== /a.js ===
4+
/**
5+
* @param {{ a: number; b: string }} args
6+
*/
7+
function f({ a, b }) {}
8+
>f : Symbol(f, Decl(a.js, 0, 0))
9+
>a : Symbol(a, Decl(a.js, 3, 12))
10+
>b : Symbol(b, Decl(a.js, 3, 15))
11+

0 commit comments

Comments
 (0)