Skip to content

Commit

Permalink
chore(typings): use solution config file to proerly check extensions/…
Browse files Browse the repository at this point in the history
…declaration without leaking globals
  • Loading branch information
Hotell committed Nov 16, 2021
1 parent 08064c2 commit 17a6794
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 5 deletions.
5 changes: 5 additions & 0 deletions typings/custom-global/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {},
"include": ["*.d.ts"]
}
11 changes: 8 additions & 3 deletions typings/environment/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,14 @@ declare namespace NodeJS {
};
}

// @ts-ignore - ignore type checking on `/typings` package scope, because `@types/webpack-env` defines `env` as `any`,
// thus making extension incompatible.
// - `@types/webpack-env` leaks here because we override `@storybook/addons` module type definitions which internally reference `@types/webpack-env`
/**
* NOTE:
* proper DX and type-checking wont work whenever a library that uses `@types/webpack-env` is used in your code.
*
* WHY?:
* - `@types/webpack-env` defines `env` as `any`, thus making extension incompatible. @see https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/webpack-env/index.d.ts#L275
* - `@storybook/addons` module type definitions internally reference `@types/webpack-env` so `process.env` type checking/DX wont work in all storybook configs/files
*/
export interface ProcessEnv extends ExtendedProcessEnv {}
}

Expand Down
5 changes: 5 additions & 0 deletions typings/environment/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {},
"include": ["*.d.ts"]
}
5 changes: 5 additions & 0 deletions typings/inline-style-expand-shorthand/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {},
"include": ["*.d.ts"]
}
2 changes: 1 addition & 1 deletion typings/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"version": "0.0.1",
"private": true,
"scripts": {
"type-check": "tsc -p ./tsconfig.json"
"type-check": "tsc -b ./tsconfig.json"
}
}
5 changes: 5 additions & 0 deletions typings/static-assets/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {},
"include": ["*.d.ts"]
}
5 changes: 5 additions & 0 deletions typings/storybook__addons/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {},
"include": ["*.d.ts"]
}
20 changes: 19 additions & 1 deletion typings/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,23 @@
"noEmit": true,
"types": []
},
"include": ["**/*.d.ts"]
"include": [],
"files": [],
"references": [
{
"path": "./environment/tsconfig.json"
},
{
"path": "./static-assets/tsconfig.json"
},
{
"path": "./inline-style-expand-shorthand/tsconfig.json"
},
{
"path": "./storybook__addons/tsconfig.json"
},
{
"path": "./custom-global/tsconfig.json"
}
]
}

0 comments on commit 17a6794

Please sign in to comment.