From 68077f7bb84729afc8e50181d121b0972e8aa047 Mon Sep 17 00:00:00 2001 From: Aaron Jensen Date: Thu, 31 May 2018 14:59:54 -0700 Subject: [PATCH 1/2] Fix typings for Typescript 2.9 --- package.json | 2 +- .../__snapshots__/typescript.js.snap | 91 ++++++++----------- typings/helpers.d.ts | 5 +- typings/preact/helpers.d.ts | 5 +- 4 files changed, 41 insertions(+), 62 deletions(-) diff --git a/package.json b/package.json index a7d026e9..e4373282 100644 --- a/package.json +++ b/package.json @@ -71,7 +71,7 @@ "tslint": "^5.8.0", "tslint-microsoft-contrib": "^5.0.0", "tsutils": "^2.15.0", - "typescript": "^2.6.2" + "typescript": "^2.9.1" }, "eslintConfig": { "extends": "./node_modules/kcd-scripts/eslint.js", diff --git a/src/__tests__/__snapshots__/typescript.js.snap b/src/__tests__/__snapshots__/typescript.js.snap index 61b4ff52..fc0413af 100644 --- a/src/__tests__/__snapshots__/typescript.js.snap +++ b/src/__tests__/__snapshots__/typescript.js.snap @@ -39,15 +39,13 @@ test/preact/should-fail.test.tsx(90,47): error TS2344: Type 'PropsWithoutTheme' Property 'theme' is missing in type 'PropsWithoutTheme'. test/preact/should-fail.test.tsx(98,11): error TS2345: Argument of type 'FunctionalComponent' is not assignable to parameter of type '\\"tspan\\"'. test/preact/should-fail.test.tsx(113,18): error TS2551: Property 'visibles' does not exist on type '{ theme: any; } & ExampleComponentProps & object'. Did you mean 'visible'? -test/preact/should-fail.test.tsx(125,29): error TS2322: Type '{ visible: string; }' is not assignable to type 'Readonly'. Type '{ allowReorder: boolean; }' is not assignable to type '(string | SVGProperties | StyleFunction)[]'. @@ -68,22 +66,19 @@ test/preact/should-fail.test.tsx(197,4): error TS2345: Argument of type '(props: test/preact/should-fail.test.tsx(201,1): error TS2554: Expected 1 arguments, but got 0. test/preact/should-fail.test.tsx(202,30): error TS2345: Argument of type '\\"\\"' is not assignable to parameter of type 'object'. test/preact/should-fail.test.tsx(203,30): error TS2345: Argument of type 'false' is not assignable to parameter of type 'object'. -test/preact/should-fail.test.tsx(225,19): error TS2559: Type '{ d: string; }' has no properties in common with type 'Readonly & Pick<{ theme?: any; }, never> & { ...'. -test/preact/should-fail.test.tsx(226,19): error TS2322: Type '{ primaryColor: number; }' is not assignable to type 'Readonly & Pick<{ theme?: any; }, never> & { ...'. - Types of property 'primaryColor' are incompatible. - Type 'number' is not assignable to type 'string | undefined'. -test/preact/should-fail.test.tsx(227,31): error TS2559: Type '{ d: string; }' has no properties in common with type 'Readonly & Pick<{ theme: any; }, never> & ExtraGlamorousProps ...'. -test/preact/should-fail.test.tsx(228,31): error TS2322: Type '{ primaryColor: number; }' is not assignable to type 'Readonly & Pick<{ theme: any; }, never> & ExtraGlamorousProps ...'. - Types of property 'primaryColor' are incompatible. - Type 'number' is not assignable to type 'string | undefined'. -test/preact/should-fail.test.tsx(229,31): error TS2559: Type '{ d: string; }' has no properties in common with type 'Readonly & ExtraGlamorousProps & Attributes & { child...'. -test/preact/should-fail.test.tsx(230,31): error TS2322: Type '{ primaryColor: number; }' is not assignable to type 'Readonly & ExtraGlamorousProps & Attributes & { child...'. - Types of property 'primaryColor' are incompatible. - Type 'number' is not assignable to type 'string | undefined'. -test/preact/should-fail.test.tsx(266,38): error TS2559: Type '{ display: string; }' has no properties in common with type 'Readonly & Pick<{ theme?: any; }, never> & { ...'. +test/preact/should-fail.test.tsx(226,19): error TS2326: Types of property 'primaryColor' are incompatible. + Type 'number' is not assignable to type 'string | undefined'. +test/preact/should-fail.test.tsx(227,6): error TS2559: Type '{ d: string; }' has no properties in common with type 'Readonly & Pick<{ theme: any; }, never> & ExtraGlamorousProps ...'. +test/preact/should-fail.test.tsx(228,31): error TS2326: Types of property 'primaryColor' are incompatible. + Type 'number' is not assignable to type 'string | undefined'. +test/preact/should-fail.test.tsx(229,6): error TS2559: Type '{ d: string; }' has no properties in common with type 'Readonly & ExtraGlamorousProps & Attributes & { child...'. +test/preact/should-fail.test.tsx(230,31): error TS2326: Types of property 'primaryColor' are incompatible. + Type 'number' is not assignable to type 'string | undefined'. +test/preact/should-fail.test.tsx(266,6): error TS2559: Type '{ display: string; }' has no properties in common with type 'Readonly' is not assignable to parameter of type '\\"tspan\\"'. test/should-fail.test.tsx(135,20): error TS2551: Property 'visibles' does not exist on type '{ theme: any; } & ExampleComponentProps & object'. Did you mean 'visible'? -test/should-fail.test.tsx(150,29): error TS2322: Type '{ visible: string; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes'. - Types of property 'visible' are incompatible. - Type 'string' is not assignable to type 'boolean'. -test/should-fail.test.tsx(151,5): error TS2322: Type '{}' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes'. Property 'visible' is missing in type '{}'. -test/should-fail.test.tsx(152,32): error TS2322: Type '{ visible: string; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes & { visible: b...'. - Type '{ visible: string; }' is not assignable to type 'Readonly & { visible: boolean; } & object & ExtraGlamorousProps>'. - Types of property 'visible' are incompatible. - Type 'string' is not assignable to type 'boolean'. -test/should-fail.test.tsx(153,5): error TS2322: Type '{}' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes & { visible: b...'. +test/should-fail.test.tsx(152,32): error TS2326: Types of property 'visible' are incompatible. + Type 'string' is not assignable to type 'boolean'. +test/should-fail.test.tsx(153,6): error TS2322: Type '{}' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes & { visible: b...'. Type '{}' is not assignable to type 'Readonly & { visible: boolean; } & object & ExtraGlamorousProps>'. Property 'visible' is missing in type '{}'. test/should-fail.test.tsx(157,21): error TS2345: Argument of type '{ allowReorder: boolean; }' is not assignable to parameter of type 'StyleArgument'. @@ -159,24 +150,18 @@ test/should-fail.test.tsx(224,3): error TS2345: Argument of type '(props: { visi test/should-fail.test.tsx(229,1): error TS2554: Expected 1 arguments, but got 0. test/should-fail.test.tsx(230,30): error TS2345: Argument of type '\\"\\"' is not assignable to parameter of type 'object'. test/should-fail.test.tsx(231,30): error TS2345: Argument of type 'false' is not assignable to parameter of type 'object'. -test/should-fail.test.tsx(257,19): error TS2559: Type '{ d: string; }' has no properties in common with type 'IntrinsicAttributes & IntrinsicClassAttributes & Partial<{ pr...'. -test/should-fail.test.tsx(258,19): error TS2322: Type '{ primaryColor: number; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes & Partial<{ pr...'. - Type '{ primaryColor: number; }' is not assignable to type 'Readonly & Partial<{ primaryColor: string; }> & Pick<{ theme?: any; }, ...'. - Types of property 'primaryColor' are incompatible. - Type 'number' is not assignable to type 'string | undefined'. -test/should-fail.test.tsx(259,31): error TS2559: Type '{ d: string; }' has no properties in common with type 'IntrinsicAttributes & IntrinsicClassAttributes & Pic...'. -test/should-fail.test.tsx(260,31): error TS2322: Type '{ primaryColor: number; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes & Pic...'. - Type '{ primaryColor: number; }' is not assignable to type 'Readonly & Pick<{ theme: any; }, never> & ExtraGlamorousProps>'. - Types of property 'primaryColor' are incompatible. - Type 'number' is not assignable to type 'string | undefined'. -test/should-fail.test.tsx(261,31): error TS2559: Type '{ d: string; }' has no properties in common with type 'IntrinsicAttributes & IntrinsicClassAttributes & ExtraGlamorousProps>'. - Types of property 'primaryColor' are incompatible. - Type 'number' is not assignable to type 'string | undefined'. -test/should-fail.test.tsx(290,38): error TS2559: Type '{ display: string; }' has no properties in common with type 'IntrinsicAttributes & IntrinsicClassAttributes & object & Ext...'. -test/should-fail.test.tsx(295,36): error TS2559: Type '{ display: string; }' has no properties in common with type 'IntrinsicAttributes & IntrinsicClassAttributes & object & Ext...'. +test/should-fail.test.tsx(257,6): error TS2559: Type '{ d: string; }' has no properties in common with type 'IntrinsicAttributes & IntrinsicClassAttributes & Partial<{ pr...'. +test/should-fail.test.tsx(258,19): error TS2326: Types of property 'primaryColor' are incompatible. + Type 'number' is not assignable to type 'string | undefined'. +test/should-fail.test.tsx(259,6): error TS2559: Type '{ d: string; }' has no properties in common with type 'IntrinsicAttributes & IntrinsicClassAttributes & Pic...'. +test/should-fail.test.tsx(260,31): error TS2326: Types of property 'primaryColor' are incompatible. + Type 'number' is not assignable to type 'string | undefined'. +test/should-fail.test.tsx(261,6): error TS2559: Type '{ d: string; }' has no properties in common with type 'IntrinsicAttributes & IntrinsicClassAttributes & object & Ext...'. +test/should-fail.test.tsx(295,6): error TS2559: Type '{ display: string; }' has no properties in common with type 'IntrinsicAttributes & IntrinsicClassAttributes & object & Ext...'. " `; diff --git a/typings/helpers.d.ts b/typings/helpers.d.ts index 9c9245fc..82509d75 100644 --- a/typings/helpers.d.ts +++ b/typings/helpers.d.ts @@ -1,7 +1,4 @@ -type Diff = ({[P in T]: P} & - {[P in U]: never} & {[x: string]: never})[T] - -export type Omit = Pick> +export type Omit = Pick> export type SingleOrArray = { [P in T]: Properties[P] | Array diff --git a/typings/preact/helpers.d.ts b/typings/preact/helpers.d.ts index 9c9245fc..82509d75 100644 --- a/typings/preact/helpers.d.ts +++ b/typings/preact/helpers.d.ts @@ -1,7 +1,4 @@ -type Diff = ({[P in T]: P} & - {[P in U]: never} & {[x: string]: never})[T] - -export type Omit = Pick> +export type Omit = Pick> export type SingleOrArray = { [P in T]: Properties[P] | Array From b3e75d48a279cfbde0bad9cc78b810d28327a7d9 Mon Sep 17 00:00:00 2001 From: Aaron Jensen Date: Thu, 31 May 2018 16:59:43 -0700 Subject: [PATCH 2/2] Disable React deprecation lint warnings for now --- src/.eslintrc | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 src/.eslintrc diff --git a/src/.eslintrc b/src/.eslintrc new file mode 100644 index 00000000..9c8c27b7 --- /dev/null +++ b/src/.eslintrc @@ -0,0 +1,5 @@ +{ + "rules": { + "react/no-deprecated": "off" + } +}