forked from TypeScriptToLua/TypeScriptToLua
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeprecated.spec.ts
More file actions
103 lines (92 loc) · 3.05 KB
/
Copy pathdeprecated.spec.ts
File metadata and controls
103 lines (92 loc) · 3.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import { annotationRemoved } from "../../../src/transformation/utils/diagnostics";
import * as util from "../../util";
test.each(["extension", "metaExtension"])("extension removed", extensionType => {
util.testModule`
declare class A {}
/** @${extensionType} **/
class B extends A {}
`.expectDiagnosticsToMatchSnapshot([annotationRemoved.code]);
});
test("phantom removed", () => {
util.testModule`
/** @phantom **/
namespace A {
function nsMember() {}
}
`.expectDiagnosticsToMatchSnapshot([annotationRemoved.code]);
});
test("pureAbstract removed", () => {
util.testModule`
/** @pureAbstract */
declare class ClassA {}
class ClassB extends ClassA {}
`.expectDiagnosticsToMatchSnapshot([annotationRemoved.code]);
});
test("forRange removed", () => {
util.testModule`
/** @forRange */
declare function forRange(start: number, limit: number, step?: number): number[];
for (const i of forRange(1, 10)) {}
`.expectDiagnosticsToMatchSnapshot([annotationRemoved.code]);
});
test("vararg removed", () => {
util.testModule`
/** @vararg */
type VarArg<T extends any[]> = T & { readonly __brand: unique symbol };
function foo(...args: any[]) {}
function vararg(...args: VarArg<any[]>) {
foo(...args);
}
`.expectDiagnosticsToMatchSnapshot([annotationRemoved.code]);
});
test("luaiterator removed", () => {
util.testFunction`
const arr = ["a", "b", "c"];
/** @luaIterator */
interface Iter extends Iterable<string> {}
function luaIter(): Iter {
let i = 0;
return (() => arr[i++]) as any;
}
let result = "";
for (let e of luaIter()) { result += e; }
return result;
`.expectDiagnosticsToMatchSnapshot([annotationRemoved.code]);
});
const tableLibClass = `
/** @luaTable */
declare class Table<K extends {} = {}, V = any> {
length: number;
constructor(notAllowed?: any);
set(key?: K, value?: V, notAllowed?: any): void;
get(key?: K, notAllowed?: any): V;
other(): void;
}
declare let tbl: Table;
`;
test("LuaTable removed warning constructor", () => {
util.testModule("const table = new Table();")
.setTsHeader(tableLibClass)
.expectDiagnosticsToMatchSnapshot([annotationRemoved.code]);
});
test("LuaTable removed warning property access length", () => {
util.testFunction`
return tbl.length;
`
.setTsHeader(tableLibClass)
.expectDiagnosticsToMatchSnapshot([annotationRemoved.code]);
});
test("LuaTable removed warning property access get", () => {
util.testFunction`
return tbl.get("foo");
`
.setTsHeader(tableLibClass)
.expectDiagnosticsToMatchSnapshot([annotationRemoved.code]);
});
test("LuaTable deprecation warning property access set", () => {
util.testFunction`
return tbl.set("foo", 0);
`
.setTsHeader(tableLibClass)
.expectDiagnosticsToMatchSnapshot([annotationRemoved.code]);
});