-
-
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.
feat: tsd expectDeprecated and expectNotDeprecated
- Loading branch information
Showing
6 changed files
with
141 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import type ts from 'unleashed-typescript'; | ||
import type { Assertion } from '../../types'; | ||
import { ErrorCode } from '../../../common/error'; | ||
import type { Compiler } from '../../../typescript/types'; | ||
import { argumentError, hasDeprecatedTag, missingArgument } from './util'; | ||
|
||
// https://github.dev/SamVerschueren/tsd/blob/e4a398c1b47a4d2f914446b662840e2be5994997/source/lib/assertions/handlers/expect-deprecated.ts#L11 | ||
export function expectDeprecated( | ||
{ node }: Assertion, | ||
{ sourceFile, typeChecker }: Compiler, | ||
): ts.Diagnostic | undefined { | ||
const argument = node.arguments[0]; | ||
|
||
if (!argument) { | ||
return missingArgument(node, sourceFile); | ||
} | ||
|
||
if (!hasDeprecatedTag(argument, typeChecker)) { | ||
return argumentError(ErrorCode.ASSERT_DEPRECATED, typeChecker, argument, sourceFile, node); | ||
} | ||
|
||
return; | ||
} |
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,23 @@ | ||
import type ts from 'unleashed-typescript'; | ||
import type { Assertion } from '../../types'; | ||
import { ErrorCode } from '../../../common/error'; | ||
import type { Compiler } from '../../../typescript/types'; | ||
import { argumentError, hasDeprecatedTag, missingArgument } from './util'; | ||
|
||
// https://github.dev/SamVerschueren/tsd/blob/e4a398c1b47a4d2f914446b662840e2be5994997/source/lib/assertions/handlers/expect-deprecated.ts#L11 | ||
export function expectNotDeprecated( | ||
{ node }: Assertion, | ||
{ sourceFile, typeChecker }: Compiler, | ||
): ts.Diagnostic | undefined { | ||
const argument = node.arguments[0]; | ||
|
||
if (!argument) { | ||
return missingArgument(node, sourceFile); | ||
} | ||
|
||
if (hasDeprecatedTag(argument, typeChecker)) { | ||
return argumentError(ErrorCode.ASSERT_NOT_DEPRECATED, typeChecker, argument, sourceFile, node); | ||
} | ||
|
||
return; | ||
} |
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