-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(cli): handle non
@types
imports from tsconfig `compilerOptions.…
…types` (#7548) Synced from #785 by walkerburgin: --- The TypeScript docs for `compilerOptions.types` make it sound like `compilerOptions.types` only applies to `@types` packages, but in practice it can also be used to include types from non `@types` in the global scope. For example, `cypress` recommends this in their [docs](https://docs.cypress.io/app/tooling/typescript-support#Configure-tsconfigjson): ```json { "compilerOptions": { "target": "es5", "lib": ["es5", "dom"], "types": ["cypress", "node"] }, "include": ["**/*.ts"] } ``` From what I can tell, if you don't specify `compilerOptions.types`, TypeScript will **not** automatically include types from a visible non `@types` package like `cypress` (`describe`, `beforeEach`, etc). But you can include non `@types` packages in `compilerOptions.types` to allow list them into the global scope. --- ### Changes are visible to end-users: no ### Test plan I updated the existing test case for `compilerOptions.types`. - Covered by existing test cases - New test cases added Closes #785 Co-authored-by: Walker Burgin <wburgin@anduril.com> GitOrigin-RevId: 4321e2b70b9e8d1f68fff219b42cae02a5d3205a
- Loading branch information
1 parent
8f91b83
commit 864c2f2
Showing
7 changed files
with
16 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
# gazelle:js_ignore_imports @types/ignored | ||
# gazelle:js_ignore_imports @types/test__ignored | ||
# gazelle:js_ignore_imports ignored | ||
# gazelle:js_ignore_imports @test/ignored |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
load("@aspect_rules_ts//ts:defs.bzl", "ts_config") | ||
|
||
# gazelle:js_ignore_imports @types/ignored | ||
# gazelle:js_ignore_imports @types/test__ignored | ||
# gazelle:js_ignore_imports ignored | ||
# gazelle:js_ignore_imports @test/ignored | ||
|
||
ts_config( | ||
name = "tsconfig", | ||
src = "tsconfig.json", | ||
deps = [ | ||
"//:node_modules/@types/jquery", | ||
"//:node_modules/@types/testing-library__jest-dom", | ||
"//:node_modules/cypress", | ||
"//:tsconfig", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"extends": "../tsconfig.json", | ||
"compilerOptions": { | ||
"types": ["jquery", "@testing-library/jest-dom", "ignored", "@test/ignored"] | ||
"types": ["jquery", "@testing-library/jest-dom", "ignored", "@test/ignored", "cypress"] | ||
} | ||
} |