mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-11 10:46:28 -05:00
Template literal types and mapped type 'as' clauses (#40336)
* Initial implementation of string template types
* Accept new API baselines
* Accept new baselines
* Unified checking for large cross product union types
* Accept new baselines
* Ensure errors from union type resolution are reported
* Accept new baselines
* Compute constraints for string template types
* Support `as T` clause in mapped types
* Accept new API baselines
* Add missing semicolon
* Add checking of `as T` clauses
* Support casing modifiers in string template types
* Accept new baselines
* Bump keyword maximum length
* fix anders
* Revert "fix anders"
This reverts commit b3178d4618.
* Properly handle 'as T' clause with keyof for mapped type
* Fix lint error
* Single character inferences and anchored end span matching
* Fewer array copy operations in template literal type resolution
* Handle cases where 'as T' maps multiple properties onto one
* Fix lint error
* Store key type instead of type mapper in MappedSymbol
* No constraint on `in T` type when `as N` clause present
* Rename from TemplateType to TemplateLiteralType
* Accept new API baselines
* Add tests
* Accept new baselines
* Address CR feedback
* Accept new API baselines
Co-authored-by: Erich Gamma <egamma@microsoft.com>
This commit is contained in:
@@ -48,6 +48,6 @@ namespace ts.codefix {
|
||||
|
||||
function doChange(changes: textChanges.ChangeTracker, sourceFile: SourceFile, { container, typeNode, constraint, name }: Info): void {
|
||||
changes.replaceNode(sourceFile, container, factory.createMappedTypeNode(/*readonlyToken*/ undefined,
|
||||
factory.createTypeParameterDeclaration(name, factory.createTypeReferenceNode(constraint)), /*questionToken*/ undefined, typeNode));
|
||||
factory.createTypeParameterDeclaration(name, factory.createTypeReferenceNode(constraint)), /*nameType*/ undefined, /*questionToken*/ undefined, typeNode));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ namespace ts.codefix {
|
||||
const mappedIntersectionType = factory.createMappedTypeNode(
|
||||
hasEffectiveReadonlyModifier(indexSignature) ? factory.createModifier(SyntaxKind.ReadonlyKeyword) : undefined,
|
||||
mappedTypeParameter,
|
||||
/*nameType*/ undefined,
|
||||
indexSignature.questionToken,
|
||||
indexSignature.type);
|
||||
const intersectionType = factory.createIntersectionTypeNode([
|
||||
|
||||
Reference in New Issue
Block a user