-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Lexus Drumgold <[email protected]>
- Loading branch information
1 parent
8385019
commit 680e3be
Showing
10 changed files
with
121 additions
and
13 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* @file Type Tests - InferType | ||
* @module esast/nodes/tests/unit-d/InferType | ||
*/ | ||
|
||
import type { Data, Parent } from '@flex-development/esast' | ||
import type { Optional } from '@flex-development/tutils' | ||
import type * as TestSubject from '../type-infer' | ||
|
||
describe('unit-d:nodes/InferType', () => { | ||
type Subject = TestSubject.default | ||
type SubjectData = TestSubject.InferTypeData | ||
|
||
it('should extend Parent', () => { | ||
expectTypeOf<Subject>().toMatchTypeOf<Parent>() | ||
}) | ||
|
||
it('should match [data?: Optional<InferTypeData>]', () => { | ||
expectTypeOf<Subject>() | ||
.toHaveProperty('data') | ||
.toEqualTypeOf<Optional<SubjectData>>() | ||
}) | ||
|
||
it('should match [type: "inferType"]', () => { | ||
expectTypeOf<Subject>() | ||
.toHaveProperty('type') | ||
.toEqualTypeOf<'inferType'>() | ||
}) | ||
|
||
describe('InferTypeData', () => { | ||
it('should extend Data', () => { | ||
expectTypeOf<SubjectData>().toMatchTypeOf<Data>() | ||
}) | ||
}) | ||
}) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/** | ||
* @file Nodes - InferType | ||
* @module esast/nodes/InferType | ||
*/ | ||
|
||
import type { InternalComments } from '#internal' | ||
import type { | ||
Comments, | ||
Data, | ||
ExtendsClause, | ||
Identifier, | ||
Parent | ||
} from '@flex-development/esast' | ||
import type { Optional } from '@flex-development/tutils' | ||
|
||
/** | ||
* Info associated with `infer` types. | ||
* | ||
* @see {@linkcode Data} | ||
* | ||
* @extends {Data} | ||
*/ | ||
interface InferTypeData extends Data {} | ||
|
||
/** | ||
* An `infer` type. | ||
* | ||
* @see {@linkcode Parent} | ||
* @see https://www.typescriptlang.org/docs/handbook/2/conditional-types.html#inferring-within-conditional-types | ||
* | ||
* @extends {Parent} | ||
*/ | ||
interface InferType extends Parent { | ||
/** | ||
* List of children. | ||
* | ||
* @see {@linkcode Comments} | ||
* @see {@linkcode ExtendsClause} | ||
* @see {@linkcode Identifier} | ||
*/ | ||
children: | ||
| [ | ||
...comments: Comments, | ||
identifier: Identifier, | ||
...comments: InternalComments, | ||
extend: ExtendsClause | ||
] | ||
| [...comments: Comments, identifier: Identifier] | ||
|
||
/** | ||
* Info from the ecosystem. | ||
* | ||
* @see {@linkcode InferTypeData} | ||
*/ | ||
data?: Optional<InferTypeData> | ||
|
||
/** | ||
* Node type. | ||
*/ | ||
type: 'inferType' | ||
} | ||
|
||
export type { InferTypeData, InferType as default } |
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