Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion src/transform-inline/visitor-type-check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' });
Expand Down Expand Up @@ -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',
Expand Down
6 changes: 0 additions & 6 deletions src/transform-inline/visitor-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down