diff --git a/index.d.ts b/index.d.ts index be09c6d..e13b345 100644 --- a/index.d.ts +++ b/index.d.ts @@ -258,6 +258,10 @@ interface ExpectedNull { type: 'null'; } +/** + * a pair of `ts.TemplateLiteralType.texts` and the `intrinsicName`s for `ts.TemplateLiteralType.types`, + * @see https://github.com/microsoft/TypeScript/pull/40336 + */ type TemplateLiteralPair = [string, 'string' | 'number' | 'bigint' | 'any' | 'undefined' | 'null' | undefined]; interface ExpectedTemplateLiteral { diff --git a/src/transform-inline/visitor-type-check.ts b/src/transform-inline/visitor-type-check.ts index b45df5f..b1dc71a 100644 --- a/src/transform-inline/visitor-type-check.ts +++ b/src/transform-inline/visitor-type-check.ts @@ -7,6 +7,7 @@ import * as VisitorIndexedAccess from './visitor-indexed-access'; import * as VisitorIsStringKeyof from './visitor-is-string-keyof'; import * as VisitorTypeName from './visitor-type-name'; import { sliceSet } from './utils'; +import {TemplateLiteralPair} from '../../index'; function visitDateType(type: ts.ObjectType, visitorContext: VisitorContext) { const name = VisitorTypeName.visitType(type, visitorContext, { type: 'type-check' }); @@ -695,7 +696,7 @@ function visitTemplateLiteralType(type: ts.TemplateLiteralType, visitorContext: const name = VisitorTypeName.visitType(type, visitorContext, {type: 'type-check'}); const typePairs = type.texts.reduce((prev, curr, i: number) => [...prev, [curr, typeof type.types[i] === 'undefined' ? undefined : VisitorUtils.getIntrinsicName(type.types[i])]] as never, - [] as VisitorUtils.TemplateLiteralPair[] + [] as TemplateLiteralPair[] ) const templateLiteralTypeError = VisitorUtils.createErrorObject({ type: 'template-literal', diff --git a/src/transform-inline/visitor-utils.ts b/src/transform-inline/visitor-utils.ts index 21d291b..03829f5 100644 --- a/src/transform-inline/visitor-utils.ts +++ b/src/transform-inline/visitor-utils.ts @@ -4,12 +4,6 @@ import * as tsutils from 'tsutils/typeguard/3.0'; import { VisitorContext } from './visitor-context'; import { Reason } from '../../index'; -/** - * a pair of {@link ts.TemplateLiteralType.texts} and the `intrinsicName`s for {@link ts.TemplateLiteralType.types}, - * @see https://github.com/microsoft/TypeScript/pull/40336 - */ -export type TemplateLiteralPair = [string, 'string' | 'number' | 'bigint' | 'any' | 'undefined' | 'null' | undefined]; - export const objectIdentifier = ts.createIdentifier('object'); export const pathIdentifier = ts.createIdentifier('path'); const keyIdentifier = ts.createIdentifier('key');