4 * Copyright 2018 Palantir Technologies, Inc.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 Object.defineProperty(exports, "__esModule", { value: true });
19 var tslib_1 = require("tslib");
20 var Lint = require("../../index");
21 // tslint:disable: object-literal-sort-keys
22 exports.codeExamples = [
24 description: "Requires type definitions for call signatures",
25 config: Lint.Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n \"rules\": { \"typedef\": [true, \"call-signature\"] }\n "], ["\n \"rules\": { \"typedef\": [true, \"call-signature\"] }\n "]))),
26 pass: Lint.Utils.dedent(templateObject_2 || (templateObject_2 = tslib_1.__makeTemplateObject(["\n function add(x, y): number {\n return x + y;\n }\n "], ["\n function add(x, y): number {\n return x + y;\n }\n "]))),
27 fail: Lint.Utils.dedent(templateObject_3 || (templateObject_3 = tslib_1.__makeTemplateObject(["\n function add(x, y) {\n return x + y;\n }\n "], ["\n function add(x, y) {\n return x + y;\n }\n "]))),
30 description: "Requires type definitions for arrow call signatures",
31 config: Lint.Utils.dedent(templateObject_4 || (templateObject_4 = tslib_1.__makeTemplateObject(["\n \"rules\": { \"typedef\": [true, \"arrow-call-signature\"] }\n "], ["\n \"rules\": { \"typedef\": [true, \"arrow-call-signature\"] }\n "]))),
32 pass: Lint.Utils.dedent(templateObject_5 || (templateObject_5 = tslib_1.__makeTemplateObject(["\n const add = (x, y): number => x + y;\n "], ["\n const add = (x, y): number => x + y;\n "]))),
33 fail: Lint.Utils.dedent(templateObject_6 || (templateObject_6 = tslib_1.__makeTemplateObject(["\n const add = (x, y) => x + y;\n "], ["\n const add = (x, y) => x + y;\n "]))),
36 description: "Requires type definitions for parameters",
37 config: Lint.Utils.dedent(templateObject_7 || (templateObject_7 = tslib_1.__makeTemplateObject(["\n \"rules\": { \"typedef\": [true, \"parameter\"] }\n "], ["\n \"rules\": { \"typedef\": [true, \"parameter\"] }\n "]))),
38 pass: Lint.Utils.dedent(templateObject_8 || (templateObject_8 = tslib_1.__makeTemplateObject(["\n function add(x: number, y: number) {\n return x + y;\n }\n "], ["\n function add(x: number, y: number) {\n return x + y;\n }\n "]))),
39 fail: Lint.Utils.dedent(templateObject_9 || (templateObject_9 = tslib_1.__makeTemplateObject(["\n function add(x, y) {\n return x + y;\n }\n "], ["\n function add(x, y) {\n return x + y;\n }\n "]))),
42 description: "Requires type definitions for arrow function parameters",
43 config: Lint.Utils.dedent(templateObject_10 || (templateObject_10 = tslib_1.__makeTemplateObject(["\n \"rules\": { \"typedef\": [true, \"arrow-parameter\"] }\n "], ["\n \"rules\": { \"typedef\": [true, \"arrow-parameter\"] }\n "]))),
44 pass: Lint.Utils.dedent(templateObject_11 || (templateObject_11 = tslib_1.__makeTemplateObject(["\n const add = (x: number, y: number) => x + y;\n "], ["\n const add = (x: number, y: number) => x + y;\n "]))),
45 fail: Lint.Utils.dedent(templateObject_12 || (templateObject_12 = tslib_1.__makeTemplateObject(["\n const add = (x, y) => x + y;\n "], ["\n const add = (x, y) => x + y;\n "]))),
48 description: "Requires type definitions for property declarations",
49 config: Lint.Utils.dedent(templateObject_13 || (templateObject_13 = tslib_1.__makeTemplateObject(["\n \"rules\": { \"typedef\": [true, \"property-declaration\"] }\n "], ["\n \"rules\": { \"typedef\": [true, \"property-declaration\"] }\n "]))),
50 pass: Lint.Utils.dedent(templateObject_14 || (templateObject_14 = tslib_1.__makeTemplateObject(["\n interface I {\n foo: number;\n bar: string;\n }\n "], ["\n interface I {\n foo: number;\n bar: string;\n }\n "]))),
51 fail: Lint.Utils.dedent(templateObject_15 || (templateObject_15 = tslib_1.__makeTemplateObject(["\n interface I {\n foo;\n bar;\n }\n "], ["\n interface I {\n foo;\n bar;\n }\n "]))),
54 description: "Requires type definitions for variable declarations",
55 config: Lint.Utils.dedent(templateObject_16 || (templateObject_16 = tslib_1.__makeTemplateObject(["\n \"rules\": { \"typedef\": [true, \"variable-declaration\"] }\n "], ["\n \"rules\": { \"typedef\": [true, \"variable-declaration\"] }\n "]))),
56 pass: Lint.Utils.dedent(templateObject_17 || (templateObject_17 = tslib_1.__makeTemplateObject(["\n let x: number;\n "], ["\n let x: number;\n "]))),
57 fail: Lint.Utils.dedent(templateObject_18 || (templateObject_18 = tslib_1.__makeTemplateObject(["\n let x;\n "], ["\n let x;\n "]))),
60 description: "Requires type definitions for member variable declarations",
61 config: Lint.Utils.dedent(templateObject_19 || (templateObject_19 = tslib_1.__makeTemplateObject(["\n \"rules\": { \"typedef\": [true, \"member-variable-declaration\"] }\n "], ["\n \"rules\": { \"typedef\": [true, \"member-variable-declaration\"] }\n "]))),
62 pass: Lint.Utils.dedent(templateObject_20 || (templateObject_20 = tslib_1.__makeTemplateObject(["\n class MyClass {\n x: number;\n }\n "], ["\n class MyClass {\n x: number;\n }\n "]))),
63 fail: Lint.Utils.dedent(templateObject_21 || (templateObject_21 = tslib_1.__makeTemplateObject(["\n class MyClass {\n x;\n }\n "], ["\n class MyClass {\n x;\n }\n "]))),
66 description: "Requires type definitions when destructuring objects.",
67 config: Lint.Utils.dedent(templateObject_22 || (templateObject_22 = tslib_1.__makeTemplateObject(["\n \"rules\": { \"typedef\": [true, \"object-destructuring\"] }\n "], ["\n \"rules\": { \"typedef\": [true, \"object-destructuring\"] }\n "]))),
68 pass: Lint.Utils.dedent(templateObject_23 || (templateObject_23 = tslib_1.__makeTemplateObject(["\n interface FooBar {\n foo: number;\n bar: string;\n }\n const foobar = { foo: 1, bar: '2' };\n const { foo, bar }: FooBar = foobar;\n "], ["\n interface FooBar {\n foo: number;\n bar: string;\n }\n const foobar = { foo: 1, bar: '2' };\n const { foo, bar }: FooBar = foobar;\n "]))),
69 fail: Lint.Utils.dedent(templateObject_24 || (templateObject_24 = tslib_1.__makeTemplateObject(["\n interface FooBar {\n foo: number;\n bar: string;\n }\n const foobar = { foo: 1, bar: '2' };\n const { foo, bar } = foobar;\n "], ["\n interface FooBar {\n foo: number;\n bar: string;\n }\n const foobar = { foo: 1, bar: '2' };\n const { foo, bar } = foobar;\n "]))),
72 description: "Requires type definitions when destructuring arrays.",
73 config: Lint.Utils.dedent(templateObject_25 || (templateObject_25 = tslib_1.__makeTemplateObject(["\n \"rules\": { \"typedef\": [true, \"array-destructuring\"] }\n "], ["\n \"rules\": { \"typedef\": [true, \"array-destructuring\"] }\n "]))),
74 pass: Lint.Utils.dedent(templateObject_26 || (templateObject_26 = tslib_1.__makeTemplateObject(["\n const foobar = [1, '2'];\n const [foo, bar]: Array<number | string> = foobar;\n "], ["\n const foobar = [1, '2'];\n const [foo, bar]: Array<number | string> = foobar;\n "]))),
75 fail: Lint.Utils.dedent(templateObject_27 || (templateObject_27 = tslib_1.__makeTemplateObject(["\n const foobar = [1, '2'];\n const [foo, bar] = foobar;\n "], ["\n const foobar = [1, '2'];\n const [foo, bar] = foobar;\n "]))),
78 var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10, templateObject_11, templateObject_12, templateObject_13, templateObject_14, templateObject_15, templateObject_16, templateObject_17, templateObject_18, templateObject_19, templateObject_20, templateObject_21, templateObject_22, templateObject_23, templateObject_24, templateObject_25, templateObject_26, templateObject_27;