From 22f3c89ba4d2ff1821be3f67b962dc2346e63573 Mon Sep 17 00:00:00 2001 From: Fredrik Nicol Date: Mon, 16 May 2022 14:13:14 +0100 Subject: [PATCH] Export `DataType` namespace Fixes #138 --- __tests__/__fixtures__/typecheck.ts | 3 --- __tests__/__snapshots__/dist.typescript-3.5.ts.snap | 2 -- __tests__/__snapshots__/dist.typescript-3.6.ts.snap | 2 -- __tests__/__snapshots__/dist.typescript-3.7.ts.snap | 2 -- __tests__/__snapshots__/dist.typescript-3.8.ts.snap | 2 -- __tests__/__snapshots__/dist.typescript-3.9.ts.snap | 2 -- __tests__/__snapshots__/dist.typescript-4.0.ts.snap | 2 -- __tests__/__snapshots__/dist.typescript-4.1.ts.snap | 2 -- __tests__/__snapshots__/dist.typescript-4.2.ts.snap | 2 -- __tests__/__snapshots__/dist.typescript-4.3.ts.snap | 2 -- __tests__/__snapshots__/dist.typescript-4.4.ts.snap | 2 -- __tests__/__snapshots__/dist.typescript-4.5.ts.snap | 2 -- .../__snapshots__/dist.typescript-latest.ts.snap | 2 -- __tests__/dist.typescript-3.5.ts | 2 +- __tests__/dist.typescript-3.6.ts | 2 +- __tests__/dist.typescript-3.7.ts | 2 +- __tests__/dist.typescript-3.8.ts | 2 +- __tests__/dist.typescript-3.9.ts | 2 +- __tests__/dist.typescript-4.0.ts | 2 +- __tests__/dist.typescript-4.1.ts | 2 +- __tests__/dist.typescript-4.2.ts | 2 +- __tests__/dist.typescript-4.3.ts | 2 +- __tests__/dist.typescript-4.4.ts | 2 +- __tests__/dist.typescript-4.5.ts | 2 +- __tests__/dist.typescript-latest.ts | 2 +- index.d.ts | 8 +++++++- src/declarator.ts | 11 +++++++---- src/typescript.ts | 8 +++----- 28 files changed, 29 insertions(+), 49 deletions(-) diff --git a/__tests__/__fixtures__/typecheck.ts b/__tests__/__fixtures__/typecheck.ts index 47d698e..aaa1263 100644 --- a/__tests__/__fixtures__/typecheck.ts +++ b/__tests__/__fixtures__/typecheck.ts @@ -147,9 +147,6 @@ propertyValueWithAutocompleteHack([1]); // Should fail const differentMajorVersions: CSS.Properties = {} as OldCSS.Properties; -// eslint-disable-next-line @typescript-eslint/no-unused-vars -type DataTypeShouldNotBeExposed = CSS.DataType.Color; - css; cssWithFallbackValues; cssWithHyphenProperties; diff --git a/__tests__/__snapshots__/dist.typescript-3.5.ts.snap b/__tests__/__snapshots__/dist.typescript-3.5.ts.snap index 149e3dd..e924d10 100644 --- a/__tests__/__snapshots__/dist.typescript-3.5.ts.snap +++ b/__tests__/__snapshots__/dist.typescript-3.5.ts.snap @@ -56,5 +56,3 @@ exports[`Typescript 3.5 detects errors 15`] = ` Type '[1]' is not assignable to type '[0 | \\"auto\\" | \\"inherit\\" | (string & {}) | \\"-moz-initial\\" | \\"initial\\" | \\"revert\\" | \\"unset\\" | \\"-moz-fit-content\\" | \\"-moz-max-content\\" | \\"-moz-min-content\\" | \\"fit-content\\" | \\"max-content\\" | ... 4 more ... | \\"min-intrinsic\\"]'. Type '1' is not assignable to type '0 | \\"auto\\" | \\"inherit\\" | (string & {}) | \\"-moz-initial\\" | \\"initial\\" | \\"revert\\" | \\"unset\\" | \\"-moz-fit-content\\" | \\"-moz-max-content\\" | \\"-moz-min-content\\" | \\"fit-content\\" | \\"max-content\\" | ... 4 more ... | \\"min-intrinsic\\"'." `; - -exports[`Typescript 3.5 detects errors 16`] = `"150:38 - Namespace '\\"index\\"' has no exported member 'DataType'."`; diff --git a/__tests__/__snapshots__/dist.typescript-3.6.ts.snap b/__tests__/__snapshots__/dist.typescript-3.6.ts.snap index 7ee40d5..6a2917d 100644 --- a/__tests__/__snapshots__/dist.typescript-3.6.ts.snap +++ b/__tests__/__snapshots__/dist.typescript-3.6.ts.snap @@ -56,5 +56,3 @@ exports[`Typescript 3.6 detects errors 15`] = ` Type '[1]' is not assignable to type '[0 | \\"auto\\" | \\"inherit\\" | (string & {}) | \\"-moz-initial\\" | \\"initial\\" | \\"revert\\" | \\"unset\\" | \\"-moz-fit-content\\" | \\"-moz-max-content\\" | \\"-moz-min-content\\" | \\"fit-content\\" | \\"max-content\\" | ... 4 more ... | \\"min-intrinsic\\"]'. Type '1' is not assignable to type '0 | \\"auto\\" | \\"inherit\\" | (string & {}) | \\"-moz-initial\\" | \\"initial\\" | \\"revert\\" | \\"unset\\" | \\"-moz-fit-content\\" | \\"-moz-max-content\\" | \\"-moz-min-content\\" | \\"fit-content\\" | \\"max-content\\" | ... 4 more ... | \\"min-intrinsic\\"'." `; - -exports[`Typescript 3.6 detects errors 16`] = `"150:38 - Namespace '\\"index\\"' has no exported member 'DataType'."`; diff --git a/__tests__/__snapshots__/dist.typescript-3.7.ts.snap b/__tests__/__snapshots__/dist.typescript-3.7.ts.snap index 0ed4de8..370158b 100644 --- a/__tests__/__snapshots__/dist.typescript-3.7.ts.snap +++ b/__tests__/__snapshots__/dist.typescript-3.7.ts.snap @@ -56,5 +56,3 @@ exports[`Typescript 3.7 detects errors 15`] = ` Type '[1]' is not assignable to type '[0 | \\"auto\\" | \\"inherit\\" | (string & {}) | \\"-moz-initial\\" | \\"initial\\" | \\"revert\\" | \\"unset\\" | \\"-moz-fit-content\\" | \\"-moz-max-content\\" | \\"-moz-min-content\\" | \\"fit-content\\" | \\"max-content\\" | ... 4 more ... | \\"min-intrinsic\\"]'. Type '1' is not assignable to type '0 | \\"auto\\" | \\"inherit\\" | (string & {}) | \\"-moz-initial\\" | \\"initial\\" | \\"revert\\" | \\"unset\\" | \\"-moz-fit-content\\" | \\"-moz-max-content\\" | \\"-moz-min-content\\" | \\"fit-content\\" | \\"max-content\\" | ... 4 more ... | \\"min-intrinsic\\"'." `; - -exports[`Typescript 3.7 detects errors 16`] = `"150:38 - Namespace '\\"index\\"' has no exported member 'DataType'."`; diff --git a/__tests__/__snapshots__/dist.typescript-3.8.ts.snap b/__tests__/__snapshots__/dist.typescript-3.8.ts.snap index f754e78..8878488 100644 --- a/__tests__/__snapshots__/dist.typescript-3.8.ts.snap +++ b/__tests__/__snapshots__/dist.typescript-3.8.ts.snap @@ -38,5 +38,3 @@ exports[`Typescript 3.8 detects errors 13`] = `"134:25 - This condition will alw exports[`Typescript 3.8 detects errors 14`] = `"144:34 - Argument of type '1' is not assignable to parameter of type '0 | \\"auto\\" | \\"inherit\\" | (string & {}) | \\"-moz-initial\\" | \\"initial\\" | \\"revert\\" | \\"unset\\" | \\"-moz-fit-content\\" | \\"-moz-max-content\\" | \\"-moz-min-content\\" | \\"fit-content\\" | \\"max-content\\" | ... 5 more ... | [...]'."`; exports[`Typescript 3.8 detects errors 15`] = `"145:35 - Type '1' is not assignable to type '0 | \\"auto\\" | \\"inherit\\" | (string & {}) | \\"-moz-initial\\" | \\"initial\\" | \\"revert\\" | \\"unset\\" | \\"-moz-fit-content\\" | \\"-moz-max-content\\" | \\"-moz-min-content\\" | \\"fit-content\\" | \\"max-content\\" | ... 4 more ... | \\"min-intrinsic\\"'."`; - -exports[`Typescript 3.8 detects errors 16`] = `"150:38 - Namespace '\\"index\\"' has no exported member 'DataType'."`; diff --git a/__tests__/__snapshots__/dist.typescript-3.9.ts.snap b/__tests__/__snapshots__/dist.typescript-3.9.ts.snap index 2423dbd..5b79076 100644 --- a/__tests__/__snapshots__/dist.typescript-3.9.ts.snap +++ b/__tests__/__snapshots__/dist.typescript-3.9.ts.snap @@ -38,5 +38,3 @@ exports[`Typescript 3.9 detects errors 13`] = `"134:25 - This condition will alw exports[`Typescript 3.9 detects errors 14`] = `"144:34 - Argument of type '1' is not assignable to parameter of type '0 | \\"auto\\" | \\"inherit\\" | (string & {}) | \\"-moz-initial\\" | \\"initial\\" | \\"revert\\" | \\"unset\\" | \\"-moz-fit-content\\" | \\"-moz-max-content\\" | \\"-moz-min-content\\" | \\"fit-content\\" | \\"max-content\\" | ... 5 more ... | [...]'."`; exports[`Typescript 3.9 detects errors 15`] = `"145:35 - Type '1' is not assignable to type 'Width<0 | (string & {})>'."`; - -exports[`Typescript 3.9 detects errors 16`] = `"150:38 - Namespace '\\"index\\"' has no exported member 'DataType'."`; diff --git a/__tests__/__snapshots__/dist.typescript-4.0.ts.snap b/__tests__/__snapshots__/dist.typescript-4.0.ts.snap index 50349fe..131d007 100644 --- a/__tests__/__snapshots__/dist.typescript-4.0.ts.snap +++ b/__tests__/__snapshots__/dist.typescript-4.0.ts.snap @@ -38,5 +38,3 @@ exports[`Typescript 4.0 detects errors 13`] = `"134:25 - This condition will alw exports[`Typescript 4.0 detects errors 14`] = `"144:34 - Argument of type '1' is not assignable to parameter of type '0 | \\"auto\\" | \\"inherit\\" | (string & {}) | \\"-moz-initial\\" | \\"initial\\" | \\"revert\\" | \\"unset\\" | \\"-moz-fit-content\\" | \\"-moz-max-content\\" | \\"-moz-min-content\\" | \\"fit-content\\" | \\"max-content\\" | ... 5 more ... | [...]'."`; exports[`Typescript 4.0 detects errors 15`] = `"145:35 - Type '1' is not assignable to type 'Width<0 | (string & {})>'."`; - -exports[`Typescript 4.0 detects errors 16`] = `"150:38 - Namespace '\\"index\\"' has no exported member 'DataType'."`; diff --git a/__tests__/__snapshots__/dist.typescript-4.1.ts.snap b/__tests__/__snapshots__/dist.typescript-4.1.ts.snap index f17f4e8..e368b0c 100644 --- a/__tests__/__snapshots__/dist.typescript-4.1.ts.snap +++ b/__tests__/__snapshots__/dist.typescript-4.1.ts.snap @@ -38,5 +38,3 @@ exports[`Typescript 4.1 detects errors 13`] = `"134:25 - This condition will alw exports[`Typescript 4.1 detects errors 14`] = `"144:34 - Argument of type '1' is not assignable to parameter of type '0 | \\"auto\\" | \\"inherit\\" | (string & {}) | \\"-moz-initial\\" | \\"initial\\" | \\"revert\\" | \\"unset\\" | \\"-moz-fit-content\\" | \\"-moz-max-content\\" | \\"-moz-min-content\\" | \\"fit-content\\" | \\"max-content\\" | ... 5 more ... | [...]'."`; exports[`Typescript 4.1 detects errors 15`] = `"145:35 - Type '1' is not assignable to type 'Width<0 | (string & {})>'."`; - -exports[`Typescript 4.1 detects errors 16`] = `"150:38 - Namespace '\\"index\\"' has no exported member 'DataType'."`; diff --git a/__tests__/__snapshots__/dist.typescript-4.2.ts.snap b/__tests__/__snapshots__/dist.typescript-4.2.ts.snap index 3bfdf88..9e4485b 100644 --- a/__tests__/__snapshots__/dist.typescript-4.2.ts.snap +++ b/__tests__/__snapshots__/dist.typescript-4.2.ts.snap @@ -38,5 +38,3 @@ exports[`Typescript 4.2 detects errors 13`] = `"134:25 - This condition will alw exports[`Typescript 4.2 detects errors 14`] = `"144:34 - Argument of type '1' is not assignable to parameter of type 'Width<0 | (string & {})> | [Width<0 | (string & {})>]'."`; exports[`Typescript 4.2 detects errors 15`] = `"145:35 - Type '1' is not assignable to type 'Width<0 | (string & {})>'."`; - -exports[`Typescript 4.2 detects errors 16`] = `"150:38 - Namespace '\\"index\\"' has no exported member 'DataType'."`; diff --git a/__tests__/__snapshots__/dist.typescript-4.3.ts.snap b/__tests__/__snapshots__/dist.typescript-4.3.ts.snap index dd500c6..fde1a46 100644 --- a/__tests__/__snapshots__/dist.typescript-4.3.ts.snap +++ b/__tests__/__snapshots__/dist.typescript-4.3.ts.snap @@ -38,5 +38,3 @@ exports[`Typescript 4.3 detects errors 13`] = `"134:25 - This condition will alw exports[`Typescript 4.3 detects errors 14`] = `"144:34 - Argument of type '1' is not assignable to parameter of type 'Width<0 | (string & {})> | [Width<0 | (string & {})>]'."`; exports[`Typescript 4.3 detects errors 15`] = `"145:35 - Type '1' is not assignable to type 'Width<0 | (string & {})>'."`; - -exports[`Typescript 4.3 detects errors 16`] = `"150:38 - Namespace '\\"index\\"' has no exported member 'DataType'."`; diff --git a/__tests__/__snapshots__/dist.typescript-4.4.ts.snap b/__tests__/__snapshots__/dist.typescript-4.4.ts.snap index 5ab006e..f8d61ba 100644 --- a/__tests__/__snapshots__/dist.typescript-4.4.ts.snap +++ b/__tests__/__snapshots__/dist.typescript-4.4.ts.snap @@ -38,5 +38,3 @@ exports[`Typescript 4.4 detects errors 13`] = `"134:25 - This condition will alw exports[`Typescript 4.4 detects errors 14`] = `"144:34 - Argument of type '1' is not assignable to parameter of type 'Width<0 | (string & {})> | [Width<0 | (string & {})>]'."`; exports[`Typescript 4.4 detects errors 15`] = `"145:35 - Type '1' is not assignable to type 'Width<0 | (string & {})>'."`; - -exports[`Typescript 4.4 detects errors 16`] = `"150:38 - Namespace '\\"index\\"' has no exported member 'DataType'."`; diff --git a/__tests__/__snapshots__/dist.typescript-4.5.ts.snap b/__tests__/__snapshots__/dist.typescript-4.5.ts.snap index dad7e57..2728bd1 100644 --- a/__tests__/__snapshots__/dist.typescript-4.5.ts.snap +++ b/__tests__/__snapshots__/dist.typescript-4.5.ts.snap @@ -38,5 +38,3 @@ exports[`Typescript 4.5 detects errors 13`] = `"134:25 - This condition will alw exports[`Typescript 4.5 detects errors 14`] = `"144:34 - Argument of type '1' is not assignable to parameter of type 'Width<0 | (string & {})> | [Width<0 | (string & {})>]'."`; exports[`Typescript 4.5 detects errors 15`] = `"145:35 - Type '1' is not assignable to type 'Width<0 | (string & {})>'."`; - -exports[`Typescript 4.5 detects errors 16`] = `"150:38 - Namespace '\\"index\\"' has no exported member 'DataType'."`; diff --git a/__tests__/__snapshots__/dist.typescript-latest.ts.snap b/__tests__/__snapshots__/dist.typescript-latest.ts.snap index 6bf33cf..f77f3de 100644 --- a/__tests__/__snapshots__/dist.typescript-latest.ts.snap +++ b/__tests__/__snapshots__/dist.typescript-latest.ts.snap @@ -38,5 +38,3 @@ exports[`Typescript 4.6 detects errors 13`] = `"134:25 - This condition will alw exports[`Typescript 4.6 detects errors 14`] = `"144:34 - Argument of type '1' is not assignable to parameter of type 'Width<0 | (string & {})> | [Width<0 | (string & {})>]'."`; exports[`Typescript 4.6 detects errors 15`] = `"145:35 - Type '1' is not assignable to type 'Width<0 | (string & {})>'."`; - -exports[`Typescript 4.6 detects errors 16`] = `"150:38 - Namespace '\\"index\\"' has no exported member 'DataType'."`; diff --git a/__tests__/dist.typescript-3.5.ts b/__tests__/dist.typescript-3.5.ts index a3a6a0b..d5e07a0 100644 --- a/__tests__/dist.typescript-3.5.ts +++ b/__tests__/dist.typescript-3.5.ts @@ -14,7 +14,7 @@ describe('Typescript 3.5', () => { }); expect(Number(ts.versionMajorMinor)).toBe(3.5); - expect(errors.length).toBe(16); + expect(errors.length).toBe(15); for (const error of errors) { expect(error).toMatchSnapshot(); } diff --git a/__tests__/dist.typescript-3.6.ts b/__tests__/dist.typescript-3.6.ts index dfb02fe..d19b516 100644 --- a/__tests__/dist.typescript-3.6.ts +++ b/__tests__/dist.typescript-3.6.ts @@ -14,7 +14,7 @@ describe('Typescript 3.6', () => { }); expect(Number(ts.versionMajorMinor)).toBe(3.6); - expect(errors.length).toBe(16); + expect(errors.length).toBe(15); for (const error of errors) { expect(error).toMatchSnapshot(); } diff --git a/__tests__/dist.typescript-3.7.ts b/__tests__/dist.typescript-3.7.ts index a49293d..58e9015 100644 --- a/__tests__/dist.typescript-3.7.ts +++ b/__tests__/dist.typescript-3.7.ts @@ -14,7 +14,7 @@ describe('Typescript 3.7', () => { }); expect(Number(ts.versionMajorMinor)).toBe(3.7); - expect(errors.length).toBe(16); + expect(errors.length).toBe(15); for (const error of errors) { expect(error).toMatchSnapshot(); } diff --git a/__tests__/dist.typescript-3.8.ts b/__tests__/dist.typescript-3.8.ts index 3752258..9ab85a6 100644 --- a/__tests__/dist.typescript-3.8.ts +++ b/__tests__/dist.typescript-3.8.ts @@ -14,7 +14,7 @@ describe('Typescript 3.8', () => { }); expect(Number(ts.versionMajorMinor)).toBe(3.8); - expect(errors.length).toBe(16); + expect(errors.length).toBe(15); for (const error of errors) { expect(error).toMatchSnapshot(); } diff --git a/__tests__/dist.typescript-3.9.ts b/__tests__/dist.typescript-3.9.ts index 1615118..b3f86e6 100644 --- a/__tests__/dist.typescript-3.9.ts +++ b/__tests__/dist.typescript-3.9.ts @@ -14,7 +14,7 @@ describe('Typescript 3.9', () => { }); expect(Number(ts.versionMajorMinor)).toBe(3.9); - expect(errors.length).toBe(16); + expect(errors.length).toBe(15); for (const error of errors) { expect(error).toMatchSnapshot(); } diff --git a/__tests__/dist.typescript-4.0.ts b/__tests__/dist.typescript-4.0.ts index 6752f72..f8c6c65 100644 --- a/__tests__/dist.typescript-4.0.ts +++ b/__tests__/dist.typescript-4.0.ts @@ -14,7 +14,7 @@ describe('Typescript 4.0', () => { }); expect(Number(ts.versionMajorMinor)).toBe(4.0); - expect(errors.length).toBe(16); + expect(errors.length).toBe(15); for (const error of errors) { expect(error).toMatchSnapshot(); } diff --git a/__tests__/dist.typescript-4.1.ts b/__tests__/dist.typescript-4.1.ts index 0c48b3e..af578dd 100644 --- a/__tests__/dist.typescript-4.1.ts +++ b/__tests__/dist.typescript-4.1.ts @@ -14,7 +14,7 @@ describe('Typescript 4.1', () => { }); expect(Number(ts.versionMajorMinor)).toBe(4.1); - expect(errors.length).toBe(16); + expect(errors.length).toBe(15); for (const error of errors) { expect(error).toMatchSnapshot(); } diff --git a/__tests__/dist.typescript-4.2.ts b/__tests__/dist.typescript-4.2.ts index 350bdda..94f3ab3 100644 --- a/__tests__/dist.typescript-4.2.ts +++ b/__tests__/dist.typescript-4.2.ts @@ -14,7 +14,7 @@ describe('Typescript 4.2', () => { }); expect(Number(ts.versionMajorMinor)).toBe(4.2); - expect(errors.length).toBe(16); + expect(errors.length).toBe(15); for (const error of errors) { expect(error).toMatchSnapshot(); } diff --git a/__tests__/dist.typescript-4.3.ts b/__tests__/dist.typescript-4.3.ts index 5373ba2..c12be66 100644 --- a/__tests__/dist.typescript-4.3.ts +++ b/__tests__/dist.typescript-4.3.ts @@ -14,7 +14,7 @@ describe('Typescript 4.3', () => { }); expect(Number(ts.versionMajorMinor)).toBe(4.3); - expect(errors.length).toBe(16); + expect(errors.length).toBe(15); for (const error of errors) { expect(error).toMatchSnapshot(); } diff --git a/__tests__/dist.typescript-4.4.ts b/__tests__/dist.typescript-4.4.ts index 2b514e3..2cee6bc 100644 --- a/__tests__/dist.typescript-4.4.ts +++ b/__tests__/dist.typescript-4.4.ts @@ -14,7 +14,7 @@ describe('Typescript 4.4', () => { }); expect(Number(ts.versionMajorMinor)).toBe(4.4); - expect(errors.length).toBe(16); + expect(errors.length).toBe(15); for (const error of errors) { expect(error).toMatchSnapshot(); } diff --git a/__tests__/dist.typescript-4.5.ts b/__tests__/dist.typescript-4.5.ts index 0f3061f..426ac2f 100644 --- a/__tests__/dist.typescript-4.5.ts +++ b/__tests__/dist.typescript-4.5.ts @@ -14,7 +14,7 @@ describe('Typescript 4.5', () => { }); expect(Number(ts.versionMajorMinor)).toBe(4.5); - expect(errors.length).toBe(16); + expect(errors.length).toBe(15); for (const error of errors) { expect(error).toMatchSnapshot(); } diff --git a/__tests__/dist.typescript-latest.ts b/__tests__/dist.typescript-latest.ts index b80be66..076d7cc 100644 --- a/__tests__/dist.typescript-latest.ts +++ b/__tests__/dist.typescript-latest.ts @@ -14,7 +14,7 @@ describe('Typescript 4.6', () => { }); expect(Number(ts.versionMajorMinor)).toBe(4.6); - expect(errors.length).toBe(16); + expect(errors.length).toBe(15); for (const error of errors) { expect(error).toMatchSnapshot(); } diff --git a/index.d.ts b/index.d.ts index 4c51af4..470f542 100644 --- a/index.d.ts +++ b/index.d.ts @@ -20313,7 +20313,13 @@ export namespace AtRule { type Zoom = "auto" | (string & {}) | (number & {}); } -declare namespace DataType { +/** + * **Attention!** Data types receives its name from the spec. E.g. `` becomes `DataType.Color` and + * `` becomes `DataType.ContentDistribution`. It happens quite frequent that these data types + * are split into several data types or/and name changes as the spec develops. So there's a risk that a minor/patch + * update from `csstype` can break your typing if you're using the `DataType` namespace. + */ +export namespace DataType { type AbsoluteSize = "large" | "medium" | "small" | "x-large" | "x-small" | "xx-large" | "xx-small" | "xxx-large"; type AnimateableFeature = "contents" | "scroll-position" | (string & {}); diff --git a/src/declarator.ts b/src/declarator.ts index f813a13..26965d2 100644 --- a/src/declarator.ts +++ b/src/declarator.ts @@ -71,7 +71,7 @@ export type SimpleType = Exclude; export interface INamespace { name: string; - export: boolean; + comment?: string; body: () => (Interface | IDeclaration)[]; } @@ -274,12 +274,16 @@ export async function declarator(minTypesInDataTypes: number) { const propertyNamespace: INamespace = { name: 'Property', - export: true, body: () => Array.from(propertyDeclarations.values()), }; const dataTypeNamespace: INamespace = { name: 'DataType', - export: false, + comment: `/** + * **Attention!** Data types receives its name from the spec. E.g. \`\` becomes \`DataType.Color\` and + * \`\` becomes \`DataType.ContentDistribution\`. It happens quite frequent that these data types + * are split into several data types or/and name changes as the spec develops. So there's a risk that a minor/patch + * update from \`csstype\` can break your typing if you're using the \`DataType\` namespace. + */`, body: () => Array.from(dataTypeDeclarations.values()), }; @@ -374,7 +378,6 @@ export async function declarator(minTypesInDataTypes: number) { const atRuleInterfaces: Interface[] = []; const atRuleNamespace: INamespace = { name: 'AtRule', - export: true, body: () => [...atRuleInterfaces, ...Array.from(atRuleDeclarations.values())], }; diff --git a/src/typescript.ts b/src/typescript.ts index 741abdf..5bd965b 100644 --- a/src/typescript.ts +++ b/src/typescript.ts @@ -38,13 +38,11 @@ export default async function typescript() { namespaceOutput += EOL; } - if (namespace.export) { - namespaceOutput += 'export '; - } else { - namespaceOutput += 'declare '; + if (namespace.comment) { + namespaceOutput += namespace.comment + EOL; } - namespaceOutput += `namespace ${namespace.name} {${EOL}`; + namespaceOutput += `export namespace ${namespace.name} {${EOL}`; const body = namespace.body();