generated from bazel-contrib/rules-template
-
-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support --noCheck for transpiling without type-checking
- Loading branch information
Showing
14 changed files
with
206 additions
and
48 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
load("@aspect_rules_ts//ts:defs.bzl", "ts_config") | ||
|
||
ts_config( | ||
name = "tsconfig", | ||
src = "tsconfig.json", | ||
visibility = [":__subpackages__"], | ||
) |
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
load("@aspect_bazel_lib//lib:testing.bzl", "assert_outputs") | ||
load("@aspect_rules_ts//ts:defs.bzl", "ts_project") | ||
|
||
ts_project( | ||
name = "backend", | ||
async_typecheck = True, | ||
declaration = True, | ||
tsconfig = "//examples/async_typecheck:tsconfig", | ||
deps = ["//examples/async_typecheck/core"], | ||
) | ||
|
||
assert_outputs( | ||
name = "test_backend_default_outputs", | ||
actual = "backend", | ||
expected = ["examples/async_typecheck/backend/index.js"], | ||
) |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import type { IntersectionType } from '../core' | ||
|
||
// Example object of IntersectionType | ||
const myObject: IntersectionType = { | ||
a: 42, | ||
b: 'backend', | ||
c: true, | ||
} | ||
|
||
console.log(myObject) |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
load("@aspect_rules_ts//ts:defs.bzl", "ts_project") | ||
|
||
ts_project( | ||
name = "core", | ||
async_typecheck = True, | ||
declaration = True, | ||
tsconfig = "//examples/async_typecheck:tsconfig", | ||
visibility = ["//examples/async_typecheck:__subpackages__"], | ||
) |
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** | ||
* A file with some non-trivial types, so type-checking it may take some time. | ||
* This helps to motivate the example: we'd like to be able to type-check the frontend and backend in parallel with this file. | ||
*/ | ||
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ( | ||
k: infer I | ||
) => void | ||
? I | ||
: never | ||
|
||
// Example usage | ||
type UnionType = { a: number } | { b: string } | { c: boolean } | ||
|
||
export type IntersectionType = UnionToIntersection<UnionType> | ||
|
||
export const MyIntersectingValue: IntersectionType = { | ||
a: 1, | ||
b: '2', | ||
c: true, | ||
} |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
load("@aspect_rules_ts//ts:defs.bzl", "ts_project") | ||
|
||
ts_project( | ||
name = "frontend", | ||
async_typecheck = True, | ||
tsconfig = { | ||
"compilerOptions": { | ||
"declaration": True, | ||
"isolatedDeclarations": True, | ||
}, | ||
}, | ||
deps = ["//examples/async_typecheck/core"], | ||
) |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import type { IntersectionType } from '../core' | ||
import { MyIntersectingValue } from '../core' | ||
|
||
// Example object of IntersectionType | ||
const myObject: IntersectionType = { | ||
a: 42, | ||
b: 'frontend', | ||
c: true, | ||
} | ||
|
||
const otherObject = MyIntersectingValue | ||
|
||
console.log(myObject, otherObject, myObject === otherObject) |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"compilerOptions": { | ||
"isolatedDeclarations": true, | ||
"declaration": true | ||
}, | ||
// Workaround https://github.com/microsoft/TypeScript/issues/59036 | ||
"exclude": [] | ||
} |
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
Oops, something went wrong.