Compare commits
2 commits
Author | SHA1 | Date | |
---|---|---|---|
fb93b181ff | |||
26a626d045 |
|
@ -20747,7 +20747,7 @@ namespace ts {
|
|||
|
||||
function getBaseTypeOfLiteralType(type: Type): Type {
|
||||
return type.flags & TypeFlags.EnumLiteral ? getBaseTypeOfEnumLiteralType(type as LiteralType) :
|
||||
type.flags & TypeFlags.StringLiteral ? stringType :
|
||||
type.flags & (TypeFlags.StringLiteral | TypeFlags.TemplateLiteral | TypeFlags.StringMapping) ? stringType :
|
||||
type.flags & TypeFlags.NumberLiteral ? numberType :
|
||||
type.flags & TypeFlags.BigIntLiteral ? bigintType :
|
||||
type.flags & TypeFlags.BooleanLiteral ? booleanType :
|
||||
|
|
|
@ -198,4 +198,17 @@ tests/cases/conformance/types/literal/templateLiteralTypes3.ts(141,9): error TS2
|
|||
action.response;
|
||||
}
|
||||
}
|
||||
|
||||
// Repro from #46768
|
||||
|
||||
type DotString = `${string}.${string}.${string}`;
|
||||
|
||||
declare function noSpread<P extends DotString>(args: P[]): P;
|
||||
declare function spread<P extends DotString>(...args: P[]): P;
|
||||
|
||||
noSpread([`1.${'2'}.3`, `1.${'2'}.4`]);
|
||||
noSpread([`1.${'2' as string}.3`, `1.${'2' as string}.4`]);
|
||||
|
||||
spread(`1.${'2'}.3`, `1.${'2'}.4`);
|
||||
spread(`1.${'2' as string}.3`, `1.${'2' as string}.4`);
|
||||
|
|
@ -170,6 +170,19 @@ function reducer(action: Action) {
|
|||
action.response;
|
||||
}
|
||||
}
|
||||
|
||||
// Repro from #46768
|
||||
|
||||
type DotString = `${string}.${string}.${string}`;
|
||||
|
||||
declare function noSpread<P extends DotString>(args: P[]): P;
|
||||
declare function spread<P extends DotString>(...args: P[]): P;
|
||||
|
||||
noSpread([`1.${'2'}.3`, `1.${'2'}.4`]);
|
||||
noSpread([`1.${'2' as string}.3`, `1.${'2' as string}.4`]);
|
||||
|
||||
spread(`1.${'2'}.3`, `1.${'2'}.4`);
|
||||
spread(`1.${'2' as string}.3`, `1.${'2' as string}.4`);
|
||||
|
||||
|
||||
//// [templateLiteralTypes3.js]
|
||||
|
@ -257,6 +270,10 @@ function reducer(action) {
|
|||
action.response;
|
||||
}
|
||||
}
|
||||
noSpread(["1.".concat('2', ".3"), "1.".concat('2', ".4")]);
|
||||
noSpread(["1.".concat('2', ".3"), "1.".concat('2', ".4")]);
|
||||
spread("1.".concat('2', ".3"), "1.".concat('2', ".4"));
|
||||
spread("1.".concat('2', ".3"), "1.".concat('2', ".4"));
|
||||
|
||||
|
||||
//// [templateLiteralTypes3.d.ts]
|
||||
|
@ -324,3 +341,6 @@ declare type Action = {
|
|||
response: string;
|
||||
};
|
||||
declare function reducer(action: Action): void;
|
||||
declare type DotString = `${string}.${string}.${string}`;
|
||||
declare function noSpread<P extends DotString>(args: P[]): P;
|
||||
declare function spread<P extends DotString>(...args: P[]): P;
|
||||
|
|
|
@ -516,3 +516,36 @@ function reducer(action: Action) {
|
|||
}
|
||||
}
|
||||
|
||||
// Repro from #46768
|
||||
|
||||
type DotString = `${string}.${string}.${string}`;
|
||||
>DotString : Symbol(DotString, Decl(templateLiteralTypes3.ts, 170, 1))
|
||||
|
||||
declare function noSpread<P extends DotString>(args: P[]): P;
|
||||
>noSpread : Symbol(noSpread, Decl(templateLiteralTypes3.ts, 174, 49))
|
||||
>P : Symbol(P, Decl(templateLiteralTypes3.ts, 176, 26))
|
||||
>DotString : Symbol(DotString, Decl(templateLiteralTypes3.ts, 170, 1))
|
||||
>args : Symbol(args, Decl(templateLiteralTypes3.ts, 176, 47))
|
||||
>P : Symbol(P, Decl(templateLiteralTypes3.ts, 176, 26))
|
||||
>P : Symbol(P, Decl(templateLiteralTypes3.ts, 176, 26))
|
||||
|
||||
declare function spread<P extends DotString>(...args: P[]): P;
|
||||
>spread : Symbol(spread, Decl(templateLiteralTypes3.ts, 176, 61))
|
||||
>P : Symbol(P, Decl(templateLiteralTypes3.ts, 177, 24))
|
||||
>DotString : Symbol(DotString, Decl(templateLiteralTypes3.ts, 170, 1))
|
||||
>args : Symbol(args, Decl(templateLiteralTypes3.ts, 177, 45))
|
||||
>P : Symbol(P, Decl(templateLiteralTypes3.ts, 177, 24))
|
||||
>P : Symbol(P, Decl(templateLiteralTypes3.ts, 177, 24))
|
||||
|
||||
noSpread([`1.${'2'}.3`, `1.${'2'}.4`]);
|
||||
>noSpread : Symbol(noSpread, Decl(templateLiteralTypes3.ts, 174, 49))
|
||||
|
||||
noSpread([`1.${'2' as string}.3`, `1.${'2' as string}.4`]);
|
||||
>noSpread : Symbol(noSpread, Decl(templateLiteralTypes3.ts, 174, 49))
|
||||
|
||||
spread(`1.${'2'}.3`, `1.${'2'}.4`);
|
||||
>spread : Symbol(spread, Decl(templateLiteralTypes3.ts, 176, 61))
|
||||
|
||||
spread(`1.${'2' as string}.3`, `1.${'2' as string}.4`);
|
||||
>spread : Symbol(spread, Decl(templateLiteralTypes3.ts, 176, 61))
|
||||
|
||||
|
|
|
@ -513,3 +513,54 @@ function reducer(action: Action) {
|
|||
}
|
||||
}
|
||||
|
||||
// Repro from #46768
|
||||
|
||||
type DotString = `${string}.${string}.${string}`;
|
||||
>DotString : `${string}.${string}.${string}`
|
||||
|
||||
declare function noSpread<P extends DotString>(args: P[]): P;
|
||||
>noSpread : <P extends `${string}.${string}.${string}`>(args: P[]) => P
|
||||
>args : P[]
|
||||
|
||||
declare function spread<P extends DotString>(...args: P[]): P;
|
||||
>spread : <P extends `${string}.${string}.${string}`>(...args: P[]) => P
|
||||
>args : P[]
|
||||
|
||||
noSpread([`1.${'2'}.3`, `1.${'2'}.4`]);
|
||||
>noSpread([`1.${'2'}.3`, `1.${'2'}.4`]) : "1.2.3" | "1.2.4"
|
||||
>noSpread : <P extends `${string}.${string}.${string}`>(args: P[]) => P
|
||||
>[`1.${'2'}.3`, `1.${'2'}.4`] : ("1.2.3" | "1.2.4")[]
|
||||
>`1.${'2'}.3` : "1.2.3"
|
||||
>'2' : "2"
|
||||
>`1.${'2'}.4` : "1.2.4"
|
||||
>'2' : "2"
|
||||
|
||||
noSpread([`1.${'2' as string}.3`, `1.${'2' as string}.4`]);
|
||||
>noSpread([`1.${'2' as string}.3`, `1.${'2' as string}.4`]) : `1.${string}.3` | `1.${string}.4`
|
||||
>noSpread : <P extends `${string}.${string}.${string}`>(args: P[]) => P
|
||||
>[`1.${'2' as string}.3`, `1.${'2' as string}.4`] : (`1.${string}.3` | `1.${string}.4`)[]
|
||||
>`1.${'2' as string}.3` : `1.${string}.3`
|
||||
>'2' as string : string
|
||||
>'2' : "2"
|
||||
>`1.${'2' as string}.4` : `1.${string}.4`
|
||||
>'2' as string : string
|
||||
>'2' : "2"
|
||||
|
||||
spread(`1.${'2'}.3`, `1.${'2'}.4`);
|
||||
>spread(`1.${'2'}.3`, `1.${'2'}.4`) : "1.2.3" | "1.2.4"
|
||||
>spread : <P extends `${string}.${string}.${string}`>(...args: P[]) => P
|
||||
>`1.${'2'}.3` : "1.2.3"
|
||||
>'2' : "2"
|
||||
>`1.${'2'}.4` : "1.2.4"
|
||||
>'2' : "2"
|
||||
|
||||
spread(`1.${'2' as string}.3`, `1.${'2' as string}.4`);
|
||||
>spread(`1.${'2' as string}.3`, `1.${'2' as string}.4`) : `1.${string}.3` | `1.${string}.4`
|
||||
>spread : <P extends `${string}.${string}.${string}`>(...args: P[]) => P
|
||||
>`1.${'2' as string}.3` : `1.${string}.3`
|
||||
>'2' as string : string
|
||||
>'2' : "2"
|
||||
>`1.${'2' as string}.4` : `1.${string}.4`
|
||||
>'2' as string : string
|
||||
>'2' : "2"
|
||||
|
||||
|
|
|
@ -172,3 +172,16 @@ function reducer(action: Action) {
|
|||
action.response;
|
||||
}
|
||||
}
|
||||
|
||||
// Repro from #46768
|
||||
|
||||
type DotString = `${string}.${string}.${string}`;
|
||||
|
||||
declare function noSpread<P extends DotString>(args: P[]): P;
|
||||
declare function spread<P extends DotString>(...args: P[]): P;
|
||||
|
||||
noSpread([`1.${'2'}.3`, `1.${'2'}.4`]);
|
||||
noSpread([`1.${'2' as string}.3`, `1.${'2' as string}.4`]);
|
||||
|
||||
spread(`1.${'2'}.3`, `1.${'2'}.4`);
|
||||
spread(`1.${'2' as string}.3`, `1.${'2' as string}.4`);
|
||||
|
|
Loading…
Reference in a new issue