-
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.
fix: Update expected output tests and standardise transient type erro…
…r messages
- Loading branch information
1 parent
1b27e8a
commit 63f78fd
Showing
8 changed files
with
65 additions
and
47 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
type TransientTypeError = { | ||
usedAsType: string | ||
usedInExpression: string | ||
} | ||
|
||
export const transientTypeErrors = { | ||
arrays: (typeName) => ({ | ||
usedAsType: `\`${typeName}\` is not valid as a variable, parameter, return, or property type. Please define a static tuple type or use an \`as const\` expression`, | ||
usedInExpression: `Expression of type \`${typeName}\` cannot be used conditionally`, | ||
}), | ||
nativeNumeric: (typeName) => ({ | ||
usedAsType: `\`${typeName}\` is not valid as a variable, parameter, return, or property type. Please use an algo-ts type such as \`biguint\` or \`uint64\``, | ||
usedInExpression: `Expression of type \`${typeName}\` must be explicitly converted to an algo-ts type, for example by wrapping the expression in \`Uint64(...)\` or \`BigUint(...)\``, | ||
}), | ||
unionTypes: (typeName) => ({ | ||
usedAsType: `Union types are not valid as a variable, parameter, return, or property type. Expression type is ${typeName}`, | ||
usedInExpression: `Union types are only valid in boolean expressions. Expression type is ${typeName}`, | ||
}), | ||
} satisfies Record<string, (typeName: string) => TransientTypeError> |
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 |
---|---|---|
@@ -1,8 +1,8 @@ | ||
import type { uint64 } from '@algorandfoundation/algorand-typescript' | ||
|
||
function test(x: uint64, y: uint64) { | ||
// @expect-error Expression of type `number` must be explicitly converted to an algo-ts type... | ||
// @expect-error Expression of type `1 | 2` must be explicitly converted to an algo-ts type... | ||
const d: uint64 = (y % 2 ? 2 : 1) + (x < 4 ? x : y) | ||
// @expect-error Expression of type `number` must be explicitly converted to an algo-ts type... | ||
// @expect-error Expression of type `1 | 2` must be explicitly converted to an algo-ts type... | ||
const f = (y % 2 ? 2 : 1) === (x < 4 ? x : y) | ||
} |
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 @@ | ||
import { Uint64 } from '@algorandfoundation/algorand-typescript' | ||
|
||
function test() { | ||
// @expect-error Native array types are not valid as variable, parameter, return, or property types... | ||
// @expect-error `Array<uint64>` is not valid as a variable, parameter, return, or property type. Please define a static tuple type or use an `as const` expression | ||
const myArray = [Uint64(1), Uint64(2)] | ||
} |
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