Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: use stripInternal for tsc build #166

Merged
merged 3 commits into from
Feb 9, 2023

Conversation

vpanta
Copy link
Contributor

@vpanta vpanta commented Dec 6, 2022

Prevents @internal types from being included in final artifacts.

Problem

Currently, the @internal Generable type is being included in the published package. When building against it with tsc, we are getting errors such as:

node_modules/@circleci/circleci-config-sdk/dist/src/lib/Components/index.d.ts:18:5 - error TS1131: Property or signature expected.

18     get generableType(): GenerableType;
       ~~~

node_modules/@circleci/circleci-config-sdk/dist/src/lib/Components/index.d.ts:18:9 - error TS1005: ';' expected.

18     get generableType(): GenerableType;
           ~~~~~~~~~~~~~

node_modules/@circleci/circleci-config-sdk/dist/src/lib/Components/index.d.ts:18:24 - error TS1005: ';' expected.

18     get generableType(): GenerableType;
                          ~

node_modules/@circleci/circleci-config-sdk/dist/src/lib/Components/index.d.ts:19:1 - error TS1128: Declaration or statement expected.

19 }
   ~

Solution

Use stripInternal in the tsconfig's compilerOptions, which ensures this gets removed. Without this type in the final product, our tsc builds succeed.

Diff in artifacts

Using npm run build, the diff in the generated package is the following:

diff --git a/node_modules/@circleci/circleci-config-sdk/dist/src/lib/Components/index.d.ts b/node_modules/@circleci/circleci-config-sdk/dist/src/lib/Components/index.d.ts
index 35b443e..e26a57a 100644
--- a/node_modules/@circleci/circleci-config-sdk/dist/src/lib/Components/index.d.ts
+++ b/node_modules/@circleci/circleci-config-sdk/dist/src/lib/Components/index.d.ts
@@ -1,20 +1,2 @@
-import { GenerableType } from '../Config/exports/Mapping';
-/**
- * @internal
- */
-export interface Generable {
-    /**
-     * Generate the CircleCI YAML equivalent JSON for config compilation
-     * Generable's name is the key in the output.
-     */
-    generate(flatten?: boolean): unknown;
-    /**
-     * Generate the CircleCI YAML equivalent JSON contents for config compilation
-     */
-    generateContents?(flatten?: boolean): unknown;
-    /**
-     * Type of generable object
-     */
-    get generableType(): GenerableType;
-}
+export {};
 //# sourceMappingURL=index.d.ts.map
\ No newline at end of file
diff --git a/node_modules/@circleci/circleci-config-sdk/dist/src/lib/Components/index.d.ts.map b/node_modules/@circleci/circleci-config-sdk/dist/src/lib/Components/index.d.ts.map
index 7f6c01d..e4534a1 100644
--- a/node_modules/@circleci/circleci-config-sdk/dist/src/lib/Components/index.d.ts.map
+++ b/node_modules/@circleci/circleci-config-sdk/dist/src/lib/Components/index.d.ts.map
@@ -1 +1 @@
-{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE1D;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB;;;OAGG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;IAErC;;OAEG;IACH,gBAAgB,CAAC,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;IAE9C;;OAEG;IACH,IAAI,aAAa,IAAI,aAAa,CAAC;CACpC"}
\ No newline at end of file
+{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/index.ts"],"names":[],"mappings":""}
\ No newline at end of file

Prevents `@internal` types from being included in final artifacts
@ghost
Copy link

ghost commented Dec 6, 2022

👇 Click on the image for a new way to code review
  • Make big changes easier — review code in small groups of related files

  • Know where to start — see the whole change at a glance

  • Take a code tour — explore the change with an interactive tour

  • Make comments and review — all fully sync’ed with github

    Try it now!

Review these changes using an interactive CodeSee Map

Legend

CodeSee Map Legend

@KyleTryon KyleTryon self-requested a review February 9, 2023 19:56
@KyleTryon KyleTryon merged commit f1567a3 into CircleCI-Public:main Feb 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants