mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge remote-tracking branch 'tsupstream/master'
This commit is contained in:
@@ -172,4 +172,45 @@ zhongsp <patrick.zhongsp@gmail.com> # Patrick Zhong
|
||||
T18970237136 <T18970237136@users.noreply.github.com> # @T18970237136
|
||||
JBerger <JBerger@melco.com>
|
||||
bootstraponline <code@bootstraponline.com> # @bootstraponline
|
||||
yortus <yortus@gmail.com> # @yortus
|
||||
yortus <yortus@gmail.com> # @yortus
|
||||
András Parditka <andraaspar@gmail.com>
|
||||
Anton Khlynovskiy <subzey@gmail.com>
|
||||
Charly POLY <cpoly55@gmail.com>
|
||||
Cotton Hou <himcotton@gmail.com>
|
||||
Ethan Resnick <ethan.resnick@gmail.com>
|
||||
Marius Schulz <marius.schulz@me.com>
|
||||
Mattias Buelens <mattias.buelens@gmail.com>
|
||||
Myles Megyesi <mylesmegyesi@users.noreply.github.com>
|
||||
Tim Lancina <tim@ionic.io>
|
||||
Aaron Holmes <aaron@aaronholmes.net> Aaron Holmes <aholmes@bltomato.com>
|
||||
Akshar Patel <akshar.patel.47@gmail.com>
|
||||
Ali Sabzevari <alisabzevari@gmail.com>
|
||||
Aliaksandr Radzivanovich <aradzivanovich@gmail.com>
|
||||
BuildTools <FranklinWhale@users.noreply.github.com> # Franklin Tse
|
||||
ChogyDan <danielhollocher@gmail.com> # Daniel Hollocher
|
||||
Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com> Daniel Rosenwasser <drosen@microsoft.com>
|
||||
David Kmenta <david.kmenta@lmc.eu>
|
||||
E020873 <nicolas.henry-partner@arcelormittal.com> # Nicolas Henry
|
||||
Elisée Maurer <elisee@sparklinlabs.com>
|
||||
Emilio García-Pumarino <emili.tfe@gmail.com> dashaus <emili.tfe@gmail.com>
|
||||
Guilherme Oenning <me@goenning.net>
|
||||
Herrington Darkholme <nonamesheep1@gmail.com>
|
||||
Ivo Gabe de Wolff <ivogabe@ivogabe.nl>
|
||||
Joey Wilson <joey.wilson.a@gmail.com>
|
||||
Jonathon Smith <failing@crashdive.co.uk>
|
||||
Juan Luis Boya García <ntrrgc@gmail.com>
|
||||
Kagami Sascha Rosylight <saschanaz@outlook.com>
|
||||
Lucien Greathouse <me@lpghatguy.com>
|
||||
Martin Vseticka <vseticka.martin@gmail.com>
|
||||
Mattias Buelens <mattias.buelens@opentelly.com>
|
||||
Michael Bromley <michael@michaelbromley.co.uk>
|
||||
Paul Jolly <paul@myitcv.org.uk>
|
||||
Perry Jiang <jiangperry@gmail.com>
|
||||
Peter Burns <rictic@google.com>
|
||||
Robert Coie <rac@intrigue.com>
|
||||
Thomas Loubiou <t.loubiou@systonic.fr>
|
||||
Tim Perry <tim.perry@softwire.com>
|
||||
Vidar Tonaas Fauske <vidartf@gmail.com>
|
||||
Viktor Zozulyak <zozulyakviktor@gmail.com>
|
||||
rix <rix@rixs-MacBook-Pro.local> # Richard Sentino
|
||||
rohitverma007 <rohitverma@live.ca> # Rohit Verma
|
||||
@@ -2,6 +2,7 @@ language: node_js
|
||||
|
||||
node_js:
|
||||
- 'stable'
|
||||
- '6'
|
||||
- '4'
|
||||
|
||||
sudo: false
|
||||
|
||||
+33
@@ -1,17 +1,23 @@
|
||||
TypeScript is authored by:
|
||||
* Aaron Holmes
|
||||
* Abubaker Bashir
|
||||
* Adam Freidin
|
||||
* Adi Dahiya
|
||||
* Ahmad Farid
|
||||
* Akshar Patel
|
||||
* Alex Eagle
|
||||
* Alexander Kuvaev
|
||||
* Alexander Rusakov
|
||||
* Ali Sabzevari
|
||||
* Aliaksandr Radzivanovich
|
||||
* Anatoly Ressin
|
||||
* Anders Hejlsberg
|
||||
* Andrej Baran
|
||||
* Andrew Z Allen
|
||||
* András Parditka
|
||||
* Andy Hanson
|
||||
* Anil Anar
|
||||
* Anton Khlynovskiy
|
||||
* Anton Tolmachev
|
||||
* Arnav Singh
|
||||
* Arthur Ozga
|
||||
@@ -27,16 +33,20 @@ TypeScript is authored by:
|
||||
* Brett Mayen
|
||||
* Bryan Forbes
|
||||
* Caitlin Potter
|
||||
* Charly POLY
|
||||
* Chris Bubernak
|
||||
* Christophe Vidal
|
||||
* Chuck Jazdzewski
|
||||
* Colby Russell
|
||||
* Colin Snover
|
||||
* Cotton Hou
|
||||
* Cyrus Najmabadi
|
||||
* Dafrok Zhang
|
||||
* Dan Corder
|
||||
* Dan Quirk
|
||||
* Daniel Hollocher
|
||||
* Daniel Rosenwasser
|
||||
* David Kmenta
|
||||
* David Li
|
||||
* David Souther
|
||||
* Denis Nedelyaev
|
||||
@@ -45,8 +55,11 @@ TypeScript is authored by:
|
||||
* Dirk Holtwick
|
||||
* Dom Chen
|
||||
* Doug Ilijev
|
||||
* Elisée Maurer
|
||||
* Emilio García-Pumarino
|
||||
* Eric Tsang
|
||||
* Erik Edrosa
|
||||
* Ethan Resnick
|
||||
* Ethan Rubio
|
||||
* Evan Martin
|
||||
* Evan Sebastian
|
||||
@@ -54,12 +67,14 @@ TypeScript is authored by:
|
||||
* Fabian Cook
|
||||
* @falsandtru
|
||||
* Frank Wallis
|
||||
* Franklin Tse
|
||||
* František Žiacik
|
||||
* Gabe Moothart
|
||||
* Gabriel Isenberg
|
||||
* Gilad Peleg
|
||||
* Godfrey Chan
|
||||
* Graeme Wicksted
|
||||
* Guilherme Oenning
|
||||
* Guillaume Salles
|
||||
* Guy Bedford
|
||||
* Harald Niesche
|
||||
@@ -78,12 +93,14 @@ TypeScript is authored by:
|
||||
* Jeffrey Morlan
|
||||
* Jesse Schalken
|
||||
* Jiri Tobisek
|
||||
* Joey Wilson
|
||||
* Johannes Rieken
|
||||
* John Vilk
|
||||
* Jonathan Bond-Caron
|
||||
* Jonathan Park
|
||||
* Jonathan Toland
|
||||
* Jonathan Turner
|
||||
* Jonathon Smith
|
||||
* Josh Abernathy
|
||||
* Josh Kalderimis
|
||||
* Josh Soref
|
||||
@@ -102,15 +119,21 @@ TypeScript is authored by:
|
||||
* Lucien Greathouse
|
||||
* Lukas Elmer
|
||||
* Marin Marinov
|
||||
* Marius Schulz
|
||||
* Martin Vseticka
|
||||
* Masahiro Wakame
|
||||
* Matt McCutchen
|
||||
* Mattias Buelens
|
||||
* Mattias Buelens
|
||||
* Max Deepfield
|
||||
* Micah Zoltu
|
||||
* Michael
|
||||
* Michael Bromley
|
||||
* Mohamed Hegazy
|
||||
* Myles Megyesi
|
||||
* Nathan Shively-Sanders
|
||||
* Nathan Yee
|
||||
* Nicolas Henry
|
||||
* Nima Zahedi
|
||||
* Noah Chen
|
||||
* Noj Vek
|
||||
@@ -119,9 +142,12 @@ TypeScript is authored by:
|
||||
* Omer Sheikh
|
||||
* Oskar Segersva¨rd
|
||||
* Patrick Zhong
|
||||
* Paul Jolly
|
||||
* Paul van Brenk
|
||||
* @pcbro
|
||||
* Pedro Maltez
|
||||
* Perry Jiang
|
||||
* Peter Burns
|
||||
* Philip Bulley
|
||||
* Piero Cangianiello
|
||||
* @piloopin
|
||||
@@ -130,6 +156,9 @@ TypeScript is authored by:
|
||||
* Punya Biswal
|
||||
* Rado Kirov
|
||||
* Richard Knoll
|
||||
* Richard Sentino
|
||||
* Robert Coie
|
||||
* Rohit Verma
|
||||
* Ron Buckton
|
||||
* Rostislav Galimsky
|
||||
* Rowan Wyborn
|
||||
@@ -152,7 +181,9 @@ TypeScript is authored by:
|
||||
* @T18970237136
|
||||
* Tarik Ozket
|
||||
* Tetsuharu Ohzeki
|
||||
* Thomas Loubiou
|
||||
* Tien Hoanhtien
|
||||
* Tim Lancina
|
||||
* Tim Perry
|
||||
* Tim Viiding-Spader
|
||||
* Tingan Ho
|
||||
@@ -161,6 +192,8 @@ TypeScript is authored by:
|
||||
* Tomas Grubliauskas
|
||||
* Torben Fitschen
|
||||
* TruongSinh Tran-Nguyen
|
||||
* Vidar Tonaas Fauske
|
||||
* Viktor Zozulyak
|
||||
* Vilic Vane
|
||||
* Vladimir Matveev
|
||||
* Wesley Wigham
|
||||
|
||||
@@ -250,6 +250,7 @@ var harnessSources = harnessCoreSources.concat([
|
||||
"convertToBase64.ts",
|
||||
"transpile.ts",
|
||||
"reuseProgramStructure.ts",
|
||||
"textStorage.ts",
|
||||
"cachingInServerLSHost.ts",
|
||||
"moduleResolution.ts",
|
||||
"tsconfigParsing.ts",
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ import jobs.generation.Utilities;
|
||||
def project = GithubProject
|
||||
def branch = GithubBranchName
|
||||
|
||||
def nodeVersions = ['stable', '4']
|
||||
def nodeVersions = ['stable', '6', '4']
|
||||
|
||||
nodeVersions.each { nodeVer ->
|
||||
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@
|
||||
"tsserver": "./bin/tsserver"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.8.0"
|
||||
"node": ">=4.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/browserify": "latest",
|
||||
|
||||
+245
-123
@@ -1439,9 +1439,8 @@ namespace ts {
|
||||
// May be an untyped module. If so, ignore resolutionDiagnostic.
|
||||
if (!isRelative && resolvedModule && !extensionIsTypeScript(resolvedModule.extension)) {
|
||||
if (isForAugmentation) {
|
||||
Debug.assert(!!moduleNotFoundError);
|
||||
const diag = Diagnostics.Invalid_module_name_in_augmentation_Module_0_resolves_to_an_untyped_module_at_1_which_cannot_be_augmented;
|
||||
error(errorNode, diag, moduleName, resolvedModule.resolvedFileName);
|
||||
error(errorNode, diag, moduleReference, resolvedModule.resolvedFileName);
|
||||
}
|
||||
else if (compilerOptions.noImplicitAny && moduleNotFoundError) {
|
||||
error(errorNode,
|
||||
@@ -1742,7 +1741,19 @@ namespace ts {
|
||||
}
|
||||
|
||||
function getAccessibleSymbolChain(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags, useOnlyExternalAliasing: boolean): Symbol[] {
|
||||
function getAccessibleSymbolChainFromSymbolTable(symbols: SymbolTable): Symbol[] {
|
||||
function getAccessibleSymbolChainFromSymbolTable(symbols: SymbolTable) {
|
||||
return getAccessibleSymbolChainFromSymbolTableWorker(symbols, []);
|
||||
}
|
||||
|
||||
function getAccessibleSymbolChainFromSymbolTableWorker(symbols: SymbolTable, visitedSymbolTables: SymbolTable[]): Symbol[] {
|
||||
if (contains(visitedSymbolTables, symbols)) {
|
||||
return undefined;
|
||||
}
|
||||
visitedSymbolTables.push(symbols);
|
||||
const result = trySymbolTable(symbols);
|
||||
visitedSymbolTables.pop();
|
||||
return result;
|
||||
|
||||
function canQualifySymbol(symbolFromSymbolTable: Symbol, meaning: SymbolFlags) {
|
||||
// If the symbol is equivalent and doesn't need further qualification, this symbol is accessible
|
||||
if (!needsQualification(symbolFromSymbolTable, enclosingDeclaration, meaning)) {
|
||||
@@ -1764,34 +1775,36 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
// If symbol is directly available by its name in the symbol table
|
||||
if (isAccessible(symbols[symbol.name])) {
|
||||
return [symbol];
|
||||
}
|
||||
function trySymbolTable(symbols: SymbolTable) {
|
||||
// If symbol is directly available by its name in the symbol table
|
||||
if (isAccessible(symbols[symbol.name])) {
|
||||
return [symbol];
|
||||
}
|
||||
|
||||
// Check if symbol is any of the alias
|
||||
return forEachProperty(symbols, symbolFromSymbolTable => {
|
||||
if (symbolFromSymbolTable.flags & SymbolFlags.Alias
|
||||
&& symbolFromSymbolTable.name !== "export="
|
||||
&& !getDeclarationOfKind(symbolFromSymbolTable, SyntaxKind.ExportSpecifier)) {
|
||||
if (!useOnlyExternalAliasing || // We can use any type of alias to get the name
|
||||
// Is this external alias, then use it to name
|
||||
ts.forEach(symbolFromSymbolTable.declarations, isExternalModuleImportEqualsDeclaration)) {
|
||||
// Check if symbol is any of the alias
|
||||
return forEachProperty(symbols, symbolFromSymbolTable => {
|
||||
if (symbolFromSymbolTable.flags & SymbolFlags.Alias
|
||||
&& symbolFromSymbolTable.name !== "export="
|
||||
&& !getDeclarationOfKind(symbolFromSymbolTable, SyntaxKind.ExportSpecifier)) {
|
||||
if (!useOnlyExternalAliasing || // We can use any type of alias to get the name
|
||||
// Is this external alias, then use it to name
|
||||
ts.forEach(symbolFromSymbolTable.declarations, isExternalModuleImportEqualsDeclaration)) {
|
||||
|
||||
const resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable);
|
||||
if (isAccessible(symbolFromSymbolTable, resolveAlias(symbolFromSymbolTable))) {
|
||||
return [symbolFromSymbolTable];
|
||||
}
|
||||
const resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable);
|
||||
if (isAccessible(symbolFromSymbolTable, resolveAlias(symbolFromSymbolTable))) {
|
||||
return [symbolFromSymbolTable];
|
||||
}
|
||||
|
||||
// Look in the exported members, if we can find accessibleSymbolChain, symbol is accessible using this chain
|
||||
// but only if the symbolFromSymbolTable can be qualified
|
||||
const accessibleSymbolsFromExports = resolvedImportedSymbol.exports ? getAccessibleSymbolChainFromSymbolTable(resolvedImportedSymbol.exports) : undefined;
|
||||
if (accessibleSymbolsFromExports && canQualifySymbol(symbolFromSymbolTable, getQualifiedLeftMeaning(meaning))) {
|
||||
return [symbolFromSymbolTable].concat(accessibleSymbolsFromExports);
|
||||
// Look in the exported members, if we can find accessibleSymbolChain, symbol is accessible using this chain
|
||||
// but only if the symbolFromSymbolTable can be qualified
|
||||
const accessibleSymbolsFromExports = resolvedImportedSymbol.exports ? getAccessibleSymbolChainFromSymbolTableWorker(resolvedImportedSymbol.exports, visitedSymbolTables) : undefined;
|
||||
if (accessibleSymbolsFromExports && canQualifySymbol(symbolFromSymbolTable, getQualifiedLeftMeaning(meaning))) {
|
||||
return [symbolFromSymbolTable].concat(accessibleSymbolsFromExports);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (symbol) {
|
||||
@@ -2673,7 +2686,7 @@ namespace ts {
|
||||
}
|
||||
Debug.assert(bindingElement.kind === SyntaxKind.BindingElement);
|
||||
if (bindingElement.propertyName) {
|
||||
writer.writeSymbol(getTextOfNode(bindingElement.propertyName), bindingElement.symbol);
|
||||
writer.writeProperty(getTextOfNode(bindingElement.propertyName));
|
||||
writePunctuation(writer, SyntaxKind.ColonToken);
|
||||
writeSpace(writer);
|
||||
}
|
||||
@@ -3472,20 +3485,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
if (!popTypeResolution()) {
|
||||
if ((<VariableLikeDeclaration>symbol.valueDeclaration).type) {
|
||||
// Variable has type annotation that circularly references the variable itself
|
||||
type = unknownType;
|
||||
error(symbol.valueDeclaration, Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation,
|
||||
symbolToString(symbol));
|
||||
}
|
||||
else {
|
||||
// Variable has initializer that circularly references the variable itself
|
||||
type = anyType;
|
||||
if (compilerOptions.noImplicitAny) {
|
||||
error(symbol.valueDeclaration, Diagnostics._0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer,
|
||||
symbolToString(symbol));
|
||||
}
|
||||
}
|
||||
type = reportCircularityError(symbol);
|
||||
}
|
||||
links.type = type;
|
||||
}
|
||||
@@ -3619,11 +3619,33 @@ namespace ts {
|
||||
function getTypeOfInstantiatedSymbol(symbol: Symbol): Type {
|
||||
const links = getSymbolLinks(symbol);
|
||||
if (!links.type) {
|
||||
links.type = instantiateType(getTypeOfSymbol(links.target), links.mapper);
|
||||
if (!pushTypeResolution(symbol, TypeSystemPropertyName.Type)) {
|
||||
return unknownType;
|
||||
}
|
||||
let type = instantiateType(getTypeOfSymbol(links.target), links.mapper);
|
||||
if (!popTypeResolution()) {
|
||||
type = reportCircularityError(symbol);
|
||||
}
|
||||
links.type = type;
|
||||
}
|
||||
return links.type;
|
||||
}
|
||||
|
||||
function reportCircularityError(symbol: Symbol) {
|
||||
// Check if variable has type annotation that circularly references the variable itself
|
||||
if ((<VariableLikeDeclaration>symbol.valueDeclaration).type) {
|
||||
error(symbol.valueDeclaration, Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation,
|
||||
symbolToString(symbol));
|
||||
return unknownType;
|
||||
}
|
||||
// Otherwise variable has initializer that circularly references the variable itself
|
||||
if (compilerOptions.noImplicitAny) {
|
||||
error(symbol.valueDeclaration, Diagnostics._0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer,
|
||||
symbolToString(symbol));
|
||||
}
|
||||
return anyType;
|
||||
}
|
||||
|
||||
function getTypeOfSymbol(symbol: Symbol): Type {
|
||||
if (symbol.flags & SymbolFlags.Instantiated) {
|
||||
return getTypeOfInstantiatedSymbol(symbol);
|
||||
@@ -4512,18 +4534,17 @@ namespace ts {
|
||||
// Resolve upfront such that recursive references see an empty object type.
|
||||
setStructuredTypeMembers(type, emptySymbols, emptyArray, emptyArray, undefined, undefined);
|
||||
// In { [P in K]: T }, we refer to P as the type parameter type, K as the constraint type,
|
||||
// and T as the template type. If K is of the form 'keyof S', the mapped type and S are
|
||||
// homomorphic and we copy property modifiers from corresponding properties in S.
|
||||
// and T as the template type.
|
||||
const typeParameter = getTypeParameterFromMappedType(type);
|
||||
const constraintType = getConstraintTypeFromMappedType(type);
|
||||
const homomorphicType = getHomomorphicTypeFromMappedType(type);
|
||||
const templateType = getTemplateTypeFromMappedType(type);
|
||||
const modifiersType = getModifiersTypeFromMappedType(type);
|
||||
const templateReadonly = !!type.declaration.readonlyToken;
|
||||
const templateOptional = !!type.declaration.questionToken;
|
||||
// First, if the constraint type is a type parameter, obtain the base constraint. Then,
|
||||
// if the key type is a 'keyof X', obtain 'keyof C' where C is the base constraint of X.
|
||||
// Finally, iterate over the constituents of the resulting iteration type.
|
||||
const keyType = constraintType.flags & TypeFlags.TypeParameter ? getApparentType(constraintType) : constraintType;
|
||||
const keyType = constraintType.flags & TypeFlags.TypeVariable ? getApparentType(constraintType) : constraintType;
|
||||
const iterationType = keyType.flags & TypeFlags.Index ? getIndexType(getApparentType((<IndexType>keyType).type)) : keyType;
|
||||
forEachType(iterationType, t => {
|
||||
// Create a mapper from T to the current iteration type constituent. Then, if the
|
||||
@@ -4536,11 +4557,11 @@ namespace ts {
|
||||
// Otherwise, for type string create a string index signature.
|
||||
if (t.flags & TypeFlags.StringLiteral) {
|
||||
const propName = (<LiteralType>t).text;
|
||||
const homomorphicProp = homomorphicType && getPropertyOfType(homomorphicType, propName);
|
||||
const isOptional = templateOptional || !!(homomorphicProp && homomorphicProp.flags & SymbolFlags.Optional);
|
||||
const modifiersProp = getPropertyOfType(modifiersType, propName);
|
||||
const isOptional = templateOptional || !!(modifiersProp && modifiersProp.flags & SymbolFlags.Optional);
|
||||
const prop = <TransientSymbol>createSymbol(SymbolFlags.Property | SymbolFlags.Transient | (isOptional ? SymbolFlags.Optional : 0), propName);
|
||||
prop.type = propType;
|
||||
prop.isReadonly = templateReadonly || homomorphicProp && isReadonlySymbol(homomorphicProp);
|
||||
prop.isReadonly = templateReadonly || modifiersProp && isReadonlySymbol(modifiersProp);
|
||||
members[propName] = prop;
|
||||
}
|
||||
else if (t.flags & TypeFlags.String) {
|
||||
@@ -4567,9 +4588,26 @@ namespace ts {
|
||||
unknownType);
|
||||
}
|
||||
|
||||
function getHomomorphicTypeFromMappedType(type: MappedType) {
|
||||
const constraint = getConstraintDeclaration(getTypeParameterFromMappedType(type));
|
||||
return constraint.kind === SyntaxKind.TypeOperator ? instantiateType(getTypeFromTypeNode((<TypeOperatorNode>constraint).type), type.mapper || identityMapper) : undefined;
|
||||
function getModifiersTypeFromMappedType(type: MappedType) {
|
||||
if (!type.modifiersType) {
|
||||
const constraintDeclaration = type.declaration.typeParameter.constraint;
|
||||
if (constraintDeclaration.kind === SyntaxKind.TypeOperator) {
|
||||
// If the constraint declaration is a 'keyof T' node, the modifiers type is T. We check
|
||||
// AST nodes here because, when T is a non-generic type, the logic below eagerly resolves
|
||||
// 'keyof T' to a literal union type and we can't recover T from that type.
|
||||
type.modifiersType = instantiateType(getTypeFromTypeNode((<TypeOperatorNode>constraintDeclaration).type), type.mapper || identityMapper);
|
||||
}
|
||||
else {
|
||||
// Otherwise, get the declared constraint type, and if the constraint type is a type parameter,
|
||||
// get the constraint of that type parameter. If the resulting type is an indexed type 'keyof T',
|
||||
// the modifiers type is T. Otherwise, the modifiers type is {}.
|
||||
const declaredType = <MappedType>getTypeFromMappedTypeNode(type.declaration);
|
||||
const constraint = getConstraintTypeFromMappedType(declaredType);
|
||||
const extendedConstraint = constraint.flags & TypeFlags.TypeParameter ? getConstraintOfTypeParameter(<TypeParameter>constraint) : constraint;
|
||||
type.modifiersType = extendedConstraint.flags & TypeFlags.Index ? instantiateType((<IndexType>extendedConstraint).type, type.mapper || identityMapper) : emptyObjectType;
|
||||
}
|
||||
}
|
||||
return type.modifiersType;
|
||||
}
|
||||
|
||||
function getErasedTemplateTypeFromMappedType(type: MappedType) {
|
||||
@@ -4579,7 +4617,7 @@ namespace ts {
|
||||
function isGenericMappedType(type: Type) {
|
||||
if (getObjectFlags(type) & ObjectFlags.Mapped) {
|
||||
const constraintType = getConstraintTypeFromMappedType(<MappedType>type);
|
||||
return !!(constraintType.flags & (TypeFlags.TypeParameter | TypeFlags.Index));
|
||||
return maybeTypeOfKind(constraintType, TypeFlags.TypeVariable | TypeFlags.Index);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -4667,33 +4705,24 @@ namespace ts {
|
||||
* The apparent type of a type parameter is the base constraint instantiated with the type parameter
|
||||
* as the type argument for the 'this' type.
|
||||
*/
|
||||
function getApparentTypeOfTypeParameter(type: TypeParameter) {
|
||||
function getApparentTypeOfTypeVariable(type: TypeVariable) {
|
||||
if (!type.resolvedApparentType) {
|
||||
let constraintType = getConstraintOfTypeParameter(type);
|
||||
let constraintType = getConstraintOfTypeVariable(type);
|
||||
while (constraintType && constraintType.flags & TypeFlags.TypeParameter) {
|
||||
constraintType = getConstraintOfTypeParameter(<TypeParameter>constraintType);
|
||||
constraintType = getConstraintOfTypeVariable(<TypeVariable>constraintType);
|
||||
}
|
||||
type.resolvedApparentType = getTypeWithThisArgument(constraintType || emptyObjectType, type);
|
||||
}
|
||||
return type.resolvedApparentType;
|
||||
}
|
||||
|
||||
/**
|
||||
* The apparent type of an indexed access T[K] is the type of T's string index signature, if any.
|
||||
*/
|
||||
function getApparentTypeOfIndexedAccess(type: IndexedAccessType) {
|
||||
return getIndexTypeOfType(getApparentType(type.objectType), IndexKind.String) || type;
|
||||
}
|
||||
|
||||
/**
|
||||
* For a type parameter, return the base constraint of the type parameter. For the string, number,
|
||||
* boolean, and symbol primitive types, return the corresponding object types. Otherwise return the
|
||||
* type itself. Note that the apparent type of a union type is the union type itself.
|
||||
*/
|
||||
function getApparentType(type: Type): Type {
|
||||
const t = type.flags & TypeFlags.TypeParameter ? getApparentTypeOfTypeParameter(<TypeParameter>type) :
|
||||
type.flags & TypeFlags.IndexedAccess ? getApparentTypeOfIndexedAccess(<IndexedAccessType>type) :
|
||||
type;
|
||||
const t = type.flags & TypeFlags.TypeVariable ? getApparentTypeOfTypeVariable(<TypeVariable>type) : type;
|
||||
return t.flags & TypeFlags.StringLike ? globalStringType :
|
||||
t.flags & TypeFlags.NumberLike ? globalNumberType :
|
||||
t.flags & TypeFlags.BooleanLike ? globalBooleanType :
|
||||
@@ -5279,6 +5308,12 @@ namespace ts {
|
||||
return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint;
|
||||
}
|
||||
|
||||
function getConstraintOfTypeVariable(type: TypeVariable): Type {
|
||||
return type.flags & TypeFlags.TypeParameter ? getConstraintOfTypeParameter(<TypeParameter>type) :
|
||||
type.flags & TypeFlags.IndexedAccess ? (<IndexedAccessType>type).constraint :
|
||||
undefined;
|
||||
}
|
||||
|
||||
function getParentSymbolOfTypeParameter(typeParameter: TypeParameter): Symbol {
|
||||
return getSymbolOfNode(getDeclarationOfKind(typeParameter.symbol, SyntaxKind.TypeParameter).parent);
|
||||
}
|
||||
@@ -5912,7 +5947,7 @@ namespace ts {
|
||||
return links.resolvedType;
|
||||
}
|
||||
|
||||
function getIndexTypeForTypeVariable(type: TypeVariable) {
|
||||
function getIndexTypeForGenericType(type: TypeVariable | UnionOrIntersectionType) {
|
||||
if (!type.resolvedIndexType) {
|
||||
type.resolvedIndexType = <IndexType>createType(TypeFlags.Index);
|
||||
type.resolvedIndexType.type = type;
|
||||
@@ -5931,7 +5966,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function getIndexType(type: Type): Type {
|
||||
return type.flags & TypeFlags.TypeVariable ? getIndexTypeForTypeVariable(<TypeVariable>type) :
|
||||
return maybeTypeOfKind(type, TypeFlags.TypeVariable) ? getIndexTypeForGenericType(<TypeVariable | UnionOrIntersectionType>type) :
|
||||
getObjectFlags(type) & ObjectFlags.Mapped ? getConstraintTypeFromMappedType(<MappedType>type) :
|
||||
type.flags & TypeFlags.Any || getIndexInfoOfType(type, IndexKind.String) ? stringType :
|
||||
getLiteralTypeFromPropertyNames(type);
|
||||
@@ -5954,6 +5989,24 @@ namespace ts {
|
||||
const type = <IndexedAccessType>createType(TypeFlags.IndexedAccess);
|
||||
type.objectType = objectType;
|
||||
type.indexType = indexType;
|
||||
// We eagerly compute the constraint of the indexed access type such that circularity
|
||||
// errors are immediately caught and reported. For example, class C { x: this["x"] }
|
||||
// becomes an error only when the constraint is eagerly computed.
|
||||
if (type.objectType.flags & TypeFlags.StructuredType) {
|
||||
// The constraint of T[K], where T is an object, union, or intersection type,
|
||||
// is the type of the string index signature of T, if any.
|
||||
type.constraint = getIndexTypeOfType(type.objectType, IndexKind.String);
|
||||
}
|
||||
else if (type.objectType.flags & TypeFlags.TypeVariable) {
|
||||
// The constraint of T[K], where T is a type variable, is A[K], where A is the
|
||||
// apparent type of T.
|
||||
const apparentType = getApparentTypeOfTypeVariable(<TypeVariable>type.objectType);
|
||||
if (apparentType !== emptyObjectType) {
|
||||
type.constraint = isTypeOfKind((<IndexedAccessType>type).indexType, TypeFlags.StringLike) ?
|
||||
getIndexedAccessType(apparentType, (<IndexedAccessType>type).indexType) :
|
||||
getIndexTypeOfType(apparentType, IndexKind.String);
|
||||
}
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
@@ -6032,14 +6085,19 @@ namespace ts {
|
||||
}
|
||||
|
||||
function getIndexedAccessType(objectType: Type, indexType: Type, accessNode?: ElementAccessExpression | IndexedAccessTypeNode) {
|
||||
if (indexType.flags & TypeFlags.TypeVariable ||
|
||||
objectType.flags & TypeFlags.TypeVariable && indexType.flags & TypeFlags.Index ||
|
||||
// If the index type is generic, if the object type is generic and doesn't originate in an expression,
|
||||
// or if the object type is a mapped type with a generic constraint, we are performing a higher-order
|
||||
// index access where we cannot meaningfully access the properties of the object type. Note that for a
|
||||
// generic T and a non-generic K, we eagerly resolve T[K] if it originates in an expression. This is to
|
||||
// preserve backwards compatibility. For example, an element access 'this["foo"]' has always been resolved
|
||||
// eagerly using the constraint type of 'this' at the given location.
|
||||
if (maybeTypeOfKind(indexType, TypeFlags.TypeVariable | TypeFlags.Index) ||
|
||||
maybeTypeOfKind(objectType, TypeFlags.TypeVariable) && !(accessNode && accessNode.kind === SyntaxKind.ElementAccessExpression) ||
|
||||
isGenericMappedType(objectType)) {
|
||||
// If the object type is a type variable (a type parameter or another indexed access type), if the
|
||||
// index type is a type variable or an index type, or if the object type is a mapped type with a
|
||||
// generic constraint, we are performing a higher-order index access where we cannot meaningfully
|
||||
// access the properties of the object type. In those cases, we first check that the index type is
|
||||
// assignable to 'keyof T' for the object type.
|
||||
if (objectType.flags & TypeFlags.Any) {
|
||||
return objectType;
|
||||
}
|
||||
// We first check that the index type is assignable to 'keyof T' for the object type.
|
||||
if (accessNode) {
|
||||
if (!isTypeAssignableTo(indexType, getIndexType(objectType))) {
|
||||
error(accessNode, Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType));
|
||||
@@ -6056,6 +6114,7 @@ namespace ts {
|
||||
const id = objectType.id + "," + indexType.id;
|
||||
return indexedAccessTypes[id] || (indexedAccessTypes[id] = createIndexedAccessType(objectType, indexType));
|
||||
}
|
||||
// In the following we resolve T[K] to the type of the property in T selected by K.
|
||||
const apparentObjectType = getApparentType(objectType);
|
||||
if (indexType.flags & TypeFlags.Union && !(indexType.flags & TypeFlags.Primitive)) {
|
||||
const propTypes: Type[] = [];
|
||||
@@ -6539,7 +6598,7 @@ namespace ts {
|
||||
// union type A | undefined, we produce { [P in keyof A]: X } | undefined.
|
||||
const constraintType = getConstraintTypeFromMappedType(type);
|
||||
if (constraintType.flags & TypeFlags.Index) {
|
||||
const typeVariable = <TypeParameter>(<IndexType>constraintType).type;
|
||||
const typeVariable = (<IndexType>constraintType).type;
|
||||
const mappedTypeVariable = instantiateType(typeVariable, mapper);
|
||||
if (typeVariable !== mappedTypeVariable) {
|
||||
return mapType(mappedTypeVariable, t => {
|
||||
@@ -7162,6 +7221,25 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function isUnionOrIntersectionTypeWithoutNullableConstituents(type: Type): boolean {
|
||||
if (!(type.flags & TypeFlags.UnionOrIntersection)) {
|
||||
return false;
|
||||
}
|
||||
// at this point we know that this is union or intersection type possibly with nullable constituents.
|
||||
// check if we still will have compound type if we ignore nullable components.
|
||||
let seenNonNullable = false;
|
||||
for (const t of (<UnionOrIntersectionType>type).types) {
|
||||
if (t.flags & TypeFlags.Nullable) {
|
||||
continue;
|
||||
}
|
||||
if (seenNonNullable) {
|
||||
return true;
|
||||
}
|
||||
seenNonNullable = true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Compare two types and return
|
||||
// Ternary.True if they are related with no assumptions,
|
||||
// Ternary.Maybe if they are related with assumptions of other relationships, or
|
||||
@@ -7194,7 +7272,7 @@ namespace ts {
|
||||
// and intersection types are further deconstructed on the target side, we don't want to
|
||||
// make the check again (as it might fail for a partial target type). Therefore we obtain
|
||||
// the regular source type and proceed with that.
|
||||
if (target.flags & TypeFlags.UnionOrIntersection) {
|
||||
if (isUnionOrIntersectionTypeWithoutNullableConstituents(target)) {
|
||||
source = getRegularTypeOfObjectLiteral(source);
|
||||
}
|
||||
}
|
||||
@@ -7243,8 +7321,7 @@ namespace ts {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
if (target.flags & TypeFlags.TypeParameter) {
|
||||
else if (target.flags & TypeFlags.TypeParameter) {
|
||||
// A source type { [P in keyof T]: X } is related to a target type T if X is related to T[P].
|
||||
if (getObjectFlags(source) & ObjectFlags.Mapped && getConstraintTypeFromMappedType(<MappedType>source) === getIndexType(target)) {
|
||||
if (!(<MappedType>source).declaration.questionToken) {
|
||||
@@ -7273,10 +7350,10 @@ namespace ts {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
// Given a type parameter T with a constraint C, a type S is assignable to
|
||||
// Given a type variable T with a constraint C, a type S is assignable to
|
||||
// keyof T if S is assignable to keyof C.
|
||||
if ((<IndexType>target).type.flags & TypeFlags.TypeParameter) {
|
||||
const constraint = getConstraintOfTypeParameter(<TypeParameter>(<IndexType>target).type);
|
||||
if ((<IndexType>target).type.flags & TypeFlags.TypeVariable) {
|
||||
const constraint = getConstraintOfTypeVariable(<TypeVariable>(<IndexType>target).type);
|
||||
if (constraint) {
|
||||
if (result = isRelatedTo(source, getIndexType(constraint), reportErrors)) {
|
||||
return result;
|
||||
@@ -7292,6 +7369,14 @@ namespace ts {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
// A type S is related to a type T[K] if S is related to A[K], where K is string-like and
|
||||
// A is the apparent type of S.
|
||||
if ((<IndexedAccessType>target).constraint) {
|
||||
if (result = isRelatedTo(source, (<IndexedAccessType>target).constraint, reportErrors)) {
|
||||
errorInfo = saveErrorInfo;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (source.flags & TypeFlags.TypeParameter) {
|
||||
@@ -7300,6 +7385,7 @@ namespace ts {
|
||||
const indexedAccessType = getIndexedAccessType(source, getTypeParameterFromMappedType(<MappedType>target));
|
||||
const templateType = getTemplateTypeFromMappedType(<MappedType>target);
|
||||
if (result = isRelatedTo(indexedAccessType, templateType, reportErrors)) {
|
||||
errorInfo = saveErrorInfo;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -7321,6 +7407,16 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (source.flags & TypeFlags.IndexedAccess) {
|
||||
// A type S[K] is related to a type T if A[K] is related to T, where K is string-like and
|
||||
// A is the apparent type of S.
|
||||
if ((<IndexedAccessType>source).constraint) {
|
||||
if (result = isRelatedTo((<IndexedAccessType>source).constraint, target, reportErrors)) {
|
||||
errorInfo = saveErrorInfo;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (getObjectFlags(source) & ObjectFlags.Reference && getObjectFlags(target) & ObjectFlags.Reference && (<TypeReference>source).target === (<TypeReference>target).target) {
|
||||
// We have type references to same target type, see if relationship holds for all type arguments
|
||||
@@ -8708,12 +8804,15 @@ namespace ts {
|
||||
if (constraintType.flags & TypeFlags.Index) {
|
||||
// We're inferring from some source type S to a homomorphic mapped type { [P in keyof T]: X },
|
||||
// where T is a type variable. Use inferTypeForHomomorphicMappedType to infer a suitable source
|
||||
// type and then infer from that type to T.
|
||||
// type and then make a secondary inference from that type to T. We make a secondary inference
|
||||
// such that direct inferences to T get priority over inferences to Partial<T>, for example.
|
||||
const index = indexOf(typeVariables, (<IndexType>constraintType).type);
|
||||
if (index >= 0 && !typeInferences[index].isFixed) {
|
||||
const inferredType = inferTypeForHomomorphicMappedType(source, <MappedType>target);
|
||||
if (inferredType) {
|
||||
inferiority++;
|
||||
inferFromTypes(inferredType, typeVariables[index]);
|
||||
inferiority--;
|
||||
}
|
||||
}
|
||||
return;
|
||||
@@ -10404,6 +10503,29 @@ namespace ts {
|
||||
return baseConstructorType === nullWideningType;
|
||||
}
|
||||
|
||||
function checkThisBeforeSuper(node: Node, container: Node, diagnosticMessage: DiagnosticMessage) {
|
||||
const containingClassDecl = <ClassDeclaration>container.parent;
|
||||
const baseTypeNode = getClassExtendsHeritageClauseElement(containingClassDecl);
|
||||
|
||||
// If a containing class does not have extends clause or the class extends null
|
||||
// skip checking whether super statement is called before "this" accessing.
|
||||
if (baseTypeNode && !classDeclarationExtendsNull(containingClassDecl)) {
|
||||
const superCall = getSuperCallInConstructor(<ConstructorDeclaration>container);
|
||||
|
||||
// We should give an error in the following cases:
|
||||
// - No super-call
|
||||
// - "this" is accessing before super-call.
|
||||
// i.e super(this)
|
||||
// this.x; super();
|
||||
// We want to make sure that super-call is done before accessing "this" so that
|
||||
// "this" is not accessed as a parameter of the super-call.
|
||||
if (!superCall || superCall.end > node.pos) {
|
||||
// In ES6, super inside constructor of class-declaration has to precede "this" accessing
|
||||
error(node, diagnosticMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function checkThisExpression(node: Node): Type {
|
||||
// Stop at the first arrow function so that we can
|
||||
// tell whether 'this' needs to be captured.
|
||||
@@ -10411,26 +10533,7 @@ namespace ts {
|
||||
let needToCaptureLexicalThis = false;
|
||||
|
||||
if (container.kind === SyntaxKind.Constructor) {
|
||||
const containingClassDecl = <ClassDeclaration>container.parent;
|
||||
const baseTypeNode = getClassExtendsHeritageClauseElement(containingClassDecl);
|
||||
|
||||
// If a containing class does not have extends clause or the class extends null
|
||||
// skip checking whether super statement is called before "this" accessing.
|
||||
if (baseTypeNode && !classDeclarationExtendsNull(containingClassDecl)) {
|
||||
const superCall = getSuperCallInConstructor(<ConstructorDeclaration>container);
|
||||
|
||||
// We should give an error in the following cases:
|
||||
// - No super-call
|
||||
// - "this" is accessing before super-call.
|
||||
// i.e super(this)
|
||||
// this.x; super();
|
||||
// We want to make sure that super-call is done before accessing "this" so that
|
||||
// "this" is not accessed as a parameter of the super-call.
|
||||
if (!superCall || superCall.end > node.pos) {
|
||||
// In ES6, super inside constructor of class-declaration has to precede "this" accessing
|
||||
error(node, Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class);
|
||||
}
|
||||
}
|
||||
checkThisBeforeSuper(node, container, Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class);
|
||||
}
|
||||
|
||||
// Now skip arrow functions to get the "real" owner of 'this'.
|
||||
@@ -10578,6 +10681,10 @@ namespace ts {
|
||||
return unknownType;
|
||||
}
|
||||
|
||||
if (!isCallExpression && container.kind === SyntaxKind.Constructor) {
|
||||
checkThisBeforeSuper(node, container, Diagnostics.super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class);
|
||||
}
|
||||
|
||||
if ((getModifierFlags(container) & ModifierFlags.Static) || isCallExpression) {
|
||||
nodeCheckFlag = NodeCheckFlags.SuperStatic;
|
||||
}
|
||||
@@ -11243,13 +11350,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function checkSpreadExpression(node: SpreadElement, contextualMapper?: TypeMapper): Type {
|
||||
// It is usually not safe to call checkExpressionCached if we can be contextually typing.
|
||||
// You can tell that we are contextually typing because of the contextualMapper parameter.
|
||||
// While it is true that a spread element can have a contextual type, it does not do anything
|
||||
// with this type. It is neither affected by it, nor does it propagate it to its operand.
|
||||
// So the fact that contextualMapper is passed is not important, because the operand of a spread
|
||||
// element is not contextually typed.
|
||||
const arrayOrIterableType = checkExpressionCached(node.expression, contextualMapper);
|
||||
const arrayOrIterableType = checkExpression(node.expression, contextualMapper);
|
||||
return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false);
|
||||
}
|
||||
|
||||
@@ -11539,8 +11640,11 @@ namespace ts {
|
||||
if (propertiesArray.length > 0) {
|
||||
spread = getSpreadType(spread, createObjectLiteralType(), /*isFromObjectLiteral*/ true);
|
||||
}
|
||||
spread.flags |= propagatedFlags;
|
||||
spread.symbol = node.symbol;
|
||||
if (spread.flags & TypeFlags.Object) {
|
||||
// only set the symbol and flags if this is a (fresh) object type
|
||||
spread.flags |= propagatedFlags;
|
||||
spread.symbol = node.symbol;
|
||||
}
|
||||
return spread;
|
||||
}
|
||||
|
||||
@@ -13466,13 +13570,14 @@ namespace ts {
|
||||
const containingClass = getContainingClass(node);
|
||||
if (containingClass) {
|
||||
const containingType = getTypeOfNode(containingClass);
|
||||
const baseTypes = getBaseTypes(<InterfaceType>containingType);
|
||||
if (baseTypes.length) {
|
||||
let baseTypes = getBaseTypes(containingType as InterfaceType);
|
||||
while (baseTypes.length) {
|
||||
const baseType = baseTypes[0];
|
||||
if (modifiers & ModifierFlags.Protected &&
|
||||
baseType.symbol === declaration.parent.symbol) {
|
||||
return true;
|
||||
}
|
||||
baseTypes = getBaseTypes(baseType as InterfaceType);
|
||||
}
|
||||
}
|
||||
if (modifiers & ModifierFlags.Private) {
|
||||
@@ -14980,8 +15085,8 @@ namespace ts {
|
||||
|
||||
function isLiteralContextualType(contextualType: Type) {
|
||||
if (contextualType) {
|
||||
if (contextualType.flags & TypeFlags.TypeParameter) {
|
||||
const apparentType = getApparentTypeOfTypeParameter(<TypeParameter>contextualType);
|
||||
if (contextualType.flags & TypeFlags.TypeVariable) {
|
||||
const apparentType = getApparentTypeOfTypeVariable(<TypeVariable>contextualType);
|
||||
// If the type parameter is constrained to the base primitive type we're checking for,
|
||||
// consider this a literal context. For example, given a type parameter 'T extends string',
|
||||
// this causes us to infer string literal types for T.
|
||||
@@ -15816,7 +15921,7 @@ namespace ts {
|
||||
checkSourceElement(node.type);
|
||||
const type = <MappedType>getTypeFromMappedTypeNode(node);
|
||||
const constraintType = getConstraintTypeFromMappedType(type);
|
||||
const keyType = constraintType.flags & TypeFlags.TypeParameter ? getApparentTypeOfTypeParameter(<TypeParameter>constraintType) : constraintType;
|
||||
const keyType = constraintType.flags & TypeFlags.TypeVariable ? getApparentTypeOfTypeVariable(<TypeVariable>constraintType) : constraintType;
|
||||
checkTypeAssignableTo(keyType, stringType, node.typeParameter.constraint);
|
||||
}
|
||||
|
||||
@@ -16198,7 +16303,7 @@ namespace ts {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const onfulfilledParameterType = getTypeWithFacts(getUnionType(map(thenSignatures, getTypeOfFirstParameterOfSignature)), TypeFacts.NEUndefined);
|
||||
const onfulfilledParameterType = getTypeWithFacts(getUnionType(map(thenSignatures, getTypeOfFirstParameterOfSignature)), TypeFacts.NEUndefinedOrNull);
|
||||
if (isTypeAny(onfulfilledParameterType)) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -16481,6 +16586,10 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function getParameterTypeNodeForDecoratorCheck(node: ParameterDeclaration): TypeNode {
|
||||
return node.dotDotDotToken ? getRestParameterElementType(node.type) : node.type;
|
||||
}
|
||||
|
||||
/** Check the decorators of a node */
|
||||
function checkDecorators(node: Node): void {
|
||||
if (!node.decorators) {
|
||||
@@ -16512,7 +16621,7 @@ namespace ts {
|
||||
const constructor = getFirstConstructorWithBody(<ClassDeclaration>node);
|
||||
if (constructor) {
|
||||
for (const parameter of constructor.parameters) {
|
||||
markTypeNodeAsReferenced(parameter.type);
|
||||
markTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter));
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -16521,15 +16630,17 @@ namespace ts {
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
for (const parameter of (<FunctionLikeDeclaration>node).parameters) {
|
||||
markTypeNodeAsReferenced(parameter.type);
|
||||
markTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter));
|
||||
}
|
||||
|
||||
markTypeNodeAsReferenced((<FunctionLikeDeclaration>node).type);
|
||||
break;
|
||||
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
markTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(<ParameterDeclaration>node));
|
||||
break;
|
||||
case SyntaxKind.Parameter:
|
||||
markTypeNodeAsReferenced((<PropertyDeclaration | ParameterDeclaration>node).type);
|
||||
markTypeNodeAsReferenced((<PropertyDeclaration>node).type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -16692,6 +16803,14 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function isRemovedPropertyFromObjectSpread(node: Node) {
|
||||
if (isBindingElement(node) && isObjectBindingPattern(node.parent)) {
|
||||
const lastElement = lastOrUndefined(node.parent.elements);
|
||||
return lastElement !== node && !!lastElement.dotDotDotToken;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function errorUnusedLocal(node: Node, name: string) {
|
||||
if (isIdentifierThatStartsWithUnderScore(node)) {
|
||||
const declaration = getRootDeclaration(node.parent);
|
||||
@@ -16701,7 +16820,10 @@ namespace ts {
|
||||
return;
|
||||
}
|
||||
}
|
||||
error(node, Diagnostics._0_is_declared_but_never_used, name);
|
||||
|
||||
if (!isRemovedPropertyFromObjectSpread(node.kind === SyntaxKind.Identifier ? node.parent : node)) {
|
||||
error(node, Diagnostics._0_is_declared_but_never_used, name);
|
||||
}
|
||||
}
|
||||
|
||||
function parameterNameStartsWithUnderscore(parameterName: DeclarationName) {
|
||||
@@ -17989,7 +18111,7 @@ namespace ts {
|
||||
|
||||
const baseTypeNode = getClassExtendsHeritageClauseElement(node);
|
||||
if (baseTypeNode) {
|
||||
if (languageVersion < ScriptTarget.ES2015) {
|
||||
if (languageVersion < ScriptTarget.ES2015 && !isInAmbientContext(node)) {
|
||||
checkExternalEmitHelpers(baseTypeNode.parent, ExternalEmitHelpers.Extends);
|
||||
}
|
||||
|
||||
|
||||
@@ -549,14 +549,7 @@ namespace ts {
|
||||
|
||||
/* @internal */
|
||||
export function parseCustomTypeOption(opt: CommandLineOptionOfCustomType, value: string, errors: Diagnostic[]) {
|
||||
const key = trimString((value || "")).toLowerCase();
|
||||
const map = opt.type;
|
||||
if (key in map) {
|
||||
return map[key];
|
||||
}
|
||||
else {
|
||||
errors.push(createCompilerDiagnosticForInvalidCustomType(opt));
|
||||
}
|
||||
return convertJsonOptionOfCustomType(opt, trimString(value || ""), errors);
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
@@ -848,7 +841,7 @@ namespace ts {
|
||||
* @param basePath A root directory to resolve relative path entries in the config
|
||||
* file to. e.g. outDir
|
||||
*/
|
||||
export function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions: CompilerOptions = {}, configFileName?: string, resolutionStack: Path[] = []): ParsedCommandLine {
|
||||
export function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions: CompilerOptions = {}, configFileName?: string, resolutionStack: Path[] = [], extraFileExtensions: FileExtensionInfo[] = []): ParsedCommandLine {
|
||||
const errors: Diagnostic[] = [];
|
||||
const getCanonicalFileName = createGetCanonicalFileName(host.useCaseSensitiveFileNames);
|
||||
const resolvedPath = toPath(configFileName || "", basePath, getCanonicalFileName);
|
||||
@@ -988,7 +981,7 @@ namespace ts {
|
||||
includeSpecs = ["**/*"];
|
||||
}
|
||||
|
||||
const result = matchFileNames(fileNames, includeSpecs, excludeSpecs, basePath, options, host, errors);
|
||||
const result = matchFileNames(fileNames, includeSpecs, excludeSpecs, basePath, options, host, errors, extraFileExtensions);
|
||||
|
||||
if (result.fileNames.length === 0 && !hasProperty(json, "files") && resolutionStack.length === 0) {
|
||||
errors.push(
|
||||
@@ -1192,7 +1185,7 @@ namespace ts {
|
||||
* @param host The host used to resolve files and directories.
|
||||
* @param errors An array for diagnostic reporting.
|
||||
*/
|
||||
function matchFileNames(fileNames: string[], include: string[], exclude: string[], basePath: string, options: CompilerOptions, host: ParseConfigHost, errors: Diagnostic[]): ExpandResult {
|
||||
function matchFileNames(fileNames: string[], include: string[], exclude: string[], basePath: string, options: CompilerOptions, host: ParseConfigHost, errors: Diagnostic[], extraFileExtensions: FileExtensionInfo[]): ExpandResult {
|
||||
basePath = normalizePath(basePath);
|
||||
|
||||
// The exclude spec list is converted into a regular expression, which allows us to quickly
|
||||
@@ -1226,7 +1219,7 @@ namespace ts {
|
||||
|
||||
// Rather than requery this for each file and filespec, we query the supported extensions
|
||||
// once and store it on the expansion context.
|
||||
const supportedExtensions = getSupportedExtensions(options);
|
||||
const supportedExtensions = getSupportedExtensions(options, extraFileExtensions);
|
||||
|
||||
// Literal files are always included verbatim. An "include" or "exclude" specification cannot
|
||||
// remove a literal file.
|
||||
|
||||
@@ -156,6 +156,9 @@ namespace ts {
|
||||
|
||||
if (!skipTrailingComments) {
|
||||
emitLeadingComments(detachedRange.end, /*isEmittedNode*/ true);
|
||||
if (hasWrittenComment && !writer.isAtStartOfLine()) {
|
||||
writer.writeLine();
|
||||
}
|
||||
}
|
||||
|
||||
if (extendedDiagnostics) {
|
||||
|
||||
+14
-22
@@ -863,24 +863,6 @@ namespace ts {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reduce the properties defined on a map-like (but not from its prototype chain).
|
||||
*
|
||||
* NOTE: This is intended for use with MapLike<T> objects. For Map<T> objects, use
|
||||
* reduceProperties instead as it offers better performance.
|
||||
*
|
||||
* @param map The map-like to reduce
|
||||
* @param callback An aggregation function that is called for each entry in the map
|
||||
* @param initial The initial value for the reduction.
|
||||
*/
|
||||
export function reduceOwnProperties<T, U>(map: MapLike<T>, callback: (aggregate: U, value: T, key: string) => U, initial: U): U {
|
||||
let result = initial;
|
||||
for (const key in map) if (hasOwnProperty.call(map, key)) {
|
||||
result = callback(result, map[key], String(key));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a shallow equality comparison of the contents of two map-likes.
|
||||
*
|
||||
@@ -1942,8 +1924,18 @@ namespace ts {
|
||||
export const supportedJavascriptExtensions = [".js", ".jsx"];
|
||||
const allSupportedExtensions = supportedTypeScriptExtensions.concat(supportedJavascriptExtensions);
|
||||
|
||||
export function getSupportedExtensions(options?: CompilerOptions): string[] {
|
||||
return options && options.allowJs ? allSupportedExtensions : supportedTypeScriptExtensions;
|
||||
export function getSupportedExtensions(options?: CompilerOptions, extraFileExtensions?: FileExtensionInfo[]): string[] {
|
||||
const needAllExtensions = options && options.allowJs;
|
||||
if (!extraFileExtensions || extraFileExtensions.length === 0) {
|
||||
return needAllExtensions ? allSupportedExtensions : supportedTypeScriptExtensions;
|
||||
}
|
||||
const extensions = (needAllExtensions ? allSupportedExtensions : supportedTypeScriptExtensions).slice(0);
|
||||
for (const extInfo of extraFileExtensions) {
|
||||
if (needAllExtensions || extInfo.scriptKind === ScriptKind.TS) {
|
||||
extensions.push(extInfo.extension);
|
||||
}
|
||||
}
|
||||
return extensions;
|
||||
}
|
||||
|
||||
export function hasJavaScriptFileExtension(fileName: string) {
|
||||
@@ -1954,10 +1946,10 @@ namespace ts {
|
||||
return forEach(supportedTypeScriptExtensions, extension => fileExtensionIs(fileName, extension));
|
||||
}
|
||||
|
||||
export function isSupportedSourceFileName(fileName: string, compilerOptions?: CompilerOptions) {
|
||||
export function isSupportedSourceFileName(fileName: string, compilerOptions?: CompilerOptions, extraFileExtensions?: FileExtensionInfo[]) {
|
||||
if (!fileName) { return false; }
|
||||
|
||||
for (const extension of getSupportedExtensions(compilerOptions)) {
|
||||
for (const extension of getSupportedExtensions(compilerOptions, extraFileExtensions)) {
|
||||
if (fileExtensionIs(fileName, extension)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -194,6 +194,7 @@ namespace ts {
|
||||
writer.writeSpace = writer.write;
|
||||
writer.writeStringLiteral = writer.writeLiteral;
|
||||
writer.writeParameter = writer.write;
|
||||
writer.writeProperty = writer.write;
|
||||
writer.writeSymbol = writer.write;
|
||||
setWriter(writer);
|
||||
}
|
||||
|
||||
@@ -3165,6 +3165,10 @@
|
||||
"category": "Error",
|
||||
"code": 17010
|
||||
},
|
||||
"'super' must be called before accessing a property of 'super' in the constructor of a derived class.": {
|
||||
"category": "Error",
|
||||
"code": 17011
|
||||
},
|
||||
|
||||
"Circularity detected while resolving configuration: {0}": {
|
||||
"category": "Error",
|
||||
|
||||
@@ -6337,7 +6337,7 @@ namespace ts {
|
||||
break;
|
||||
case SyntaxKind.AsteriskToken:
|
||||
const asterisk = scanner.getTokenText();
|
||||
if (state === JSDocState.SawAsterisk) {
|
||||
if (state === JSDocState.SawAsterisk || state === JSDocState.SavingComments) {
|
||||
// If we've already seen an asterisk, then we can no longer parse a tag on this line
|
||||
state = JSDocState.SavingComments;
|
||||
pushComment(asterisk);
|
||||
@@ -6358,7 +6358,10 @@ namespace ts {
|
||||
case SyntaxKind.WhitespaceTrivia:
|
||||
// only collect whitespace if we're already saving comments or have just crossed the comment indent margin
|
||||
const whitespace = scanner.getTokenText();
|
||||
if (state === JSDocState.SavingComments || margin !== undefined && indent + whitespace.length > margin) {
|
||||
if (state === JSDocState.SavingComments) {
|
||||
comments.push(whitespace);
|
||||
}
|
||||
else if (margin !== undefined && indent + whitespace.length > margin) {
|
||||
comments.push(whitespace.slice(margin - indent - 1));
|
||||
}
|
||||
indent += whitespace.length;
|
||||
@@ -6366,6 +6369,8 @@ namespace ts {
|
||||
case SyntaxKind.EndOfFileToken:
|
||||
break;
|
||||
default:
|
||||
// anything other than whitespace or asterisk at the beginning of the line starts the comment text
|
||||
state = JSDocState.SavingComments;
|
||||
pushComment(scanner.getTokenText());
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -427,7 +427,7 @@ namespace ts {
|
||||
|
||||
encodeLastRecordedSourceMapSpan();
|
||||
|
||||
return stringify({
|
||||
return JSON.stringify({
|
||||
version: 3,
|
||||
file: sourceMapData.sourceMapFile,
|
||||
sourceRoot: sourceMapData.sourceMapSourceRoot,
|
||||
|
||||
@@ -2286,14 +2286,19 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
startLexicalEnvironment();
|
||||
let loopBody = visitNode(node.statement, visitor, isStatement);
|
||||
const lexicalEnvironment = endLexicalEnvironment();
|
||||
|
||||
const currentState = convertedLoopState;
|
||||
convertedLoopState = outerConvertedLoopState;
|
||||
|
||||
if (loopOutParameters.length) {
|
||||
if (loopOutParameters.length || lexicalEnvironment) {
|
||||
const statements = isBlock(loopBody) ? (<Block>loopBody).statements.slice() : [loopBody];
|
||||
copyOutParameters(loopOutParameters, CopyDirection.ToOutParameter, statements);
|
||||
if (loopOutParameters.length) {
|
||||
copyOutParameters(loopOutParameters, CopyDirection.ToOutParameter, statements);
|
||||
}
|
||||
addRange(statements, lexicalEnvironment)
|
||||
loopBody = createBlock(statements, /*location*/ undefined, /*multiline*/ true);
|
||||
}
|
||||
|
||||
@@ -2837,7 +2842,6 @@ namespace ts {
|
||||
// _super.call(this, a)
|
||||
// _super.m.call(this, a)
|
||||
// _super.prototype.m.call(this, a)
|
||||
|
||||
resultingCall = createFunctionCall(
|
||||
visitNode(target, visitor, isExpression),
|
||||
visitNode(thisArg, visitor, isExpression),
|
||||
|
||||
@@ -101,20 +101,21 @@ namespace ts {
|
||||
// So the helper will be emit at the correct position instead of at the top of the source-file
|
||||
const moduleName = tryGetModuleNameFromFile(node, host, compilerOptions);
|
||||
const dependencies = createArrayLiteral(map(dependencyGroups, dependencyGroup => dependencyGroup.name));
|
||||
const updated = updateSourceFileNode(
|
||||
node,
|
||||
createNodeArray([
|
||||
createStatement(
|
||||
createCall(
|
||||
createPropertyAccess(createIdentifier("System"), "register"),
|
||||
const updated = setEmitFlags(
|
||||
updateSourceFileNode(
|
||||
node,
|
||||
createNodeArray([
|
||||
createStatement(
|
||||
createCall(
|
||||
createPropertyAccess(createIdentifier("System"), "register"),
|
||||
/*typeArguments*/ undefined,
|
||||
moduleName
|
||||
? [moduleName, dependencies, moduleBodyFunction]
|
||||
: [dependencies, moduleBodyFunction]
|
||||
moduleName
|
||||
? [moduleName, dependencies, moduleBodyFunction]
|
||||
: [dependencies, moduleBodyFunction]
|
||||
)
|
||||
)
|
||||
)
|
||||
], node.statements)
|
||||
);
|
||||
], node.statements)
|
||||
), EmitFlags.NoTrailingComments);
|
||||
|
||||
if (!(compilerOptions.outFile || compilerOptions.out)) {
|
||||
moveEmitHelpers(updated, moduleBodyBlock, helper => !helper.scoped);
|
||||
|
||||
@@ -1223,11 +1223,12 @@ namespace ts {
|
||||
}
|
||||
|
||||
const { firstAccessor, secondAccessor, setAccessor } = getAllAccessorDeclarations(node.members, accessor);
|
||||
if (accessor !== firstAccessor) {
|
||||
const firstAccessorWithDecorators = firstAccessor.decorators ? firstAccessor : secondAccessor && secondAccessor.decorators ? secondAccessor : undefined;
|
||||
if (!firstAccessorWithDecorators || accessor !== firstAccessorWithDecorators) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const decorators = firstAccessor.decorators || (secondAccessor && secondAccessor.decorators);
|
||||
const decorators = firstAccessorWithDecorators.decorators;
|
||||
const parameters = getDecoratorsOfParameters(setAccessor);
|
||||
if (!decorators && !parameters) {
|
||||
return undefined;
|
||||
@@ -1276,7 +1277,7 @@ namespace ts {
|
||||
* @param node The declaration node.
|
||||
* @param allDecorators An object containing all of the decorators for the declaration.
|
||||
*/
|
||||
function transformAllDecoratorsOfDeclaration(node: Declaration, allDecorators: AllDecorators) {
|
||||
function transformAllDecoratorsOfDeclaration(node: Declaration, container: ClassLikeDeclaration, allDecorators: AllDecorators) {
|
||||
if (!allDecorators) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -1284,7 +1285,7 @@ namespace ts {
|
||||
const decoratorExpressions: Expression[] = [];
|
||||
addRange(decoratorExpressions, map(allDecorators.decorators, transformDecorator));
|
||||
addRange(decoratorExpressions, flatMap(allDecorators.parameters, transformDecoratorsOfParameter));
|
||||
addTypeMetadata(node, decoratorExpressions);
|
||||
addTypeMetadata(node, container, decoratorExpressions);
|
||||
return decoratorExpressions;
|
||||
}
|
||||
|
||||
@@ -1333,7 +1334,7 @@ namespace ts {
|
||||
*/
|
||||
function generateClassElementDecorationExpression(node: ClassExpression | ClassDeclaration, member: ClassElement) {
|
||||
const allDecorators = getAllDecoratorsOfClassElement(node, member);
|
||||
const decoratorExpressions = transformAllDecoratorsOfDeclaration(member, allDecorators);
|
||||
const decoratorExpressions = transformAllDecoratorsOfDeclaration(member, node, allDecorators);
|
||||
if (!decoratorExpressions) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -1414,7 +1415,7 @@ namespace ts {
|
||||
*/
|
||||
function generateConstructorDecorationExpression(node: ClassExpression | ClassDeclaration) {
|
||||
const allDecorators = getAllDecoratorsOfConstructor(node);
|
||||
const decoratorExpressions = transformAllDecoratorsOfDeclaration(node, allDecorators);
|
||||
const decoratorExpressions = transformAllDecoratorsOfDeclaration(node, node, allDecorators);
|
||||
if (!decoratorExpressions) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -1467,22 +1468,22 @@ namespace ts {
|
||||
* @param node The declaration node.
|
||||
* @param decoratorExpressions The destination array to which to add new decorator expressions.
|
||||
*/
|
||||
function addTypeMetadata(node: Declaration, decoratorExpressions: Expression[]) {
|
||||
function addTypeMetadata(node: Declaration, container: ClassLikeDeclaration, decoratorExpressions: Expression[]) {
|
||||
if (USE_NEW_TYPE_METADATA_FORMAT) {
|
||||
addNewTypeMetadata(node, decoratorExpressions);
|
||||
addNewTypeMetadata(node, container, decoratorExpressions);
|
||||
}
|
||||
else {
|
||||
addOldTypeMetadata(node, decoratorExpressions);
|
||||
addOldTypeMetadata(node, container, decoratorExpressions);
|
||||
}
|
||||
}
|
||||
|
||||
function addOldTypeMetadata(node: Declaration, decoratorExpressions: Expression[]) {
|
||||
function addOldTypeMetadata(node: Declaration, container: ClassLikeDeclaration, decoratorExpressions: Expression[]) {
|
||||
if (compilerOptions.emitDecoratorMetadata) {
|
||||
if (shouldAddTypeMetadata(node)) {
|
||||
decoratorExpressions.push(createMetadataHelper(context, "design:type", serializeTypeOfNode(node)));
|
||||
}
|
||||
if (shouldAddParamTypesMetadata(node)) {
|
||||
decoratorExpressions.push(createMetadataHelper(context, "design:paramtypes", serializeParameterTypesOfNode(node)));
|
||||
decoratorExpressions.push(createMetadataHelper(context, "design:paramtypes", serializeParameterTypesOfNode(node, container)));
|
||||
}
|
||||
if (shouldAddReturnTypeMetadata(node)) {
|
||||
decoratorExpressions.push(createMetadataHelper(context, "design:returntype", serializeReturnTypeOfNode(node)));
|
||||
@@ -1490,14 +1491,14 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function addNewTypeMetadata(node: Declaration, decoratorExpressions: Expression[]) {
|
||||
function addNewTypeMetadata(node: Declaration, container: ClassLikeDeclaration, decoratorExpressions: Expression[]) {
|
||||
if (compilerOptions.emitDecoratorMetadata) {
|
||||
let properties: ObjectLiteralElementLike[];
|
||||
if (shouldAddTypeMetadata(node)) {
|
||||
(properties || (properties = [])).push(createPropertyAssignment("type", createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, createToken(SyntaxKind.EqualsGreaterThanToken), serializeTypeOfNode(node))));
|
||||
}
|
||||
if (shouldAddParamTypesMetadata(node)) {
|
||||
(properties || (properties = [])).push(createPropertyAssignment("paramTypes", createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, createToken(SyntaxKind.EqualsGreaterThanToken), serializeParameterTypesOfNode(node))));
|
||||
(properties || (properties = [])).push(createPropertyAssignment("paramTypes", createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, createToken(SyntaxKind.EqualsGreaterThanToken), serializeParameterTypesOfNode(node, container))));
|
||||
}
|
||||
if (shouldAddReturnTypeMetadata(node)) {
|
||||
(properties || (properties = [])).push(createPropertyAssignment("returnType", createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, createToken(SyntaxKind.EqualsGreaterThanToken), serializeReturnTypeOfNode(node))));
|
||||
@@ -1542,12 +1543,16 @@ namespace ts {
|
||||
* @param node The node to test.
|
||||
*/
|
||||
function shouldAddParamTypesMetadata(node: Declaration): boolean {
|
||||
const kind = node.kind;
|
||||
return kind === SyntaxKind.ClassDeclaration
|
||||
|| kind === SyntaxKind.ClassExpression
|
||||
|| kind === SyntaxKind.MethodDeclaration
|
||||
|| kind === SyntaxKind.GetAccessor
|
||||
|| kind === SyntaxKind.SetAccessor;
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
case SyntaxKind.ClassExpression:
|
||||
return getFirstConstructorWithBody(<ClassLikeDeclaration>node) !== undefined;
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1572,30 +1577,12 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the most likely element type for a TypeNode. This is not an exhaustive test
|
||||
* as it assumes a rest argument can only be an array type (either T[], or Array<T>).
|
||||
*
|
||||
* @param node The type node.
|
||||
*/
|
||||
function getRestParameterElementType(node: TypeNode) {
|
||||
if (node && node.kind === SyntaxKind.ArrayType) {
|
||||
return (<ArrayTypeNode>node).elementType;
|
||||
}
|
||||
else if (node && node.kind === SyntaxKind.TypeReference) {
|
||||
return singleOrUndefined((<TypeReferenceNode>node).typeArguments);
|
||||
}
|
||||
else {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes the types of the parameters of a node for use with decorator type metadata.
|
||||
*
|
||||
* @param node The node that should have its parameter types serialized.
|
||||
*/
|
||||
function serializeParameterTypesOfNode(node: Node): Expression {
|
||||
function serializeParameterTypesOfNode(node: Node, container: ClassLikeDeclaration): Expression {
|
||||
const valueDeclaration =
|
||||
isClassLike(node)
|
||||
? getFirstConstructorWithBody(node)
|
||||
@@ -1605,7 +1592,7 @@ namespace ts {
|
||||
|
||||
const expressions: Expression[] = [];
|
||||
if (valueDeclaration) {
|
||||
const parameters = valueDeclaration.parameters;
|
||||
const parameters = getParametersOfDecoratedDeclaration(valueDeclaration, container);
|
||||
const numParameters = parameters.length;
|
||||
for (let i = 0; i < numParameters; i++) {
|
||||
const parameter = parameters[i];
|
||||
@@ -1624,6 +1611,16 @@ namespace ts {
|
||||
return createArrayLiteral(expressions);
|
||||
}
|
||||
|
||||
function getParametersOfDecoratedDeclaration(node: FunctionLikeDeclaration, container: ClassLikeDeclaration) {
|
||||
if (container && node.kind === SyntaxKind.GetAccessor) {
|
||||
const { setAccessor } = getAllAccessorDeclarations(container.members, <AccessorDeclaration>node);
|
||||
if (setAccessor) {
|
||||
return setAccessor.parameters;
|
||||
}
|
||||
}
|
||||
return node.parameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes the return type of a node for use with decorator type metadata.
|
||||
*
|
||||
|
||||
@@ -11,7 +11,8 @@
|
||||
"stripInternal": true,
|
||||
"target": "es5",
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true
|
||||
"noUnusedParameters": true,
|
||||
"types": [ ]
|
||||
},
|
||||
"files": [
|
||||
"core.ts",
|
||||
|
||||
+14
-3
@@ -2407,6 +2407,7 @@ namespace ts {
|
||||
writeSpace(text: string): void;
|
||||
writeStringLiteral(text: string): void;
|
||||
writeParameter(text: string): void;
|
||||
writeProperty(text: string): void;
|
||||
writeSymbol(text: string, symbol: Symbol): void;
|
||||
writeLine(): void;
|
||||
increaseIndent(): void;
|
||||
@@ -2908,6 +2909,8 @@ namespace ts {
|
||||
/* @internal */
|
||||
resolvedProperties: SymbolTable; // Cache of resolved properties
|
||||
/* @internal */
|
||||
resolvedIndexType: IndexType;
|
||||
/* @internal */
|
||||
couldContainTypeVariables: boolean;
|
||||
}
|
||||
|
||||
@@ -2930,6 +2933,7 @@ namespace ts {
|
||||
typeParameter?: TypeParameter;
|
||||
constraintType?: Type;
|
||||
templateType?: Type;
|
||||
modifiersType?: Type;
|
||||
mapper?: TypeMapper; // Instantiation mapper
|
||||
}
|
||||
|
||||
@@ -2965,6 +2969,8 @@ namespace ts {
|
||||
}
|
||||
|
||||
export interface TypeVariable extends Type {
|
||||
/* @internal */
|
||||
resolvedApparentType: Type;
|
||||
/* @internal */
|
||||
resolvedIndexType: IndexType;
|
||||
}
|
||||
@@ -2977,8 +2983,6 @@ namespace ts {
|
||||
/* @internal */
|
||||
mapper?: TypeMapper; // Instantiation mapper
|
||||
/* @internal */
|
||||
resolvedApparentType: Type;
|
||||
/* @internal */
|
||||
isThisType?: boolean;
|
||||
}
|
||||
|
||||
@@ -2987,11 +2991,12 @@ namespace ts {
|
||||
export interface IndexedAccessType extends TypeVariable {
|
||||
objectType: Type;
|
||||
indexType: Type;
|
||||
constraint?: Type;
|
||||
}
|
||||
|
||||
// keyof T types (TypeFlags.Index)
|
||||
export interface IndexType extends Type {
|
||||
type: TypeVariable;
|
||||
type: TypeVariable | UnionOrIntersectionType;
|
||||
}
|
||||
|
||||
export const enum SignatureKind {
|
||||
@@ -3083,6 +3088,12 @@ namespace ts {
|
||||
ThisProperty
|
||||
}
|
||||
|
||||
export interface FileExtensionInfo {
|
||||
extension: string;
|
||||
scriptKind: ScriptKind;
|
||||
isMixedContent: boolean;
|
||||
}
|
||||
|
||||
export interface DiagnosticMessage {
|
||||
key: string;
|
||||
category: DiagnosticCategory;
|
||||
|
||||
+18
-49
@@ -43,6 +43,7 @@ namespace ts {
|
||||
writeSpace: writeText,
|
||||
writeStringLiteral: writeText,
|
||||
writeParameter: writeText,
|
||||
writeProperty: writeText,
|
||||
writeSymbol: writeText,
|
||||
|
||||
// Completely ignore indentation for string writers. And map newlines to
|
||||
@@ -802,6 +803,23 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the most likely element type for a TypeNode. This is not an exhaustive test
|
||||
* as it assumes a rest argument can only be an array type (either T[], or Array<T>).
|
||||
*
|
||||
* @param node The type node.
|
||||
*/
|
||||
export function getRestParameterElementType(node: TypeNode) {
|
||||
if (node && node.kind === SyntaxKind.ArrayType) {
|
||||
return (<ArrayTypeNode>node).elementType;
|
||||
}
|
||||
else if (node && node.kind === SyntaxKind.TypeReference) {
|
||||
return singleOrUndefined((<TypeReferenceNode>node).typeArguments);
|
||||
}
|
||||
else {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
export function isVariableLike(node: Node): node is VariableLikeDeclaration {
|
||||
if (node) {
|
||||
@@ -3188,55 +3206,6 @@ namespace ts {
|
||||
return output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize an object graph into a JSON string. This is intended only for use on an acyclic graph
|
||||
* as the fallback implementation does not check for circular references by default.
|
||||
*/
|
||||
export const stringify: (value: any) => string = typeof JSON !== "undefined" && JSON.stringify
|
||||
? JSON.stringify
|
||||
: stringifyFallback;
|
||||
|
||||
/**
|
||||
* Serialize an object graph into a JSON string.
|
||||
*/
|
||||
function stringifyFallback(value: any): string {
|
||||
// JSON.stringify returns `undefined` here, instead of the string "undefined".
|
||||
return value === undefined ? undefined : stringifyValue(value);
|
||||
}
|
||||
|
||||
function stringifyValue(value: any): string {
|
||||
return typeof value === "string" ? `"${escapeString(value)}"`
|
||||
: typeof value === "number" ? isFinite(value) ? String(value) : "null"
|
||||
: typeof value === "boolean" ? value ? "true" : "false"
|
||||
: typeof value === "object" && value ? isArray(value) ? cycleCheck(stringifyArray, value) : cycleCheck(stringifyObject, value)
|
||||
: /*fallback*/ "null";
|
||||
}
|
||||
|
||||
function cycleCheck(cb: (value: any) => string, value: any) {
|
||||
Debug.assert(!value.hasOwnProperty("__cycle"), "Converting circular structure to JSON");
|
||||
value.__cycle = true;
|
||||
const result = cb(value);
|
||||
delete value.__cycle;
|
||||
return result;
|
||||
}
|
||||
|
||||
function stringifyArray(value: any) {
|
||||
return `[${reduceLeft(value, stringifyElement, "")}]`;
|
||||
}
|
||||
|
||||
function stringifyElement(memo: string, value: any) {
|
||||
return (memo ? memo + "," : memo) + stringifyValue(value);
|
||||
}
|
||||
|
||||
function stringifyObject(value: any) {
|
||||
return `{${reduceOwnProperties(value, stringifyProperty, "")}}`;
|
||||
}
|
||||
|
||||
function stringifyProperty(memo: string, value: any, key: string) {
|
||||
return value === undefined || typeof value === "function" || key === "__cycle" ? memo
|
||||
: (memo ? memo + "," : memo) + `"${escapeString(key)}":${stringifyValue(value)}`;
|
||||
}
|
||||
|
||||
const base64Digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
||||
|
||||
/**
|
||||
|
||||
@@ -607,23 +607,13 @@ namespace FourSlash {
|
||||
});
|
||||
}
|
||||
|
||||
public verifyMemberListContains(symbol: string, text?: string, documentation?: string, kind?: string) {
|
||||
const members = this.getMemberListAtCaret();
|
||||
if (members) {
|
||||
this.assertItemInCompletionList(members.entries, symbol, text, documentation, kind);
|
||||
}
|
||||
else {
|
||||
this.raiseError("Expected a member list, but none was provided");
|
||||
}
|
||||
}
|
||||
|
||||
public verifyMemberListCount(expectedCount: number, negative: boolean) {
|
||||
public verifyCompletionListCount(expectedCount: number, negative: boolean) {
|
||||
if (expectedCount === 0 && negative) {
|
||||
this.verifyMemberListIsEmpty(/*negative*/ false);
|
||||
this.verifyCompletionListIsEmpty(/*negative*/ false);
|
||||
return;
|
||||
}
|
||||
|
||||
const members = this.getMemberListAtCaret();
|
||||
const members = this.getCompletionListAtCaret();
|
||||
|
||||
if (members) {
|
||||
const match = members.entries.length === expectedCount;
|
||||
@@ -637,13 +627,6 @@ namespace FourSlash {
|
||||
}
|
||||
}
|
||||
|
||||
public verifyMemberListDoesNotContain(symbol: string) {
|
||||
const members = this.getMemberListAtCaret();
|
||||
if (members && members.entries.filter(e => e.name === symbol).length !== 0) {
|
||||
this.raiseError(`Member list did contain ${symbol}`);
|
||||
}
|
||||
}
|
||||
|
||||
public verifyCompletionListItemsCountIsGreaterThan(count: number, negative: boolean) {
|
||||
const completions = this.getCompletionListAtCaret();
|
||||
const itemsCount = completions.entries.length;
|
||||
@@ -685,16 +668,6 @@ namespace FourSlash {
|
||||
}
|
||||
}
|
||||
|
||||
public verifyMemberListIsEmpty(negative: boolean) {
|
||||
const members = this.getMemberListAtCaret();
|
||||
if ((!members || members.entries.length === 0) && negative) {
|
||||
this.raiseError("Member list is empty at Caret");
|
||||
}
|
||||
else if ((members && members.entries.length !== 0) && !negative) {
|
||||
this.raiseError(`Member list is not empty at Caret:\nMember List contains: ${stringify(members.entries.map(e => e.name))}`);
|
||||
}
|
||||
}
|
||||
|
||||
public verifyCompletionListIsEmpty(negative: boolean) {
|
||||
const completions = this.getCompletionListAtCaret();
|
||||
if ((!completions || completions.entries.length === 0) && negative) {
|
||||
@@ -892,10 +865,6 @@ namespace FourSlash {
|
||||
this.raiseError(`verifyReferencesAtPositionListContains failed - could not find the item: ${stringify(missingItem)} in the returned list: (${stringify(references)})`);
|
||||
}
|
||||
|
||||
private getMemberListAtCaret() {
|
||||
return this.languageService.getCompletionsAtPosition(this.activeFile.fileName, this.currentCaretPosition);
|
||||
}
|
||||
|
||||
private getCompletionListAtCaret() {
|
||||
return this.languageService.getCompletionsAtPosition(this.activeFile.fileName, this.currentCaretPosition);
|
||||
}
|
||||
@@ -1353,11 +1322,6 @@ namespace FourSlash {
|
||||
Harness.IO.log(stringify(sigHelp));
|
||||
}
|
||||
|
||||
public printMemberListMembers() {
|
||||
const members = this.getMemberListAtCaret();
|
||||
this.printMembersOrCompletions(members);
|
||||
}
|
||||
|
||||
public printCompletionListMembers() {
|
||||
const completions = this.getCompletionListAtCaret();
|
||||
this.printMembersOrCompletions(completions);
|
||||
@@ -3061,19 +3025,8 @@ namespace FourSlashInterface {
|
||||
}
|
||||
}
|
||||
|
||||
// Verifies the member list contains the specified symbol. The
|
||||
// member list is brought up if necessary
|
||||
public memberListContains(symbol: string, text?: string, documentation?: string, kind?: string) {
|
||||
if (this.negative) {
|
||||
this.state.verifyMemberListDoesNotContain(symbol);
|
||||
}
|
||||
else {
|
||||
this.state.verifyMemberListContains(symbol, text, documentation, kind);
|
||||
}
|
||||
}
|
||||
|
||||
public memberListCount(expectedCount: number) {
|
||||
this.state.verifyMemberListCount(expectedCount, this.negative);
|
||||
public completionListCount(expectedCount: number) {
|
||||
this.state.verifyCompletionListCount(expectedCount, this.negative);
|
||||
}
|
||||
|
||||
// Verifies the completion list contains the specified symbol. The
|
||||
@@ -3109,10 +3062,6 @@ namespace FourSlashInterface {
|
||||
this.state.verifyCompletionListAllowsNewIdentifier(this.negative);
|
||||
}
|
||||
|
||||
public memberListIsEmpty() {
|
||||
this.state.verifyMemberListIsEmpty(this.negative);
|
||||
}
|
||||
|
||||
public signatureHelpPresent() {
|
||||
this.state.verifySignatureHelpPresent(!this.negative);
|
||||
}
|
||||
@@ -3514,10 +3463,6 @@ namespace FourSlashInterface {
|
||||
this.state.printCurrentSignatureHelp();
|
||||
}
|
||||
|
||||
public printMemberListMembers() {
|
||||
this.state.printMemberListMembers();
|
||||
}
|
||||
|
||||
public printCompletionListMembers() {
|
||||
this.state.printCompletionListMembers();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
/// <reference path="../harness.ts" />
|
||||
/// <reference path="../../server/scriptVersionCache.ts"/>
|
||||
/// <reference path="./tsserverProjectSystem.ts" />
|
||||
|
||||
namespace ts.textStorage {
|
||||
describe("Text storage", () => {
|
||||
const f = {
|
||||
path: "/a/app.ts",
|
||||
content: `
|
||||
let x = 1;
|
||||
let y = 2;
|
||||
function bar(a: number) {
|
||||
return a + 1;
|
||||
}`
|
||||
};
|
||||
|
||||
it("text based storage should be have exactly the same as script version cache", () => {
|
||||
|
||||
const host = ts.projectSystem.createServerHost([f]);
|
||||
|
||||
const ts1 = new server.TextStorage(host, server.asNormalizedPath(f.path));
|
||||
const ts2 = new server.TextStorage(host, server.asNormalizedPath(f.path));
|
||||
|
||||
ts1.useScriptVersionCache();
|
||||
ts2.useText();
|
||||
|
||||
const lineMap = computeLineStarts(f.content);
|
||||
|
||||
for (let line = 0; line < lineMap.length; line++) {
|
||||
const start = lineMap[line];
|
||||
const end = line === lineMap.length - 1 ? f.path.length : lineMap[line + 1];
|
||||
|
||||
for (let offset = 0; offset < end - start; offset++) {
|
||||
const pos1 = ts1.lineOffsetToPosition(line + 1, offset + 1);
|
||||
const pos2 = ts2.lineOffsetToPosition(line + 1, offset + 1);
|
||||
assert.isTrue(pos1 === pos2, `lineOffsetToPosition ${line + 1}-${offset + 1}: expected ${pos1} to equal ${pos2}`);
|
||||
}
|
||||
|
||||
const {start: start1, length: length1 } = ts1.lineToTextSpan(line);
|
||||
const {start: start2, length: length2 } = ts2.lineToTextSpan(line);
|
||||
assert.isTrue(start1 === start2, `lineToTextSpan ${line}::start:: expected ${start1} to equal ${start2}`);
|
||||
assert.isTrue(length1 === length2, `lineToTextSpan ${line}::length:: expected ${length1} to equal ${length2}`);
|
||||
}
|
||||
|
||||
for (let pos = 0; pos < f.content.length; pos++) {
|
||||
const { line: line1, offset: offset1 } = ts1.positionToLineOffset(pos);
|
||||
const { line: line2, offset: offset2 } = ts2.positionToLineOffset(pos);
|
||||
assert.isTrue(line1 === line2, `positionToLineOffset ${pos}::line:: expected ${line1} to equal ${line2}`);
|
||||
assert.isTrue(offset1 === offset2, `positionToLineOffset ${pos}::offset:: expected ${offset1} to equal ${offset2}`);
|
||||
}
|
||||
});
|
||||
|
||||
it("should switch to script version cache if necessary", () => {
|
||||
const host = ts.projectSystem.createServerHost([f]);
|
||||
const ts1 = new server.TextStorage(host, server.asNormalizedPath(f.path));
|
||||
|
||||
ts1.getSnapshot();
|
||||
assert.isTrue(!ts1.hasScriptVersionCache(), "should not have script version cache - 1");
|
||||
|
||||
ts1.edit(0, 5, " ");
|
||||
assert.isTrue(ts1.hasScriptVersionCache(), "have script version cache - 1");
|
||||
|
||||
ts1.useText();
|
||||
assert.isTrue(!ts1.hasScriptVersionCache(), "should not have script version cache - 2");
|
||||
|
||||
ts1.getLineInfo(0);
|
||||
assert.isTrue(ts1.hasScriptVersionCache(), "have script version cache - 2");
|
||||
})
|
||||
});
|
||||
}
|
||||
@@ -140,7 +140,6 @@ namespace ts.projectSystem {
|
||||
export interface TestServerHostCreationParameters {
|
||||
useCaseSensitiveFileNames?: boolean;
|
||||
executingFilePath?: string;
|
||||
libFile?: FileOrFolder;
|
||||
currentDirectory?: string;
|
||||
}
|
||||
|
||||
@@ -727,6 +726,66 @@ namespace ts.projectSystem {
|
||||
checkNumberOfInferredProjects(projectService, 1);
|
||||
});
|
||||
|
||||
it("remove not-listed external projects", () => {
|
||||
const f1 = {
|
||||
path: "/a/app.ts",
|
||||
content: "let x = 1"
|
||||
};
|
||||
const f2 = {
|
||||
path: "/b/app.ts",
|
||||
content: "let x = 1"
|
||||
};
|
||||
const f3 = {
|
||||
path: "/c/app.ts",
|
||||
content: "let x = 1"
|
||||
};
|
||||
const makeProject = (f: FileOrFolder) => ({ projectFileName: f.path + ".csproj", rootFiles: [toExternalFile(f.path)], options: {} });
|
||||
const p1 = makeProject(f1);
|
||||
const p2 = makeProject(f2);
|
||||
const p3 = makeProject(f3);
|
||||
|
||||
const host = createServerHost([f1, f2, f3]);
|
||||
const session = createSession(host);
|
||||
|
||||
session.executeCommand(<protocol.OpenExternalProjectsRequest>{
|
||||
seq: 1,
|
||||
type: "request",
|
||||
command: "openExternalProjects",
|
||||
arguments: { projects: [p1, p2] }
|
||||
});
|
||||
|
||||
const projectService = session.getProjectService();
|
||||
checkNumberOfProjects(projectService, { externalProjects: 2 });
|
||||
assert.equal(projectService.externalProjects[0].getProjectName(), p1.projectFileName);
|
||||
assert.equal(projectService.externalProjects[1].getProjectName(), p2.projectFileName);
|
||||
|
||||
session.executeCommand(<protocol.OpenExternalProjectsRequest>{
|
||||
seq: 2,
|
||||
type: "request",
|
||||
command: "openExternalProjects",
|
||||
arguments: { projects: [p1, p3] }
|
||||
});
|
||||
checkNumberOfProjects(projectService, { externalProjects: 2 });
|
||||
assert.equal(projectService.externalProjects[0].getProjectName(), p1.projectFileName);
|
||||
assert.equal(projectService.externalProjects[1].getProjectName(), p3.projectFileName);
|
||||
|
||||
session.executeCommand(<protocol.OpenExternalProjectsRequest>{
|
||||
seq: 3,
|
||||
type: "request",
|
||||
command: "openExternalProjects",
|
||||
arguments: { projects: [] }
|
||||
});
|
||||
checkNumberOfProjects(projectService, { externalProjects: 0 });
|
||||
|
||||
session.executeCommand(<protocol.OpenExternalProjectsRequest>{
|
||||
seq: 3,
|
||||
type: "request",
|
||||
command: "openExternalProjects",
|
||||
arguments: { projects: [p2] }
|
||||
});
|
||||
assert.equal(projectService.externalProjects[0].getProjectName(), p2.projectFileName);
|
||||
});
|
||||
|
||||
it("handle recreated files correctly", () => {
|
||||
const configFile: FileOrFolder = {
|
||||
path: "/a/b/tsconfig.json",
|
||||
@@ -1085,6 +1144,69 @@ namespace ts.projectSystem {
|
||||
checkNumberOfProjects(projectService, {});
|
||||
});
|
||||
|
||||
it("reload regular file after closing", () => {
|
||||
const f1 = {
|
||||
path: "/a/b/app.ts",
|
||||
content: "x."
|
||||
};
|
||||
const f2 = {
|
||||
path: "/a/b/lib.ts",
|
||||
content: "let x: number;"
|
||||
};
|
||||
|
||||
const host = createServerHost([f1, f2, libFile]);
|
||||
const service = createProjectService(host);
|
||||
service.openExternalProject({ projectFileName: "/a/b/project", rootFiles: toExternalFiles([f1.path, f2.path]), options: {} })
|
||||
|
||||
service.openClientFile(f1.path);
|
||||
service.openClientFile(f2.path, "let x: string");
|
||||
|
||||
service.checkNumberOfProjects({ externalProjects: 1 });
|
||||
checkProjectActualFiles(service.externalProjects[0], [f1.path, f2.path, libFile.path]);
|
||||
|
||||
const completions1 = service.externalProjects[0].getLanguageService().getCompletionsAtPosition(f1.path, 2);
|
||||
// should contain completions for string
|
||||
assert.isTrue(completions1.entries.some(e => e.name === "charAt"), "should contain 'charAt'");
|
||||
assert.isFalse(completions1.entries.some(e => e.name === "toExponential"), "should not contain 'toExponential'");
|
||||
|
||||
service.closeClientFile(f2.path);
|
||||
const completions2 = service.externalProjects[0].getLanguageService().getCompletionsAtPosition(f1.path, 2);
|
||||
// should contain completions for string
|
||||
assert.isFalse(completions2.entries.some(e => e.name === "charAt"), "should not contain 'charAt'");
|
||||
assert.isTrue(completions2.entries.some(e => e.name === "toExponential"), "should contain 'toExponential'");
|
||||
});
|
||||
|
||||
it("clear mixed content file after closing", () => {
|
||||
const f1 = {
|
||||
path: "/a/b/app.ts",
|
||||
content: " "
|
||||
};
|
||||
const f2 = {
|
||||
path: "/a/b/lib.html",
|
||||
content: "<html/>"
|
||||
};
|
||||
|
||||
const host = createServerHost([f1, f2, libFile]);
|
||||
const service = createProjectService(host);
|
||||
service.openExternalProject({ projectFileName: "/a/b/project", rootFiles: [{ fileName: f1.path }, { fileName: f2.path, hasMixedContent: true }], options: {} })
|
||||
|
||||
service.openClientFile(f1.path);
|
||||
service.openClientFile(f2.path, "let somelongname: string");
|
||||
|
||||
service.checkNumberOfProjects({ externalProjects: 1 });
|
||||
checkProjectActualFiles(service.externalProjects[0], [f1.path, f2.path, libFile.path]);
|
||||
|
||||
const completions1 = service.externalProjects[0].getLanguageService().getCompletionsAtPosition(f1.path, 0);
|
||||
assert.isTrue(completions1.entries.some(e => e.name === "somelongname"), "should contain 'somelongname'");
|
||||
|
||||
service.closeClientFile(f2.path);
|
||||
const completions2 = service.externalProjects[0].getLanguageService().getCompletionsAtPosition(f1.path, 0);
|
||||
assert.isFalse(completions2.entries.some(e => e.name === "somelongname"), "should not contain 'somelongname'");
|
||||
const sf2 = service.externalProjects[0].getLanguageService().getProgram().getSourceFile(f2.path);
|
||||
assert.equal(sf2.text, "");
|
||||
});
|
||||
|
||||
|
||||
it("external project with included config file opened after configured project", () => {
|
||||
const file1 = {
|
||||
path: "/a/b/f1.ts",
|
||||
@@ -1116,6 +1238,7 @@ namespace ts.projectSystem {
|
||||
projectService.closeExternalProject(externalProjectName);
|
||||
checkNumberOfProjects(projectService, { configuredProjects: 0 });
|
||||
});
|
||||
|
||||
it("external project with included config file opened after configured project and then closed", () => {
|
||||
const file1 = {
|
||||
path: "/a/b/f1.ts",
|
||||
@@ -1469,6 +1592,67 @@ namespace ts.projectSystem {
|
||||
checkProjectActualFiles(projectService.inferredProjects[1], [file2.path]);
|
||||
});
|
||||
|
||||
it("tsconfig script block support", () => {
|
||||
const file1 = {
|
||||
path: "/a/b/f1.ts",
|
||||
content: ` `
|
||||
};
|
||||
const file2 = {
|
||||
path: "/a/b/f2.html",
|
||||
content: `var hello = "hello";`
|
||||
};
|
||||
const config = {
|
||||
path: "/a/b/tsconfig.json",
|
||||
content: JSON.stringify({ compilerOptions: { allowJs: true } })
|
||||
};
|
||||
const host = createServerHost([file1, file2, config]);
|
||||
const session = createSession(host);
|
||||
openFilesForSession([file1], session);
|
||||
const projectService = session.getProjectService();
|
||||
|
||||
// HTML file will not be included in any projects yet
|
||||
checkNumberOfProjects(projectService, { configuredProjects: 1 });
|
||||
checkProjectActualFiles(projectService.configuredProjects[0], [file1.path]);
|
||||
|
||||
// Specify .html extension as mixed content
|
||||
const extraFileExtensions = [{ extension: ".html", scriptKind: ScriptKind.JS, isMixedContent: true }];
|
||||
const configureHostRequest = makeSessionRequest<protocol.ConfigureRequestArguments>(CommandNames.Configure, { extraFileExtensions });
|
||||
session.executeCommand(configureHostRequest).response;
|
||||
|
||||
// HTML file still not included in the project as it is closed
|
||||
checkNumberOfProjects(projectService, { configuredProjects: 1 });
|
||||
checkProjectActualFiles(projectService.configuredProjects[0], [file1.path]);
|
||||
|
||||
// Open HTML file
|
||||
projectService.applyChangesInOpenFiles(
|
||||
/*openFiles*/[{ fileName: file2.path, hasMixedContent: true, scriptKind: ScriptKind.JS, content: `var hello = "hello";` }],
|
||||
/*changedFiles*/undefined,
|
||||
/*closedFiles*/undefined);
|
||||
|
||||
// Now HTML file is included in the project
|
||||
checkNumberOfProjects(projectService, { configuredProjects: 1 });
|
||||
checkProjectActualFiles(projectService.configuredProjects[0], [file1.path, file2.path]);
|
||||
|
||||
// Check identifiers defined in HTML content are available in .ts file
|
||||
const project = projectService.configuredProjects[0];
|
||||
let completions = project.getLanguageService().getCompletionsAtPosition(file1.path, 1);
|
||||
assert(completions && completions.entries[0].name === "hello", `expected entry hello to be in completion list`);
|
||||
|
||||
// Close HTML file
|
||||
projectService.applyChangesInOpenFiles(
|
||||
/*openFiles*/undefined,
|
||||
/*changedFiles*/undefined,
|
||||
/*closedFiles*/[file2.path]);
|
||||
|
||||
// HTML file is still included in project
|
||||
checkNumberOfProjects(projectService, { configuredProjects: 1 });
|
||||
checkProjectActualFiles(projectService.configuredProjects[0], [file1.path, file2.path]);
|
||||
|
||||
// Check identifiers defined in HTML content are not available in .ts file
|
||||
completions = project.getLanguageService().getCompletionsAtPosition(file1.path, 5);
|
||||
assert(completions && completions.entries[0].name !== "hello", `unexpected hello entry in completion list`);
|
||||
});
|
||||
|
||||
it("project structure update is deferred if files are not added\removed", () => {
|
||||
const file1 = {
|
||||
path: "/a/b/f1.ts",
|
||||
@@ -1514,7 +1698,7 @@ namespace ts.projectSystem {
|
||||
const project = projectService.externalProjects[0];
|
||||
|
||||
const scriptInfo = project.getScriptInfo(file1.path);
|
||||
const snap = scriptInfo.snap();
|
||||
const snap = scriptInfo.getSnapshot();
|
||||
const actualText = snap.getText(0, snap.getLength());
|
||||
assert.equal(actualText, "", `expected content to be empty string, got "${actualText}"`);
|
||||
|
||||
@@ -1527,7 +1711,7 @@ namespace ts.projectSystem {
|
||||
projectService.closeClientFile(file1.path);
|
||||
|
||||
const scriptInfo2 = project.getScriptInfo(file1.path);
|
||||
const snap2 = scriptInfo2.snap();
|
||||
const snap2 = scriptInfo2.getSnapshot();
|
||||
const actualText2 = snap2.getText(0, snap.getLength());
|
||||
assert.equal(actualText2, "", `expected content to be empty string, got "${actualText2}"`);
|
||||
});
|
||||
@@ -1614,6 +1798,49 @@ namespace ts.projectSystem {
|
||||
checkNumberOfProjects(projectService, { configuredProjects: 0 });
|
||||
});
|
||||
|
||||
it("language service disabled state is updated in external projects", () => {
|
||||
debugger
|
||||
const f1 = {
|
||||
path: "/a/app.js",
|
||||
content: "var x = 1"
|
||||
};
|
||||
const f2 = {
|
||||
path: "/a/largefile.js",
|
||||
content: ""
|
||||
};
|
||||
const host = createServerHost([f1, f2]);
|
||||
const originalGetFileSize = host.getFileSize;
|
||||
host.getFileSize = (filePath: string) =>
|
||||
filePath === f2.path ? server.maxProgramSizeForNonTsFiles + 1 : originalGetFileSize.call(host, filePath);
|
||||
|
||||
const service = createProjectService(host);
|
||||
const projectFileName = "/a/proj.csproj";
|
||||
|
||||
service.openExternalProject({
|
||||
projectFileName,
|
||||
rootFiles: toExternalFiles([f1.path, f2.path]),
|
||||
options: {}
|
||||
});
|
||||
service.checkNumberOfProjects({ externalProjects: 1 });
|
||||
assert.isFalse(service.externalProjects[0].languageServiceEnabled, "language service should be disabled - 1");
|
||||
|
||||
service.openExternalProject({
|
||||
projectFileName,
|
||||
rootFiles: toExternalFiles([f1.path]),
|
||||
options: {}
|
||||
});
|
||||
service.checkNumberOfProjects({ externalProjects: 1 });
|
||||
assert.isTrue(service.externalProjects[0].languageServiceEnabled, "language service should be enabled");
|
||||
|
||||
service.openExternalProject({
|
||||
projectFileName,
|
||||
rootFiles: toExternalFiles([f1.path, f2.path]),
|
||||
options: {}
|
||||
});
|
||||
service.checkNumberOfProjects({ externalProjects: 1 });
|
||||
assert.isFalse(service.externalProjects[0].languageServiceEnabled, "language service should be disabled - 2");
|
||||
});
|
||||
|
||||
it("language service disabled events are triggered", () => {
|
||||
const f1 = {
|
||||
path: "/a/app.js",
|
||||
@@ -2225,13 +2452,13 @@ namespace ts.projectSystem {
|
||||
p.updateGraph();
|
||||
|
||||
const scriptInfo = p.getScriptInfo(f.path);
|
||||
checkSnapLength(scriptInfo.snap(), f.content.length);
|
||||
checkSnapLength(scriptInfo.getSnapshot(), f.content.length);
|
||||
|
||||
// open project and replace its content with empty string
|
||||
projectService.openClientFile(f.path, "");
|
||||
checkSnapLength(scriptInfo.snap(), 0);
|
||||
checkSnapLength(scriptInfo.getSnapshot(), 0);
|
||||
});
|
||||
function checkSnapLength(snap: server.LineIndexSnapshot, expectedLength: number) {
|
||||
function checkSnapLength(snap: IScriptSnapshot, expectedLength: number) {
|
||||
assert.equal(snap.getLength(), expectedLength, "Incorrect snapshot size");
|
||||
}
|
||||
});
|
||||
@@ -2384,7 +2611,6 @@ namespace ts.projectSystem {
|
||||
const cwd = {
|
||||
path: "/a/c"
|
||||
};
|
||||
debugger;
|
||||
const host = createServerHost([f1, config, node, cwd], { currentDirectory: cwd.path });
|
||||
const projectService = createProjectService(host);
|
||||
projectService.openClientFile(f1.path);
|
||||
@@ -2655,7 +2881,7 @@ namespace ts.projectSystem {
|
||||
|
||||
// verify content
|
||||
const projectServiice = session.getProjectService();
|
||||
const snap1 = projectServiice.getScriptInfo(f1.path).snap();
|
||||
const snap1 = projectServiice.getScriptInfo(f1.path).getSnapshot();
|
||||
assert.equal(snap1.getText(0, snap1.getLength()), tmp.content, "content should be equal to the content of temp file");
|
||||
|
||||
// reload from original file file
|
||||
@@ -2667,7 +2893,7 @@ namespace ts.projectSystem {
|
||||
});
|
||||
|
||||
// verify content
|
||||
const snap2 = projectServiice.getScriptInfo(f1.path).snap();
|
||||
const snap2 = projectServiice.getScriptInfo(f1.path).getSnapshot();
|
||||
assert.equal(snap2.getText(0, snap2.getLength()), f1.content, "content should be equal to the content of original file");
|
||||
|
||||
});
|
||||
|
||||
Vendored
+9
@@ -7,6 +7,15 @@ interface Array<T> {
|
||||
includes(searchElement: T, fromIndex?: number): boolean;
|
||||
}
|
||||
|
||||
interface ReadonlyArray<T> {
|
||||
/**
|
||||
* Determines whether an array includes a certain element, returning true or false as appropriate.
|
||||
* @param searchElement The element to search for.
|
||||
* @param fromIndex The position in this array at which to begin searching for searchElement.
|
||||
*/
|
||||
includes(searchElement: T, fromIndex?: number): boolean;
|
||||
}
|
||||
|
||||
interface Int8Array {
|
||||
/**
|
||||
* Determines whether an array includes a certain element, returning true or false as appropriate.
|
||||
|
||||
+26
-6
@@ -75,17 +75,32 @@ namespace ts.server {
|
||||
getFilesAffectedBy(scriptInfo: ScriptInfo): string[];
|
||||
onProjectUpdateGraph(): void;
|
||||
emitFile(scriptInfo: ScriptInfo, writeFile: (path: string, data: string, writeByteOrderMark?: boolean) => void): boolean;
|
||||
clear(): void;
|
||||
}
|
||||
|
||||
abstract class AbstractBuilder<T extends BuilderFileInfo> implements Builder {
|
||||
|
||||
private fileInfos = createFileMap<T>();
|
||||
/**
|
||||
* stores set of files from the project.
|
||||
* NOTE: this field is created on demand and should not be accessed directly.
|
||||
* Use 'getFileInfos' instead.
|
||||
*/
|
||||
private fileInfos_doNotAccessDirectly: FileMap<T>;
|
||||
|
||||
constructor(public readonly project: Project, private ctor: { new (scriptInfo: ScriptInfo, project: Project): T }) {
|
||||
}
|
||||
|
||||
private getFileInfos() {
|
||||
return this.fileInfos_doNotAccessDirectly || (this.fileInfos_doNotAccessDirectly = createFileMap<T>());
|
||||
}
|
||||
|
||||
public clear() {
|
||||
// drop the existing list - it will be re-created as necessary
|
||||
this.fileInfos_doNotAccessDirectly = undefined;
|
||||
}
|
||||
|
||||
protected getFileInfo(path: Path): T {
|
||||
return this.fileInfos.get(path);
|
||||
return this.getFileInfos().get(path);
|
||||
}
|
||||
|
||||
protected getOrCreateFileInfo(path: Path): T {
|
||||
@@ -99,19 +114,19 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
protected getFileInfoPaths(): Path[] {
|
||||
return this.fileInfos.getKeys();
|
||||
return this.getFileInfos().getKeys();
|
||||
}
|
||||
|
||||
protected setFileInfo(path: Path, info: T) {
|
||||
this.fileInfos.set(path, info);
|
||||
this.getFileInfos().set(path, info);
|
||||
}
|
||||
|
||||
protected removeFileInfo(path: Path) {
|
||||
this.fileInfos.remove(path);
|
||||
this.getFileInfos().remove(path);
|
||||
}
|
||||
|
||||
protected forEachFileInfo(action: (fileInfo: T) => any) {
|
||||
this.fileInfos.forEachValue((_path, value) => action(value));
|
||||
this.getFileInfos().forEachValue((_path, value) => action(value));
|
||||
}
|
||||
|
||||
abstract getFilesAffectedBy(scriptInfo: ScriptInfo): string[];
|
||||
@@ -231,6 +246,11 @@ namespace ts.server {
|
||||
|
||||
private projectVersionForDependencyGraph: string;
|
||||
|
||||
public clear() {
|
||||
this.projectVersionForDependencyGraph = undefined;
|
||||
super.clear();
|
||||
}
|
||||
|
||||
private getReferencedFileInfos(fileInfo: ModuleBuilderFileInfo): ModuleBuilderFileInfo[] {
|
||||
if (!fileInfo.isExternalModuleOrHasOnlyAmbientExternalModules()) {
|
||||
return [];
|
||||
|
||||
+106
-44
@@ -108,6 +108,7 @@ namespace ts.server {
|
||||
export interface HostConfiguration {
|
||||
formatCodeOptions: FormatCodeSettings;
|
||||
hostInfo: string;
|
||||
extraFileExtensions?: FileExtensionInfo[];
|
||||
}
|
||||
|
||||
interface ConfigFileConversionResult {
|
||||
@@ -125,20 +126,23 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
export interface OpenConfiguredProjectResult {
|
||||
configFileName?: string;
|
||||
configFileName?: NormalizedPath;
|
||||
configFileErrors?: Diagnostic[];
|
||||
}
|
||||
|
||||
interface FilePropertyReader<T> {
|
||||
getFileName(f: T): string;
|
||||
getScriptKind(f: T): ScriptKind;
|
||||
hasMixedContent(f: T): boolean;
|
||||
hasMixedContent(f: T, extraFileExtensions: FileExtensionInfo[]): boolean;
|
||||
}
|
||||
|
||||
const fileNamePropertyReader: FilePropertyReader<string> = {
|
||||
getFileName: x => x,
|
||||
getScriptKind: _ => undefined,
|
||||
hasMixedContent: _ => false
|
||||
hasMixedContent: (fileName, extraFileExtensions) => {
|
||||
const mixedContentExtensions = ts.map(ts.filter(extraFileExtensions, item => item.isMixedContent), item => item.extension);
|
||||
return forEach(mixedContentExtensions, extension => fileExtensionIs(fileName, extension))
|
||||
}
|
||||
};
|
||||
|
||||
const externalFilePropertyReader: FilePropertyReader<protocol.ExternalFile> = {
|
||||
@@ -282,7 +286,8 @@ namespace ts.server {
|
||||
|
||||
this.hostConfiguration = {
|
||||
formatCodeOptions: getDefaultFormatCodeSettings(this.host),
|
||||
hostInfo: "Unknown host"
|
||||
hostInfo: "Unknown host",
|
||||
extraFileExtensions: []
|
||||
};
|
||||
|
||||
this.documentRegistry = createDocumentRegistry(host.useCaseSensitiveFileNames, host.getCurrentDirectory());
|
||||
@@ -424,7 +429,7 @@ namespace ts.server {
|
||||
this.handleDeletedFile(info);
|
||||
}
|
||||
else {
|
||||
if (info && (!info.isOpen)) {
|
||||
if (info && (!info.isScriptOpen())) {
|
||||
// file has been changed which might affect the set of referenced files in projects that include
|
||||
// this file and set of inferred projects
|
||||
info.reloadFromFile();
|
||||
@@ -440,7 +445,7 @@ namespace ts.server {
|
||||
|
||||
// TODO: handle isOpen = true case
|
||||
|
||||
if (!info.isOpen) {
|
||||
if (!info.isScriptOpen()) {
|
||||
this.filenameToScriptInfo.remove(info.path);
|
||||
this.lastDeletedFile = info;
|
||||
|
||||
@@ -486,7 +491,7 @@ namespace ts.server {
|
||||
// If a change was made inside "folder/file", node will trigger the callback twice:
|
||||
// one with the fileName being "folder/file", and the other one with "folder".
|
||||
// We don't respond to the second one.
|
||||
if (fileName && !ts.isSupportedSourceFileName(fileName, project.getCompilerOptions())) {
|
||||
if (fileName && !ts.isSupportedSourceFileName(fileName, project.getCompilerOptions(), this.hostConfiguration.extraFileExtensions)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -634,15 +639,17 @@ namespace ts.server {
|
||||
// Closing file should trigger re-reading the file content from disk. This is
|
||||
// because the user may chose to discard the buffer content before saving
|
||||
// to the disk, and the server's version of the file can be out of sync.
|
||||
info.reloadFromFile();
|
||||
info.close();
|
||||
|
||||
removeItemFromSet(this.openFiles, info);
|
||||
info.isOpen = false;
|
||||
|
||||
// collect all projects that should be removed
|
||||
let projectsToRemove: Project[];
|
||||
for (const p of info.containingProjects) {
|
||||
if (p.projectKind === ProjectKind.Configured) {
|
||||
if (info.hasMixedContent) {
|
||||
info.registerFileUpdate();
|
||||
}
|
||||
// last open file in configured project - close it
|
||||
if ((<ConfiguredProject>p).deleteOpenRef() === 0) {
|
||||
(projectsToRemove || (projectsToRemove = [])).push(p);
|
||||
@@ -652,6 +659,13 @@ namespace ts.server {
|
||||
// open file in inferred project
|
||||
(projectsToRemove || (projectsToRemove = [])).push(p);
|
||||
}
|
||||
|
||||
if (!p.languageServiceEnabled) {
|
||||
// if project language service is disabled then we create a program only for open files.
|
||||
// this means that project should be marked as dirty to force rebuilding of the program
|
||||
// on the next request
|
||||
p.markAsDirty();
|
||||
}
|
||||
}
|
||||
if (projectsToRemove) {
|
||||
for (const project of projectsToRemove) {
|
||||
@@ -811,7 +825,9 @@ namespace ts.server {
|
||||
this.host,
|
||||
getDirectoryPath(configFilename),
|
||||
/*existingOptions*/ {},
|
||||
configFilename);
|
||||
configFilename,
|
||||
/*resolutionStack*/ [],
|
||||
this.hostConfiguration.extraFileExtensions);
|
||||
|
||||
if (parsedCommandLine.errors.length) {
|
||||
errors = concatenate(errors, parsedCommandLine.errors);
|
||||
@@ -915,7 +931,7 @@ namespace ts.server {
|
||||
for (const f of files) {
|
||||
const rootFilename = propertyReader.getFileName(f);
|
||||
const scriptKind = propertyReader.getScriptKind(f);
|
||||
const hasMixedContent = propertyReader.hasMixedContent(f);
|
||||
const hasMixedContent = propertyReader.hasMixedContent(f, this.hostConfiguration.extraFileExtensions);
|
||||
if (this.host.fileExists(rootFilename)) {
|
||||
const info = this.getOrCreateScriptInfoForNormalizedPath(toNormalizedPath(rootFilename), /*openedByClient*/ clientFileName == rootFilename, /*fileContent*/ undefined, scriptKind, hasMixedContent);
|
||||
project.addRoot(info);
|
||||
@@ -961,7 +977,7 @@ namespace ts.server {
|
||||
rootFilesChanged = true;
|
||||
if (!scriptInfo) {
|
||||
const scriptKind = propertyReader.getScriptKind(f);
|
||||
const hasMixedContent = propertyReader.hasMixedContent(f);
|
||||
const hasMixedContent = propertyReader.hasMixedContent(f, this.hostConfiguration.extraFileExtensions);
|
||||
scriptInfo = this.getOrCreateScriptInfoForNormalizedPath(normalizedPath, /*openedByClient*/ false, /*fileContent*/ undefined, scriptKind, hasMixedContent);
|
||||
}
|
||||
}
|
||||
@@ -989,7 +1005,7 @@ namespace ts.server {
|
||||
}
|
||||
if (toAdd) {
|
||||
for (const f of toAdd) {
|
||||
if (f.isOpen && isRootFileInInferredProject(f)) {
|
||||
if (f.isScriptOpen() && isRootFileInInferredProject(f)) {
|
||||
// if file is already root in some inferred project
|
||||
// - remove the file from that project and delete the project if necessary
|
||||
const inferredProject = f.containingProjects[0];
|
||||
@@ -1043,9 +1059,7 @@ namespace ts.server {
|
||||
project.stopWatchingDirectory();
|
||||
}
|
||||
else {
|
||||
if (!project.languageServiceEnabled) {
|
||||
project.enableLanguageService();
|
||||
}
|
||||
project.enableLanguageService();
|
||||
this.watchConfigDirectoryForProject(project, projectOptions);
|
||||
this.updateNonInferredProject(project, projectOptions.files, fileNamePropertyReader, projectOptions.compilerOptions, projectOptions.typeAcquisition, projectOptions.compileOnSave, configFileErrors);
|
||||
}
|
||||
@@ -1089,32 +1103,34 @@ namespace ts.server {
|
||||
getOrCreateScriptInfoForNormalizedPath(fileName: NormalizedPath, openedByClient: boolean, fileContent?: string, scriptKind?: ScriptKind, hasMixedContent?: boolean) {
|
||||
let info = this.getScriptInfoForNormalizedPath(fileName);
|
||||
if (!info) {
|
||||
let content: string;
|
||||
if (this.host.fileExists(fileName)) {
|
||||
// by default pick whatever content was supplied as the argument
|
||||
// if argument was not given - then for mixed content files assume that its content is empty string
|
||||
content = fileContent || (hasMixedContent ? "" : this.host.readFile(fileName));
|
||||
}
|
||||
if (!content) {
|
||||
if (openedByClient) {
|
||||
content = "";
|
||||
}
|
||||
}
|
||||
if (content !== undefined) {
|
||||
info = new ScriptInfo(this.host, fileName, content, scriptKind, openedByClient, hasMixedContent);
|
||||
// do not watch files with mixed content - server doesn't know how to interpret it
|
||||
if (openedByClient || this.host.fileExists(fileName)) {
|
||||
info = new ScriptInfo(this.host, fileName, scriptKind, hasMixedContent);
|
||||
|
||||
this.filenameToScriptInfo.set(info.path, info);
|
||||
if (!info.isOpen && !hasMixedContent) {
|
||||
info.setWatcher(this.host.watchFile(fileName, _ => this.onSourceFileChanged(fileName)));
|
||||
|
||||
if (openedByClient) {
|
||||
if (fileContent === undefined) {
|
||||
// if file is opened by client and its content is not specified - use file text
|
||||
fileContent = this.host.readFile(fileName) || "";
|
||||
}
|
||||
}
|
||||
else {
|
||||
// do not watch files with mixed content - server doesn't know how to interpret it
|
||||
if (!hasMixedContent) {
|
||||
info.setWatcher(this.host.watchFile(fileName, _ => this.onSourceFileChanged(fileName)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (info) {
|
||||
if (fileContent !== undefined) {
|
||||
info.reload(fileContent);
|
||||
if (openedByClient && !info.isScriptOpen()) {
|
||||
info.open(fileContent);
|
||||
if (hasMixedContent) {
|
||||
info.registerFileUpdate();
|
||||
}
|
||||
}
|
||||
if (openedByClient) {
|
||||
info.isOpen = true;
|
||||
else if (fileContent !== undefined) {
|
||||
info.reload(fileContent);
|
||||
}
|
||||
}
|
||||
return info;
|
||||
@@ -1146,6 +1162,10 @@ namespace ts.server {
|
||||
mergeMaps(this.hostConfiguration.formatCodeOptions, convertFormatOptions(args.formatOptions));
|
||||
this.logger.info("Format host information updated");
|
||||
}
|
||||
if (args.extraFileExtensions) {
|
||||
this.hostConfiguration.extraFileExtensions = args.extraFileExtensions;
|
||||
this.logger.info("Host file extension mappings updated");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1211,9 +1231,22 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
openClientFileWithNormalizedPath(fileName: NormalizedPath, fileContent?: string, scriptKind?: ScriptKind, hasMixedContent?: boolean): OpenConfiguredProjectResult {
|
||||
const { configFileName = undefined, configFileErrors = undefined }: OpenConfiguredProjectResult = this.findContainingExternalProject(fileName)
|
||||
? {}
|
||||
: this.openOrUpdateConfiguredProjectForFile(fileName);
|
||||
let configFileName: NormalizedPath;
|
||||
let configFileErrors: Diagnostic[];
|
||||
|
||||
let project: ConfiguredProject | ExternalProject = this.findContainingExternalProject(fileName);
|
||||
if (!project) {
|
||||
({ configFileName, configFileErrors } = this.openOrUpdateConfiguredProjectForFile(fileName));
|
||||
if (configFileName) {
|
||||
project = this.findConfiguredProjectByProjectName(configFileName);
|
||||
}
|
||||
}
|
||||
if (project && !project.languageServiceEnabled) {
|
||||
// if project language service is disabled then we create a program only for open files.
|
||||
// this means that project should be marked as dirty to force rebuilding of the program
|
||||
// on the next request
|
||||
project.markAsDirty();
|
||||
}
|
||||
|
||||
// at this point if file is the part of some configured/external project then this project should be created
|
||||
const info = this.getOrCreateScriptInfoForNormalizedPath(fileName, /*openedByClient*/ true, fileContent, scriptKind, hasMixedContent);
|
||||
@@ -1230,7 +1263,6 @@ namespace ts.server {
|
||||
const info = this.getScriptInfoForNormalizedPath(toNormalizedPath(uncheckedFileName));
|
||||
if (info) {
|
||||
this.closeOpenFile(info);
|
||||
info.isOpen = false;
|
||||
}
|
||||
this.printProjects();
|
||||
}
|
||||
@@ -1255,7 +1287,7 @@ namespace ts.server {
|
||||
if (openFiles) {
|
||||
for (const file of openFiles) {
|
||||
const scriptInfo = this.getScriptInfo(file.fileName);
|
||||
Debug.assert(!scriptInfo || !scriptInfo.isOpen);
|
||||
Debug.assert(!scriptInfo || !scriptInfo.isScriptOpen());
|
||||
const normalizedPath = scriptInfo ? scriptInfo.fileName : toNormalizedPath(file.fileName);
|
||||
this.openClientFileWithNormalizedPath(normalizedPath, file.content, tryConvertScriptKindName(file.scriptKind), file.hasMixedContent);
|
||||
}
|
||||
@@ -1327,7 +1359,28 @@ namespace ts.server {
|
||||
}
|
||||
}
|
||||
|
||||
openExternalProject(proj: protocol.ExternalProject): void {
|
||||
openExternalProjects(projects: protocol.ExternalProject[]): void {
|
||||
// record project list before the update
|
||||
const projectsToClose = arrayToMap(this.externalProjects, p => p.getProjectName(), _ => true);
|
||||
for (const externalProjectName in this.externalProjectToConfiguredProjectMap) {
|
||||
projectsToClose[externalProjectName] = true;
|
||||
}
|
||||
|
||||
for (const externalProject of projects) {
|
||||
this.openExternalProject(externalProject, /*suppressRefreshOfInferredProjects*/ true);
|
||||
// delete project that is present in input list
|
||||
delete projectsToClose[externalProject.projectFileName];
|
||||
}
|
||||
|
||||
// close projects that were missing in the input list
|
||||
for (const externalProjectName in projectsToClose) {
|
||||
this.closeExternalProject(externalProjectName, /*suppressRefresh*/ true)
|
||||
}
|
||||
|
||||
this.refreshInferredProjects();
|
||||
}
|
||||
|
||||
openExternalProject(proj: protocol.ExternalProject, suppressRefreshOfInferredProjects = false): void {
|
||||
// typingOptions has been deprecated and is only supported for backward compatibility
|
||||
// purposes. It should be removed in future releases - use typeAcquisition instead.
|
||||
if (proj.typingOptions && !proj.typeAcquisition) {
|
||||
@@ -1357,8 +1410,15 @@ namespace ts.server {
|
||||
let exisingConfigFiles: string[];
|
||||
if (externalProject) {
|
||||
if (!tsConfigFiles) {
|
||||
const compilerOptions = convertCompilerOptions(proj.options);
|
||||
if (this.exceededTotalSizeLimitForNonTsFiles(compilerOptions, proj.rootFiles, externalFilePropertyReader)) {
|
||||
externalProject.disableLanguageService();
|
||||
}
|
||||
else {
|
||||
externalProject.enableLanguageService();
|
||||
}
|
||||
// external project already exists and not config files were added - update the project and return;
|
||||
this.updateNonInferredProject(externalProject, proj.rootFiles, externalFilePropertyReader, convertCompilerOptions(proj.options), proj.typeAcquisition, proj.options.compileOnSave, /*configFileErrors*/ undefined);
|
||||
this.updateNonInferredProject(externalProject, proj.rootFiles, externalFilePropertyReader, compilerOptions, proj.typeAcquisition, proj.options.compileOnSave, /*configFileErrors*/ undefined);
|
||||
return;
|
||||
}
|
||||
// some config files were added to external project (that previously were not there)
|
||||
@@ -1420,7 +1480,9 @@ namespace ts.server {
|
||||
delete this.externalProjectToConfiguredProjectMap[proj.projectFileName];
|
||||
this.createAndAddExternalProject(proj.projectFileName, rootFiles, proj.options, proj.typeAcquisition);
|
||||
}
|
||||
this.refreshInferredProjects();
|
||||
if (!suppressRefreshOfInferredProjects) {
|
||||
this.refreshInferredProjects();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,7 +169,7 @@ namespace ts.server {
|
||||
getScriptSnapshot(filename: string): ts.IScriptSnapshot {
|
||||
const scriptInfo = this.project.getScriptInfoLSHost(filename);
|
||||
if (scriptInfo) {
|
||||
return scriptInfo.snap();
|
||||
return scriptInfo.getSnapshot();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+37
-99
@@ -1,4 +1,4 @@
|
||||
/// <reference path="..\services\services.ts" />
|
||||
/// <reference path="..\services\services.ts" />
|
||||
/// <reference path="utilities.ts"/>
|
||||
/// <reference path="scriptInfo.ts"/>
|
||||
/// <reference path="lsHost.ts"/>
|
||||
@@ -90,87 +90,6 @@ namespace ts.server {
|
||||
}
|
||||
}
|
||||
|
||||
const emptyResult: any[] = [];
|
||||
const getEmptyResult = () => emptyResult;
|
||||
const getUndefined = () => <any>undefined;
|
||||
const emptyEncodedSemanticClassifications = { spans: emptyResult, endOfLineState: EndOfLineState.None };
|
||||
|
||||
export function createNoSemanticFeaturesWrapper(realLanguageService: LanguageService): LanguageService {
|
||||
return {
|
||||
cleanupSemanticCache: noop,
|
||||
getSyntacticDiagnostics: (fileName) =>
|
||||
fileName ? realLanguageService.getSyntacticDiagnostics(fileName) : emptyResult,
|
||||
getSemanticDiagnostics: getEmptyResult,
|
||||
getCompilerOptionsDiagnostics: () =>
|
||||
realLanguageService.getCompilerOptionsDiagnostics(),
|
||||
getSyntacticClassifications: (fileName, span) =>
|
||||
realLanguageService.getSyntacticClassifications(fileName, span),
|
||||
getEncodedSyntacticClassifications: (fileName, span) =>
|
||||
realLanguageService.getEncodedSyntacticClassifications(fileName, span),
|
||||
getSemanticClassifications: getEmptyResult,
|
||||
getEncodedSemanticClassifications: () =>
|
||||
emptyEncodedSemanticClassifications,
|
||||
getCompletionsAtPosition: getUndefined,
|
||||
findReferences: getEmptyResult,
|
||||
getCompletionEntryDetails: getUndefined,
|
||||
getQuickInfoAtPosition: getUndefined,
|
||||
findRenameLocations: getEmptyResult,
|
||||
getNameOrDottedNameSpan: (fileName, startPos, endPos) =>
|
||||
realLanguageService.getNameOrDottedNameSpan(fileName, startPos, endPos),
|
||||
getBreakpointStatementAtPosition: (fileName, position) =>
|
||||
realLanguageService.getBreakpointStatementAtPosition(fileName, position),
|
||||
getBraceMatchingAtPosition: (fileName, position) =>
|
||||
realLanguageService.getBraceMatchingAtPosition(fileName, position),
|
||||
getSignatureHelpItems: getUndefined,
|
||||
getDefinitionAtPosition: getEmptyResult,
|
||||
getRenameInfo: () => ({
|
||||
canRename: false,
|
||||
localizedErrorMessage: getLocaleSpecificMessage(Diagnostics.Language_service_is_disabled),
|
||||
displayName: undefined,
|
||||
fullDisplayName: undefined,
|
||||
kind: undefined,
|
||||
kindModifiers: undefined,
|
||||
triggerSpan: undefined
|
||||
}),
|
||||
getTypeDefinitionAtPosition: getUndefined,
|
||||
getReferencesAtPosition: getEmptyResult,
|
||||
getDocumentHighlights: getEmptyResult,
|
||||
getOccurrencesAtPosition: getEmptyResult,
|
||||
getNavigateToItems: getEmptyResult,
|
||||
getNavigationBarItems: fileName =>
|
||||
realLanguageService.getNavigationBarItems(fileName),
|
||||
getNavigationTree: fileName =>
|
||||
realLanguageService.getNavigationTree(fileName),
|
||||
getOutliningSpans: fileName =>
|
||||
realLanguageService.getOutliningSpans(fileName),
|
||||
getTodoComments: getEmptyResult,
|
||||
getIndentationAtPosition: (fileName, position, options) =>
|
||||
realLanguageService.getIndentationAtPosition(fileName, position, options),
|
||||
getFormattingEditsForRange: (fileName, start, end, options) =>
|
||||
realLanguageService.getFormattingEditsForRange(fileName, start, end, options),
|
||||
getFormattingEditsForDocument: (fileName, options) =>
|
||||
realLanguageService.getFormattingEditsForDocument(fileName, options),
|
||||
getFormattingEditsAfterKeystroke: (fileName, position, key, options) =>
|
||||
realLanguageService.getFormattingEditsAfterKeystroke(fileName, position, key, options),
|
||||
getDocCommentTemplateAtPosition: (fileName, position) =>
|
||||
realLanguageService.getDocCommentTemplateAtPosition(fileName, position),
|
||||
isValidBraceCompletionAtPosition: (fileName, position, openingBrace) =>
|
||||
realLanguageService.isValidBraceCompletionAtPosition(fileName, position, openingBrace),
|
||||
getEmitOutput: getUndefined,
|
||||
getProgram: () =>
|
||||
realLanguageService.getProgram(),
|
||||
getNonBoundSourceFile: fileName =>
|
||||
realLanguageService.getNonBoundSourceFile(fileName),
|
||||
dispose: () =>
|
||||
realLanguageService.dispose(),
|
||||
getCompletionEntrySymbol: getUndefined,
|
||||
getImplementationAtPosition: getEmptyResult,
|
||||
getSourceFile: fileName =>
|
||||
realLanguageService.getSourceFile(fileName),
|
||||
getCodeFixesAtPosition: getEmptyResult
|
||||
};
|
||||
}
|
||||
|
||||
export abstract class Project {
|
||||
private rootFiles: ScriptInfo[] = [];
|
||||
private rootFilesMap: FileMap<ScriptInfo> = createFileMap<ScriptInfo>();
|
||||
@@ -181,12 +100,14 @@ namespace ts.server {
|
||||
private lastCachedUnresolvedImportsList: SortedReadonlyArray<string>;
|
||||
|
||||
private readonly languageService: LanguageService;
|
||||
// wrapper over the real language service that will suppress all semantic operations
|
||||
private readonly noSemanticFeaturesLanguageService: LanguageService;
|
||||
|
||||
public languageServiceEnabled = true;
|
||||
|
||||
builder: Builder;
|
||||
/**
|
||||
* Set of files names that were updated since the last call to getChangesSinceVersion.
|
||||
*/
|
||||
private updatedFileNames: Map<string>;
|
||||
/**
|
||||
* Set of files that was returned from the last call to getChangesSinceVersion.
|
||||
*/
|
||||
@@ -254,7 +175,6 @@ namespace ts.server {
|
||||
this.lsHost.setCompilationSettings(this.compilerOptions);
|
||||
|
||||
this.languageService = ts.createLanguageService(this.lsHost, this.documentRegistry);
|
||||
this.noSemanticFeaturesLanguageService = createNoSemanticFeaturesWrapper(this.languageService);
|
||||
|
||||
if (!languageServiceEnabled) {
|
||||
this.disableLanguageService();
|
||||
@@ -278,9 +198,7 @@ namespace ts.server {
|
||||
if (ensureSynchronized) {
|
||||
this.updateGraph();
|
||||
}
|
||||
return this.languageServiceEnabled
|
||||
? this.languageService
|
||||
: this.noSemanticFeaturesLanguageService;
|
||||
return this.languageService;
|
||||
}
|
||||
|
||||
getCompileOnSaveAffectedFileList(scriptInfo: ScriptInfo): string[] {
|
||||
@@ -369,7 +287,10 @@ namespace ts.server {
|
||||
const result: string[] = [];
|
||||
if (this.rootFiles) {
|
||||
for (const f of this.rootFiles) {
|
||||
result.push(f.fileName);
|
||||
if (this.languageServiceEnabled || f.isScriptOpen()) {
|
||||
// if language service is disabled - process only files that are open
|
||||
result.push(f.fileName);
|
||||
}
|
||||
}
|
||||
if (this.typingFiles) {
|
||||
for (const f of this.typingFiles) {
|
||||
@@ -385,6 +306,10 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
getScriptInfos() {
|
||||
if (!this.languageServiceEnabled) {
|
||||
// if language service is not enabled - return just root files
|
||||
return this.rootFiles;
|
||||
}
|
||||
return map(this.program.getSourceFiles(), sourceFile => {
|
||||
const scriptInfo = this.projectService.getScriptInfoForPath(sourceFile.path);
|
||||
if (!scriptInfo) {
|
||||
@@ -448,7 +373,7 @@ namespace ts.server {
|
||||
|
||||
containsFile(filename: NormalizedPath, requireOpen?: boolean) {
|
||||
const info = this.projectService.getScriptInfoForNormalizedPath(filename);
|
||||
if (info && (info.isOpen || !requireOpen)) {
|
||||
if (info && (info.isScriptOpen() || !requireOpen)) {
|
||||
return this.containsScriptInfo(info);
|
||||
}
|
||||
}
|
||||
@@ -480,6 +405,10 @@ namespace ts.server {
|
||||
this.markAsDirty();
|
||||
}
|
||||
|
||||
registerFileUpdate(fileName: string) {
|
||||
(this.updatedFileNames || (this.updatedFileNames = createMap<string>()))[fileName] = fileName;
|
||||
}
|
||||
|
||||
markAsDirty() {
|
||||
this.projectStateVersion++;
|
||||
}
|
||||
@@ -521,10 +450,6 @@ namespace ts.server {
|
||||
* @returns: true if set of files in the project stays the same and false - otherwise.
|
||||
*/
|
||||
updateGraph(): boolean {
|
||||
if (!this.languageServiceEnabled) {
|
||||
return true;
|
||||
}
|
||||
|
||||
this.lsHost.startRecordingFilesWithChangedResolutions();
|
||||
|
||||
let hasChanges = this.updateGraphWorker();
|
||||
@@ -556,6 +481,16 @@ namespace ts.server {
|
||||
if (this.setTypings(cachedTypings)) {
|
||||
hasChanges = this.updateGraphWorker() || hasChanges;
|
||||
}
|
||||
|
||||
// update builder only if language service is enabled
|
||||
// otherwise tell it to drop its internal state
|
||||
if (this.languageServiceEnabled) {
|
||||
this.builder.onProjectUpdateGraph();
|
||||
}
|
||||
else {
|
||||
this.builder.clear();
|
||||
}
|
||||
|
||||
if (hasChanges) {
|
||||
this.projectStructureVersion++;
|
||||
}
|
||||
@@ -594,7 +529,6 @@ namespace ts.server {
|
||||
}
|
||||
}
|
||||
}
|
||||
this.builder.onProjectUpdateGraph();
|
||||
return hasChanges;
|
||||
}
|
||||
|
||||
@@ -665,12 +599,15 @@ namespace ts.server {
|
||||
projectName: this.getProjectName(),
|
||||
version: this.projectStructureVersion,
|
||||
isInferred: this.projectKind === ProjectKind.Inferred,
|
||||
options: this.getCompilerOptions()
|
||||
options: this.getCompilerOptions(),
|
||||
languageServiceDisabled: !this.languageServiceEnabled
|
||||
};
|
||||
const updatedFileNames = this.updatedFileNames;
|
||||
this.updatedFileNames = undefined;
|
||||
// check if requested version is the same that we have reported last time
|
||||
if (this.lastReportedFileNames && lastKnownVersion === this.lastReportedVersion) {
|
||||
// if current structure version is the same - return info witout any changes
|
||||
if (this.projectStructureVersion == this.lastReportedVersion) {
|
||||
// if current structure version is the same - return info without any changes
|
||||
if (this.projectStructureVersion == this.lastReportedVersion && !updatedFileNames) {
|
||||
return { info, projectErrors: this.projectErrors };
|
||||
}
|
||||
// compute and return the difference
|
||||
@@ -679,6 +616,7 @@ namespace ts.server {
|
||||
|
||||
const added: string[] = [];
|
||||
const removed: string[] = [];
|
||||
const updated: string[] = getOwnKeys(updatedFileNames);
|
||||
for (const id in currentFiles) {
|
||||
if (!hasProperty(lastReportedFileNames, id)) {
|
||||
added.push(id);
|
||||
@@ -691,7 +629,7 @@ namespace ts.server {
|
||||
}
|
||||
this.lastReportedFileNames = currentFiles;
|
||||
this.lastReportedVersion = this.projectStructureVersion;
|
||||
return { info, changes: { added, removed }, projectErrors: this.projectErrors };
|
||||
return { info, changes: { added, removed, updated }, projectErrors: this.projectErrors };
|
||||
}
|
||||
else {
|
||||
// unknown version - return everything
|
||||
|
||||
+15
-1
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/**
|
||||
* Declaration module describing the TypeScript Server protocol
|
||||
*/
|
||||
namespace ts.server.protocol {
|
||||
@@ -904,6 +904,11 @@ namespace ts.server.protocol {
|
||||
* Current set of compiler options for project
|
||||
*/
|
||||
options: ts.CompilerOptions;
|
||||
|
||||
/**
|
||||
* true if project language service is disabled
|
||||
*/
|
||||
languageServiceDisabled: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -918,6 +923,10 @@ namespace ts.server.protocol {
|
||||
* List of removed files
|
||||
*/
|
||||
removed: string[];
|
||||
/**
|
||||
* List of updated files
|
||||
*/
|
||||
updated: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -990,6 +999,11 @@ namespace ts.server.protocol {
|
||||
* The format options to use during formatting and other code editing features.
|
||||
*/
|
||||
formatOptions?: FormatCodeSettings;
|
||||
|
||||
/**
|
||||
* The host's additional supported file extensions
|
||||
*/
|
||||
extraFileExtensions?: FileExtensionInfo[];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+197
-35
@@ -2,6 +2,161 @@
|
||||
|
||||
namespace ts.server {
|
||||
|
||||
/* @internal */
|
||||
export class TextStorage {
|
||||
private svc: ScriptVersionCache | undefined;
|
||||
private svcVersion = 0;
|
||||
|
||||
private text: string;
|
||||
private lineMap: number[];
|
||||
private textVersion = 0;
|
||||
|
||||
constructor(private readonly host: ServerHost, private readonly fileName: NormalizedPath) {
|
||||
}
|
||||
|
||||
public getVersion() {
|
||||
return this.svc
|
||||
? `SVC-${this.svcVersion}-${this.svc.getSnapshot().version}`
|
||||
: `Text-${this.textVersion}`;
|
||||
}
|
||||
|
||||
public hasScriptVersionCache() {
|
||||
return this.svc !== undefined;
|
||||
}
|
||||
|
||||
public useScriptVersionCache(newText?: string) {
|
||||
this.switchToScriptVersionCache(newText);
|
||||
}
|
||||
|
||||
public useText(newText?: string) {
|
||||
this.svc = undefined;
|
||||
this.setText(newText);
|
||||
}
|
||||
|
||||
public edit(start: number, end: number, newText: string) {
|
||||
this.switchToScriptVersionCache().edit(start, end - start, newText);
|
||||
}
|
||||
|
||||
public reload(text: string) {
|
||||
if (this.svc) {
|
||||
this.svc.reload(text);
|
||||
}
|
||||
else {
|
||||
this.setText(text);
|
||||
}
|
||||
}
|
||||
|
||||
public reloadFromFile(tempFileName?: string) {
|
||||
if (this.svc || (tempFileName !== this.fileName)) {
|
||||
this.reload(this.getFileText(tempFileName))
|
||||
}
|
||||
else {
|
||||
this.setText(undefined);
|
||||
}
|
||||
}
|
||||
|
||||
public getSnapshot(): IScriptSnapshot {
|
||||
return this.svc
|
||||
? this.svc.getSnapshot()
|
||||
: ScriptSnapshot.fromString(this.getOrLoadText());
|
||||
}
|
||||
|
||||
public getLineInfo(line: number) {
|
||||
return this.switchToScriptVersionCache().getSnapshot().index.lineNumberToInfo(line);
|
||||
}
|
||||
/**
|
||||
* @param line 0 based index
|
||||
*/
|
||||
lineToTextSpan(line: number) {
|
||||
if (!this.svc) {
|
||||
const lineMap = this.getLineMap();
|
||||
const start = lineMap[line]; // -1 since line is 1-based
|
||||
const end = line + 1 < lineMap.length ? lineMap[line + 1] : this.text.length;
|
||||
return ts.createTextSpanFromBounds(start, end);
|
||||
}
|
||||
const index = this.svc.getSnapshot().index;
|
||||
const lineInfo = index.lineNumberToInfo(line + 1);
|
||||
let len: number;
|
||||
if (lineInfo.leaf) {
|
||||
len = lineInfo.leaf.text.length;
|
||||
}
|
||||
else {
|
||||
const nextLineInfo = index.lineNumberToInfo(line + 2);
|
||||
len = nextLineInfo.offset - lineInfo.offset;
|
||||
}
|
||||
return ts.createTextSpan(lineInfo.offset, len);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param line 1 based index
|
||||
* @param offset 1 based index
|
||||
*/
|
||||
lineOffsetToPosition(line: number, offset: number): number {
|
||||
if (!this.svc) {
|
||||
return computePositionOfLineAndCharacter(this.getLineMap(), line - 1, offset - 1);
|
||||
}
|
||||
const index = this.svc.getSnapshot().index;
|
||||
|
||||
const lineInfo = index.lineNumberToInfo(line);
|
||||
// TODO: assert this offset is actually on the line
|
||||
return (lineInfo.offset + offset - 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param line 1-based index
|
||||
* @param offset 1-based index
|
||||
*/
|
||||
positionToLineOffset(position: number): ILineInfo {
|
||||
if (!this.svc) {
|
||||
const { line, character } = computeLineAndCharacterOfPosition(this.getLineMap(), position);
|
||||
return { line: line + 1, offset: character + 1 };
|
||||
}
|
||||
const index = this.svc.getSnapshot().index;
|
||||
const lineOffset = index.charOffsetToLineNumberAndPos(position);
|
||||
return { line: lineOffset.line, offset: lineOffset.offset + 1 };
|
||||
}
|
||||
|
||||
private getFileText(tempFileName?: string) {
|
||||
return this.host.readFile(tempFileName || this.fileName) || "";
|
||||
}
|
||||
|
||||
private ensureNoScriptVersionCache() {
|
||||
Debug.assert(!this.svc, "ScriptVersionCache should not be set");
|
||||
}
|
||||
|
||||
private switchToScriptVersionCache(newText?: string): ScriptVersionCache {
|
||||
if (!this.svc) {
|
||||
this.svc = ScriptVersionCache.fromString(this.host, newText !== undefined ? newText : this.getOrLoadText());
|
||||
this.svcVersion++;
|
||||
this.text = undefined;
|
||||
}
|
||||
return this.svc;
|
||||
}
|
||||
|
||||
private getOrLoadText() {
|
||||
this.ensureNoScriptVersionCache();
|
||||
if (this.text === undefined) {
|
||||
this.setText(this.getFileText());
|
||||
}
|
||||
return this.text;
|
||||
}
|
||||
|
||||
private getLineMap() {
|
||||
this.ensureNoScriptVersionCache();
|
||||
return this.lineMap || (this.lineMap = computeLineStarts(this.getOrLoadText()));
|
||||
}
|
||||
|
||||
private setText(newText: string) {
|
||||
this.ensureNoScriptVersionCache();
|
||||
if (newText === undefined || this.text !== newText) {
|
||||
this.text = newText;
|
||||
this.lineMap = undefined;
|
||||
this.textVersion++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export class ScriptInfo {
|
||||
/**
|
||||
* All projects that include this file
|
||||
@@ -11,24 +166,46 @@ namespace ts.server {
|
||||
readonly path: Path;
|
||||
|
||||
private fileWatcher: FileWatcher;
|
||||
private svc: ScriptVersionCache;
|
||||
private textStorage: TextStorage;
|
||||
|
||||
private isOpen: boolean;
|
||||
|
||||
// TODO: allow to update hasMixedContent from the outside
|
||||
constructor(
|
||||
private readonly host: ServerHost,
|
||||
readonly fileName: NormalizedPath,
|
||||
content: string,
|
||||
readonly scriptKind: ScriptKind,
|
||||
public isOpen = false,
|
||||
public hasMixedContent = false) {
|
||||
|
||||
this.path = toPath(fileName, host.getCurrentDirectory(), createGetCanonicalFileName(host.useCaseSensitiveFileNames));
|
||||
this.svc = ScriptVersionCache.fromString(host, content);
|
||||
this.textStorage = new TextStorage(host, fileName);
|
||||
if (hasMixedContent) {
|
||||
this.textStorage.reload("");
|
||||
}
|
||||
this.scriptKind = scriptKind
|
||||
? scriptKind
|
||||
: getScriptKindFromFileName(fileName);
|
||||
}
|
||||
|
||||
public isScriptOpen() {
|
||||
return this.isOpen;
|
||||
}
|
||||
|
||||
public open(newText: string) {
|
||||
this.isOpen = true;
|
||||
this.textStorage.useScriptVersionCache(newText);
|
||||
this.markContainingProjectsAsDirty();
|
||||
}
|
||||
|
||||
public close() {
|
||||
this.isOpen = false;
|
||||
this.textStorage.useText(this.hasMixedContent ? "" : undefined);
|
||||
this.markContainingProjectsAsDirty();
|
||||
}
|
||||
|
||||
public getSnapshot() {
|
||||
return this.textStorage.getSnapshot();
|
||||
}
|
||||
|
||||
getFormatCodeSettings() {
|
||||
return this.formatCodeSettings;
|
||||
}
|
||||
@@ -90,6 +267,12 @@ namespace ts.server {
|
||||
return this.containingProjects[0];
|
||||
}
|
||||
|
||||
registerFileUpdate(): void {
|
||||
for (const p of this.containingProjects) {
|
||||
p.registerFileUpdate(this.path);
|
||||
}
|
||||
}
|
||||
|
||||
setFormatOptions(formatSettings: FormatCodeSettings): void {
|
||||
if (formatSettings) {
|
||||
if (!this.formatCodeSettings) {
|
||||
@@ -112,16 +295,16 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
getLatestVersion() {
|
||||
return this.svc.latestVersion().toString();
|
||||
return this.textStorage.getVersion();
|
||||
}
|
||||
|
||||
reload(script: string) {
|
||||
this.svc.reload(script);
|
||||
this.textStorage.reload(script);
|
||||
this.markContainingProjectsAsDirty();
|
||||
}
|
||||
|
||||
saveTo(fileName: string) {
|
||||
const snap = this.snap();
|
||||
const snap = this.textStorage.getSnapshot();
|
||||
this.host.writeFile(fileName, snap.getText(0, snap.getLength()));
|
||||
}
|
||||
|
||||
@@ -130,22 +313,17 @@ namespace ts.server {
|
||||
this.reload("");
|
||||
}
|
||||
else {
|
||||
this.svc.reloadFromFile(tempFileName || this.fileName);
|
||||
this.textStorage.reloadFromFile(tempFileName);
|
||||
this.markContainingProjectsAsDirty();
|
||||
}
|
||||
}
|
||||
|
||||
snap() {
|
||||
return this.svc.getSnapshot();
|
||||
}
|
||||
|
||||
getLineInfo(line: number) {
|
||||
const snap = this.snap();
|
||||
return snap.index.lineNumberToInfo(line);
|
||||
return this.textStorage.getLineInfo(line);
|
||||
}
|
||||
|
||||
editContent(start: number, end: number, newText: string): void {
|
||||
this.svc.edit(start, end - start, newText);
|
||||
this.textStorage.edit(start, end, newText);
|
||||
this.markContainingProjectsAsDirty();
|
||||
}
|
||||
|
||||
@@ -159,17 +337,7 @@ namespace ts.server {
|
||||
* @param line 1 based index
|
||||
*/
|
||||
lineToTextSpan(line: number) {
|
||||
const index = this.snap().index;
|
||||
const lineInfo = index.lineNumberToInfo(line + 1);
|
||||
let len: number;
|
||||
if (lineInfo.leaf) {
|
||||
len = lineInfo.leaf.text.length;
|
||||
}
|
||||
else {
|
||||
const nextLineInfo = index.lineNumberToInfo(line + 2);
|
||||
len = nextLineInfo.offset - lineInfo.offset;
|
||||
}
|
||||
return ts.createTextSpan(lineInfo.offset, len);
|
||||
return this.textStorage.lineToTextSpan(line);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -177,11 +345,7 @@ namespace ts.server {
|
||||
* @param offset 1 based index
|
||||
*/
|
||||
lineOffsetToPosition(line: number, offset: number): number {
|
||||
const index = this.snap().index;
|
||||
|
||||
const lineInfo = index.lineNumberToInfo(line);
|
||||
// TODO: assert this offset is actually on the line
|
||||
return (lineInfo.offset + offset - 1);
|
||||
return this.textStorage.lineOffsetToPosition(line, offset);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -189,9 +353,7 @@ namespace ts.server {
|
||||
* @param offset 1-based index
|
||||
*/
|
||||
positionToLineOffset(position: number): ILineInfo {
|
||||
const index = this.snap().index;
|
||||
const lineOffset = index.charOffsetToLineNumberAndPos(position);
|
||||
return { line: lineOffset.line, offset: lineOffset.offset + 1 };
|
||||
return this.textStorage.positionToLineOffset(position);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -438,8 +438,9 @@ namespace ts.server {
|
||||
}
|
||||
}
|
||||
getChangeRange(oldSnapshot: ts.IScriptSnapshot): ts.TextChangeRange {
|
||||
const oldSnap = <LineIndexSnapshot>oldSnapshot;
|
||||
return this.getTextChangeRangeSinceVersion(oldSnap.version);
|
||||
if (oldSnapshot instanceof LineIndexSnapshot) {
|
||||
return this.getTextChangeRangeSinceVersion(oldSnapshot.version);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+26
-19
@@ -20,34 +20,41 @@ namespace ts.server {
|
||||
} = require("os");
|
||||
|
||||
function getGlobalTypingsCacheLocation() {
|
||||
let basePath: string;
|
||||
switch (process.platform) {
|
||||
case "win32":
|
||||
basePath = process.env.LOCALAPPDATA ||
|
||||
case "win32": {
|
||||
const basePath = process.env.LOCALAPPDATA ||
|
||||
process.env.APPDATA ||
|
||||
(os.homedir && os.homedir()) ||
|
||||
process.env.USERPROFILE ||
|
||||
(process.env.HOMEDRIVE && process.env.HOMEPATH && normalizeSlashes(process.env.HOMEDRIVE + process.env.HOMEPATH)) ||
|
||||
os.tmpdir();
|
||||
break;
|
||||
case "linux":
|
||||
case "android":
|
||||
basePath = (os.homedir && os.homedir()) ||
|
||||
process.env.HOME ||
|
||||
((process.env.LOGNAME || process.env.USER) && `/home/${process.env.LOGNAME || process.env.USER}`) ||
|
||||
os.tmpdir();
|
||||
break;
|
||||
return combinePaths(normalizeSlashes(basePath), "Microsoft/TypeScript");
|
||||
}
|
||||
case "darwin":
|
||||
const homeDir = (os.homedir && os.homedir()) ||
|
||||
process.env.HOME ||
|
||||
((process.env.LOGNAME || process.env.USER) && `/Users/${process.env.LOGNAME || process.env.USER}`) ||
|
||||
os.tmpdir();
|
||||
basePath = combinePaths(homeDir, "Library/Application Support/");
|
||||
break;
|
||||
case "linux":
|
||||
case "android": {
|
||||
const cacheLocation = getNonWindowsCacheLocation(process.platform === "darwin");
|
||||
return combinePaths(cacheLocation, "typescript");
|
||||
}
|
||||
default:
|
||||
Debug.fail(`unsupported platform '${process.platform}'`);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Debug.assert(basePath !== undefined);
|
||||
return combinePaths(normalizeSlashes(basePath), "Microsoft/TypeScript");
|
||||
function getNonWindowsCacheLocation(platformIsDarwin: boolean) {
|
||||
if (process.env.XDG_CACHE_HOME) {
|
||||
return process.env.XDG_CACHE_HOME;
|
||||
}
|
||||
const usersDir = platformIsDarwin ? "Users" : "home"
|
||||
const homePath = (os.homedir && os.homedir()) ||
|
||||
process.env.HOME ||
|
||||
((process.env.LOGNAME || process.env.USER) && `/${usersDir}/${process.env.LOGNAME || process.env.USER}`) ||
|
||||
os.tmpdir();
|
||||
const cacheFolder = platformIsDarwin
|
||||
? "Library/Caches"
|
||||
: ".cache"
|
||||
return combinePaths(normalizeSlashes(homePath), cacheFolder);
|
||||
}
|
||||
|
||||
interface NodeChildProcess {
|
||||
|
||||
@@ -709,7 +709,7 @@ namespace ts.server {
|
||||
const displayString = ts.displayPartsToString(nameInfo.displayParts);
|
||||
const nameSpan = nameInfo.textSpan;
|
||||
const nameColStart = scriptInfo.positionToLineOffset(nameSpan.start).offset;
|
||||
const nameText = scriptInfo.snap().getText(nameSpan.start, ts.textSpanEnd(nameSpan));
|
||||
const nameText = scriptInfo.getSnapshot().getText(nameSpan.start, ts.textSpanEnd(nameSpan));
|
||||
const refs = combineProjectOutput<protocol.ReferencesResponseItem>(
|
||||
projects,
|
||||
(project: Project) => {
|
||||
@@ -722,7 +722,7 @@ namespace ts.server {
|
||||
const refScriptInfo = project.getScriptInfo(ref.fileName);
|
||||
const start = refScriptInfo.positionToLineOffset(ref.textSpan.start);
|
||||
const refLineSpan = refScriptInfo.lineToTextSpan(start.line - 1);
|
||||
const lineText = refScriptInfo.snap().getText(refLineSpan.start, ts.textSpanEnd(refLineSpan)).replace(/\r|\n/g, "");
|
||||
const lineText = refScriptInfo.getSnapshot().getText(refLineSpan.start, ts.textSpanEnd(refLineSpan)).replace(/\r|\n/g, "");
|
||||
return {
|
||||
file: ref.fileName,
|
||||
start: start,
|
||||
@@ -1026,6 +1026,9 @@ namespace ts.server {
|
||||
if (!project) {
|
||||
Errors.ThrowNoProject();
|
||||
}
|
||||
if (!project.languageServiceEnabled) {
|
||||
return false;
|
||||
}
|
||||
const scriptInfo = project.getScriptInfo(file);
|
||||
return project.builder.emitFile(scriptInfo, (path, data, writeByteOrderMark) => this.host.writeFile(path, data, writeByteOrderMark));
|
||||
}
|
||||
@@ -1326,7 +1329,7 @@ namespace ts.server {
|
||||
highPriorityFiles.push(fileNameInProject);
|
||||
else {
|
||||
const info = this.projectService.getScriptInfo(fileNameInProject);
|
||||
if (!info.isOpen) {
|
||||
if (!info.isScriptOpen()) {
|
||||
if (fileNameInProject.indexOf(".d.ts") > 0)
|
||||
veryLowPriorityFiles.push(fileNameInProject);
|
||||
else
|
||||
@@ -1365,14 +1368,12 @@ namespace ts.server {
|
||||
|
||||
private handlers = createMap<(request: protocol.Request) => { response?: any, responseRequired?: boolean }>({
|
||||
[CommandNames.OpenExternalProject]: (request: protocol.OpenExternalProjectRequest) => {
|
||||
this.projectService.openExternalProject(request.arguments);
|
||||
this.projectService.openExternalProject(request.arguments, /*suppressRefreshOfInferredProjects*/ false);
|
||||
// TODO: report errors
|
||||
return this.requiredResponse(true);
|
||||
},
|
||||
[CommandNames.OpenExternalProjects]: (request: protocol.OpenExternalProjectsRequest) => {
|
||||
for (const proj of request.arguments.projects) {
|
||||
this.projectService.openExternalProject(proj);
|
||||
}
|
||||
this.projectService.openExternalProjects(request.arguments.projects);
|
||||
// TODO: report errors
|
||||
return this.requiredResponse(true);
|
||||
},
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/// <reference path="types.d.ts" />
|
||||
/// <reference path="types.d.ts" />
|
||||
/// <reference path="shared.ts" />
|
||||
|
||||
namespace ts.server {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* @internal */
|
||||
/* @internal */
|
||||
namespace ts.JsDoc {
|
||||
const jsDocTagNames = [
|
||||
"augments",
|
||||
@@ -23,6 +23,7 @@ namespace ts.JsDoc {
|
||||
"lends",
|
||||
"link",
|
||||
"memberOf",
|
||||
"method",
|
||||
"name",
|
||||
"namespace",
|
||||
"param",
|
||||
@@ -166,6 +167,7 @@ namespace ts.JsDoc {
|
||||
const lineStart = sourceFile.getLineStarts()[posLineAndChar.line];
|
||||
|
||||
const indentationStr = sourceFile.text.substr(lineStart, posLineAndChar.character);
|
||||
const isJavaScriptFile = hasJavaScriptFileExtension(sourceFile.fileName);
|
||||
|
||||
let docParams = "";
|
||||
for (let i = 0, numParams = parameters.length; i < numParams; i++) {
|
||||
@@ -173,8 +175,12 @@ namespace ts.JsDoc {
|
||||
const paramName = currentName.kind === SyntaxKind.Identifier ?
|
||||
(<Identifier>currentName).text :
|
||||
"param" + i;
|
||||
|
||||
docParams += `${indentationStr} * @param ${paramName}${newLine}`;
|
||||
if (isJavaScriptFile) {
|
||||
docParams += `${indentationStr} * @param {any} ${paramName}${newLine}`;
|
||||
}
|
||||
else {
|
||||
docParams += `${indentationStr} * @param ${paramName}${newLine}`;
|
||||
}
|
||||
}
|
||||
|
||||
// A doc comment consists of the following
|
||||
|
||||
@@ -1725,7 +1725,7 @@ namespace ts {
|
||||
const sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName);
|
||||
|
||||
// Check if in a context where we don't want to perform any insertion
|
||||
if (isInString(sourceFile, position) || isInComment(sourceFile, position)) {
|
||||
if (isInString(sourceFile, position)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -91,7 +91,9 @@ namespace ts {
|
||||
}
|
||||
|
||||
public getText(start: number, end: number): string {
|
||||
return this.text.substring(start, end);
|
||||
return start === 0 && end === this.text.length
|
||||
? this.text
|
||||
: this.text.substring(start, end);
|
||||
}
|
||||
|
||||
public getLength(): number {
|
||||
|
||||
@@ -1137,6 +1137,7 @@ namespace ts {
|
||||
writeSpace: text => writeKind(text, SymbolDisplayPartKind.space),
|
||||
writeStringLiteral: text => writeKind(text, SymbolDisplayPartKind.stringLiteral),
|
||||
writeParameter: text => writeKind(text, SymbolDisplayPartKind.parameterName),
|
||||
writeProperty: text => writeKind(text, SymbolDisplayPartKind.propertyName),
|
||||
writeSymbol,
|
||||
writeLine,
|
||||
increaseIndent: () => { indent++; },
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
//// [awaitInheritedPromise_es2017.ts]
|
||||
interface A extends Promise<string> {}
|
||||
declare var a: A;
|
||||
async function f() {
|
||||
await a;
|
||||
}
|
||||
|
||||
//// [awaitInheritedPromise_es2017.js]
|
||||
async function f() {
|
||||
await a;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
=== tests/cases/conformance/async/es2017/awaitInheritedPromise_es2017.ts ===
|
||||
interface A extends Promise<string> {}
|
||||
>A : Symbol(A, Decl(awaitInheritedPromise_es2017.ts, 0, 0))
|
||||
>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
|
||||
|
||||
declare var a: A;
|
||||
>a : Symbol(a, Decl(awaitInheritedPromise_es2017.ts, 1, 11))
|
||||
>A : Symbol(A, Decl(awaitInheritedPromise_es2017.ts, 0, 0))
|
||||
|
||||
async function f() {
|
||||
>f : Symbol(f, Decl(awaitInheritedPromise_es2017.ts, 1, 17))
|
||||
|
||||
await a;
|
||||
>a : Symbol(a, Decl(awaitInheritedPromise_es2017.ts, 1, 11))
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
=== tests/cases/conformance/async/es2017/awaitInheritedPromise_es2017.ts ===
|
||||
interface A extends Promise<string> {}
|
||||
>A : A
|
||||
>Promise : Promise<T>
|
||||
|
||||
declare var a: A;
|
||||
>a : A
|
||||
>A : A
|
||||
|
||||
async function f() {
|
||||
>f : () => Promise<void>
|
||||
|
||||
await a;
|
||||
>await a : string
|
||||
>a : A
|
||||
}
|
||||
@@ -208,6 +208,7 @@ function foo() {
|
||||
}
|
||||
(function () { return b; });
|
||||
return { value: 100 };
|
||||
var _a;
|
||||
};
|
||||
for (var _c = 0, _d = []; _c < _d.length; _c++) {
|
||||
var b = _d[_c];
|
||||
@@ -221,6 +222,7 @@ function foo() {
|
||||
}
|
||||
}
|
||||
(function () { return a; });
|
||||
var _b;
|
||||
};
|
||||
var arguments_1 = arguments, x, z, x1, z1;
|
||||
l0: for (var _i = 0, _a = []; _i < _a.length; _i++) {
|
||||
@@ -238,7 +240,6 @@ function foo() {
|
||||
use(z);
|
||||
use(x1);
|
||||
use(z1);
|
||||
var _b, _a;
|
||||
}
|
||||
function foo2() {
|
||||
for (var _i = 0, _a = []; _i < _a.length; _i++) {
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(3,5): error TS2502: 'x' is referenced directly or indirectly in its own type annotation.
|
||||
tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(7,5): error TS2502: 'x' is referenced directly or indirectly in its own type annotation.
|
||||
tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(15,5): error TS2502: 'x' is referenced directly or indirectly in its own type annotation.
|
||||
tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(19,5): error TS2502: 'x' is referenced directly or indirectly in its own type annotation.
|
||||
tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(23,5): error TS2502: 'x' is referenced directly or indirectly in its own type annotation.
|
||||
tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(27,5): error TS2502: 'x' is referenced directly or indirectly in its own type annotation.
|
||||
tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(28,5): error TS2502: 'y' is referenced directly or indirectly in its own type annotation.
|
||||
tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(29,5): error TS2502: 'z' is referenced directly or indirectly in its own type annotation.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts (8 errors) ====
|
||||
|
||||
type T1 = {
|
||||
x: T1["x"]; // Error
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2502: 'x' is referenced directly or indirectly in its own type annotation.
|
||||
};
|
||||
|
||||
type T2<K extends "x" | "y"> = {
|
||||
x: T2<K>[K]; // Error
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS2502: 'x' is referenced directly or indirectly in its own type annotation.
|
||||
y: number;
|
||||
}
|
||||
|
||||
declare let x2: T2<"x">;
|
||||
let x2x = x2.x;
|
||||
|
||||
interface T3<T extends T3<T>> {
|
||||
x: T["x"]; // Error
|
||||
~~~~~~~~~~
|
||||
!!! error TS2502: 'x' is referenced directly or indirectly in its own type annotation.
|
||||
}
|
||||
|
||||
interface T4<T extends T4<T>> {
|
||||
x: T4<T>["x"]; // Error
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS2502: 'x' is referenced directly or indirectly in its own type annotation.
|
||||
}
|
||||
|
||||
class C1 {
|
||||
x: C1["x"]; // Error
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2502: 'x' is referenced directly or indirectly in its own type annotation.
|
||||
}
|
||||
|
||||
class C2 {
|
||||
x: this["y"]; // Error
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2502: 'x' is referenced directly or indirectly in its own type annotation.
|
||||
y: this["z"]; // Error
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2502: 'y' is referenced directly or indirectly in its own type annotation.
|
||||
z: this["x"]; // Error
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2502: 'z' is referenced directly or indirectly in its own type annotation.
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
//// [circularIndexedAccessErrors.ts]
|
||||
|
||||
type T1 = {
|
||||
x: T1["x"]; // Error
|
||||
};
|
||||
|
||||
type T2<K extends "x" | "y"> = {
|
||||
x: T2<K>[K]; // Error
|
||||
y: number;
|
||||
}
|
||||
|
||||
declare let x2: T2<"x">;
|
||||
let x2x = x2.x;
|
||||
|
||||
interface T3<T extends T3<T>> {
|
||||
x: T["x"]; // Error
|
||||
}
|
||||
|
||||
interface T4<T extends T4<T>> {
|
||||
x: T4<T>["x"]; // Error
|
||||
}
|
||||
|
||||
class C1 {
|
||||
x: C1["x"]; // Error
|
||||
}
|
||||
|
||||
class C2 {
|
||||
x: this["y"]; // Error
|
||||
y: this["z"]; // Error
|
||||
z: this["x"]; // Error
|
||||
}
|
||||
|
||||
//// [circularIndexedAccessErrors.js]
|
||||
var x2x = x2.x;
|
||||
var C1 = (function () {
|
||||
function C1() {
|
||||
}
|
||||
return C1;
|
||||
}());
|
||||
var C2 = (function () {
|
||||
function C2() {
|
||||
}
|
||||
return C2;
|
||||
}());
|
||||
|
||||
|
||||
//// [circularIndexedAccessErrors.d.ts]
|
||||
declare type T1 = {
|
||||
x: T1["x"];
|
||||
};
|
||||
declare type T2<K extends "x" | "y"> = {
|
||||
x: T2<K>[K];
|
||||
y: number;
|
||||
};
|
||||
declare let x2: T2<"x">;
|
||||
declare let x2x: any;
|
||||
interface T3<T extends T3<T>> {
|
||||
x: T["x"];
|
||||
}
|
||||
interface T4<T extends T4<T>> {
|
||||
x: T4<T>["x"];
|
||||
}
|
||||
declare class C1 {
|
||||
x: C1["x"];
|
||||
}
|
||||
declare class C2 {
|
||||
x: this["y"];
|
||||
y: this["z"];
|
||||
z: this["x"];
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
//// [tests/cases/compiler/circularReferenceInImport.ts] ////
|
||||
|
||||
//// [db.d.ts]
|
||||
|
||||
declare namespace Db {
|
||||
export import Types = Db;
|
||||
}
|
||||
|
||||
export = Db;
|
||||
|
||||
//// [app.ts]
|
||||
import * as Db from "./db"
|
||||
|
||||
export function foo() {
|
||||
return new Object()
|
||||
}
|
||||
|
||||
//// [app.js]
|
||||
"use strict";
|
||||
function foo() {
|
||||
return new Object();
|
||||
}
|
||||
exports.foo = foo;
|
||||
|
||||
|
||||
//// [app.d.ts]
|
||||
export declare function foo(): Object;
|
||||
@@ -0,0 +1,23 @@
|
||||
=== tests/cases/compiler/db.d.ts ===
|
||||
|
||||
declare namespace Db {
|
||||
>Db : Symbol(Types, Decl(db.d.ts, 0, 0))
|
||||
|
||||
export import Types = Db;
|
||||
>Types : Symbol(Types, Decl(db.d.ts, 1, 22))
|
||||
>Db : Symbol(Types, Decl(db.d.ts, 0, 0))
|
||||
}
|
||||
|
||||
export = Db;
|
||||
>Db : Symbol(Db, Decl(db.d.ts, 0, 0))
|
||||
|
||||
=== tests/cases/compiler/app.ts ===
|
||||
import * as Db from "./db"
|
||||
>Db : Symbol(Db, Decl(app.ts, 0, 6))
|
||||
|
||||
export function foo() {
|
||||
>foo : Symbol(foo, Decl(app.ts, 0, 26))
|
||||
|
||||
return new Object()
|
||||
>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
=== tests/cases/compiler/db.d.ts ===
|
||||
|
||||
declare namespace Db {
|
||||
>Db : typeof Types
|
||||
|
||||
export import Types = Db;
|
||||
>Types : typeof Types
|
||||
>Db : typeof Types
|
||||
}
|
||||
|
||||
export = Db;
|
||||
>Db : typeof Db
|
||||
|
||||
=== tests/cases/compiler/app.ts ===
|
||||
import * as Db from "./db"
|
||||
>Db : typeof Db
|
||||
|
||||
export function foo() {
|
||||
>foo : () => Object
|
||||
|
||||
return new Object()
|
||||
>new Object() : Object
|
||||
>Object : ObjectConstructor
|
||||
}
|
||||
@@ -14,15 +14,11 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
let Testing123 = Testing123_1 = class Testing123 {
|
||||
};
|
||||
Testing123.prop1 = Testing123_1.prop0;
|
||||
Testing123 = Testing123_1 = __decorate([
|
||||
Something({ v: () => Testing123_1 }),
|
||||
__metadata("design:paramtypes", [])
|
||||
Something({ v: () => Testing123_1 })
|
||||
], Testing123);
|
||||
exports.Testing123 = Testing123;
|
||||
var Testing123_1;
|
||||
|
||||
@@ -13,14 +13,10 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
let Testing123 = Testing123_1 = class Testing123 {
|
||||
};
|
||||
Testing123 = Testing123_1 = __decorate([
|
||||
Something({ v: () => Testing123_1 }),
|
||||
__metadata("design:paramtypes", [])
|
||||
Something({ v: () => Testing123_1 })
|
||||
], Testing123);
|
||||
exports.Testing123 = Testing123;
|
||||
var Testing123_1;
|
||||
|
||||
@@ -17,9 +17,6 @@ System.register([], function (exports_1, context_1) {
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var __moduleName = context_1 && context_1.id;
|
||||
var Testing123, Testing123_1;
|
||||
return {
|
||||
@@ -29,8 +26,7 @@ System.register([], function (exports_1, context_1) {
|
||||
};
|
||||
Testing123.prop1 = Testing123_1.prop0;
|
||||
Testing123 = Testing123_1 = __decorate([
|
||||
Something({ v: () => Testing123_1 }),
|
||||
__metadata("design:paramtypes", [])
|
||||
Something({ v: () => Testing123_1 })
|
||||
], Testing123);
|
||||
exports_1("Testing123", Testing123);
|
||||
}
|
||||
|
||||
@@ -14,9 +14,6 @@ System.register([], function (exports_1, context_1) {
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var __moduleName = context_1 && context_1.id;
|
||||
var Testing123, Testing123_1;
|
||||
return {
|
||||
@@ -25,8 +22,7 @@ System.register([], function (exports_1, context_1) {
|
||||
Testing123 = Testing123_1 = class Testing123 {
|
||||
};
|
||||
Testing123 = Testing123_1 = __decorate([
|
||||
Something({ v: () => Testing123_1 }),
|
||||
__metadata("design:paramtypes", [])
|
||||
Something({ v: () => Testing123_1 })
|
||||
], Testing123);
|
||||
exports_1("Testing123", Testing123);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
//// [tests/cases/compiler/decoratorMetadataRestParameterWithImportedType.ts] ////
|
||||
|
||||
//// [aux.ts]
|
||||
|
||||
export class SomeClass {
|
||||
field: string;
|
||||
}
|
||||
|
||||
//// [aux1.ts]
|
||||
export class SomeClass1 {
|
||||
field: string;
|
||||
}
|
||||
|
||||
//// [aux2.ts]
|
||||
export class SomeClass2 {
|
||||
field: string;
|
||||
}
|
||||
//// [main.ts]
|
||||
import { SomeClass } from './aux';
|
||||
import { SomeClass1 } from './aux1';
|
||||
|
||||
function annotation(): ClassDecorator {
|
||||
return (target: any): void => { };
|
||||
}
|
||||
|
||||
function annotation1(): MethodDecorator {
|
||||
return (target: any): void => { };
|
||||
}
|
||||
|
||||
@annotation()
|
||||
export class ClassA {
|
||||
array: SomeClass[];
|
||||
|
||||
constructor(...init: SomeClass[]) {
|
||||
this.array = init;
|
||||
}
|
||||
|
||||
@annotation1()
|
||||
foo(... args: SomeClass1[]) {
|
||||
}
|
||||
}
|
||||
|
||||
//// [aux.js]
|
||||
"use strict";
|
||||
var SomeClass = (function () {
|
||||
function SomeClass() {
|
||||
}
|
||||
return SomeClass;
|
||||
}());
|
||||
exports.SomeClass = SomeClass;
|
||||
//// [aux1.js]
|
||||
"use strict";
|
||||
var SomeClass1 = (function () {
|
||||
function SomeClass1() {
|
||||
}
|
||||
return SomeClass1;
|
||||
}());
|
||||
exports.SomeClass1 = SomeClass1;
|
||||
//// [aux2.js]
|
||||
"use strict";
|
||||
var SomeClass2 = (function () {
|
||||
function SomeClass2() {
|
||||
}
|
||||
return SomeClass2;
|
||||
}());
|
||||
exports.SomeClass2 = SomeClass2;
|
||||
//// [main.js]
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var aux_1 = require("./aux");
|
||||
var aux1_1 = require("./aux1");
|
||||
function annotation() {
|
||||
return function (target) { };
|
||||
}
|
||||
function annotation1() {
|
||||
return function (target) { };
|
||||
}
|
||||
var ClassA = (function () {
|
||||
function ClassA() {
|
||||
var init = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
init[_i] = arguments[_i];
|
||||
}
|
||||
this.array = init;
|
||||
}
|
||||
ClassA.prototype.foo = function () {
|
||||
var args = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
args[_i] = arguments[_i];
|
||||
}
|
||||
};
|
||||
return ClassA;
|
||||
}());
|
||||
__decorate([
|
||||
annotation1(),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [aux1_1.SomeClass1]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], ClassA.prototype, "foo", null);
|
||||
ClassA = __decorate([
|
||||
annotation(),
|
||||
__metadata("design:paramtypes", [aux_1.SomeClass])
|
||||
], ClassA);
|
||||
exports.ClassA = ClassA;
|
||||
@@ -0,0 +1,77 @@
|
||||
=== tests/cases/compiler/aux.ts ===
|
||||
|
||||
export class SomeClass {
|
||||
>SomeClass : Symbol(SomeClass, Decl(aux.ts, 0, 0))
|
||||
|
||||
field: string;
|
||||
>field : Symbol(SomeClass.field, Decl(aux.ts, 1, 24))
|
||||
}
|
||||
|
||||
=== tests/cases/compiler/aux1.ts ===
|
||||
export class SomeClass1 {
|
||||
>SomeClass1 : Symbol(SomeClass1, Decl(aux1.ts, 0, 0))
|
||||
|
||||
field: string;
|
||||
>field : Symbol(SomeClass1.field, Decl(aux1.ts, 0, 25))
|
||||
}
|
||||
|
||||
=== tests/cases/compiler/aux2.ts ===
|
||||
export class SomeClass2 {
|
||||
>SomeClass2 : Symbol(SomeClass2, Decl(aux2.ts, 0, 0))
|
||||
|
||||
field: string;
|
||||
>field : Symbol(SomeClass2.field, Decl(aux2.ts, 0, 25))
|
||||
}
|
||||
=== tests/cases/compiler/main.ts ===
|
||||
import { SomeClass } from './aux';
|
||||
>SomeClass : Symbol(SomeClass, Decl(main.ts, 0, 8))
|
||||
|
||||
import { SomeClass1 } from './aux1';
|
||||
>SomeClass1 : Symbol(SomeClass1, Decl(main.ts, 1, 8))
|
||||
|
||||
function annotation(): ClassDecorator {
|
||||
>annotation : Symbol(annotation, Decl(main.ts, 1, 36))
|
||||
>ClassDecorator : Symbol(ClassDecorator, Decl(lib.d.ts, --, --))
|
||||
|
||||
return (target: any): void => { };
|
||||
>target : Symbol(target, Decl(main.ts, 4, 12))
|
||||
}
|
||||
|
||||
function annotation1(): MethodDecorator {
|
||||
>annotation1 : Symbol(annotation1, Decl(main.ts, 5, 1))
|
||||
>MethodDecorator : Symbol(MethodDecorator, Decl(lib.d.ts, --, --))
|
||||
|
||||
return (target: any): void => { };
|
||||
>target : Symbol(target, Decl(main.ts, 8, 12))
|
||||
}
|
||||
|
||||
@annotation()
|
||||
>annotation : Symbol(annotation, Decl(main.ts, 1, 36))
|
||||
|
||||
export class ClassA {
|
||||
>ClassA : Symbol(ClassA, Decl(main.ts, 9, 1))
|
||||
|
||||
array: SomeClass[];
|
||||
>array : Symbol(ClassA.array, Decl(main.ts, 12, 21))
|
||||
>SomeClass : Symbol(SomeClass, Decl(main.ts, 0, 8))
|
||||
|
||||
constructor(...init: SomeClass[]) {
|
||||
>init : Symbol(init, Decl(main.ts, 15, 16))
|
||||
>SomeClass : Symbol(SomeClass, Decl(main.ts, 0, 8))
|
||||
|
||||
this.array = init;
|
||||
>this.array : Symbol(ClassA.array, Decl(main.ts, 12, 21))
|
||||
>this : Symbol(ClassA, Decl(main.ts, 9, 1))
|
||||
>array : Symbol(ClassA.array, Decl(main.ts, 12, 21))
|
||||
>init : Symbol(init, Decl(main.ts, 15, 16))
|
||||
}
|
||||
|
||||
@annotation1()
|
||||
>annotation1 : Symbol(annotation1, Decl(main.ts, 5, 1))
|
||||
|
||||
foo(... args: SomeClass1[]) {
|
||||
>foo : Symbol(ClassA.foo, Decl(main.ts, 17, 5))
|
||||
>args : Symbol(args, Decl(main.ts, 20, 8))
|
||||
>SomeClass1 : Symbol(SomeClass1, Decl(main.ts, 1, 8))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
=== tests/cases/compiler/aux.ts ===
|
||||
|
||||
export class SomeClass {
|
||||
>SomeClass : SomeClass
|
||||
|
||||
field: string;
|
||||
>field : string
|
||||
}
|
||||
|
||||
=== tests/cases/compiler/aux1.ts ===
|
||||
export class SomeClass1 {
|
||||
>SomeClass1 : SomeClass1
|
||||
|
||||
field: string;
|
||||
>field : string
|
||||
}
|
||||
|
||||
=== tests/cases/compiler/aux2.ts ===
|
||||
export class SomeClass2 {
|
||||
>SomeClass2 : SomeClass2
|
||||
|
||||
field: string;
|
||||
>field : string
|
||||
}
|
||||
=== tests/cases/compiler/main.ts ===
|
||||
import { SomeClass } from './aux';
|
||||
>SomeClass : typeof SomeClass
|
||||
|
||||
import { SomeClass1 } from './aux1';
|
||||
>SomeClass1 : typeof SomeClass1
|
||||
|
||||
function annotation(): ClassDecorator {
|
||||
>annotation : () => ClassDecorator
|
||||
>ClassDecorator : ClassDecorator
|
||||
|
||||
return (target: any): void => { };
|
||||
>(target: any): void => { } : (target: any) => void
|
||||
>target : any
|
||||
}
|
||||
|
||||
function annotation1(): MethodDecorator {
|
||||
>annotation1 : () => MethodDecorator
|
||||
>MethodDecorator : MethodDecorator
|
||||
|
||||
return (target: any): void => { };
|
||||
>(target: any): void => { } : (target: any) => void
|
||||
>target : any
|
||||
}
|
||||
|
||||
@annotation()
|
||||
>annotation() : ClassDecorator
|
||||
>annotation : () => ClassDecorator
|
||||
|
||||
export class ClassA {
|
||||
>ClassA : ClassA
|
||||
|
||||
array: SomeClass[];
|
||||
>array : SomeClass[]
|
||||
>SomeClass : SomeClass
|
||||
|
||||
constructor(...init: SomeClass[]) {
|
||||
>init : SomeClass[]
|
||||
>SomeClass : SomeClass
|
||||
|
||||
this.array = init;
|
||||
>this.array = init : SomeClass[]
|
||||
>this.array : SomeClass[]
|
||||
>this : this
|
||||
>array : SomeClass[]
|
||||
>init : SomeClass[]
|
||||
}
|
||||
|
||||
@annotation1()
|
||||
>annotation1() : MethodDecorator
|
||||
>annotation1 : () => MethodDecorator
|
||||
|
||||
foo(... args: SomeClass1[]) {
|
||||
>foo : (...args: SomeClass1[]) => void
|
||||
>args : SomeClass1[]
|
||||
>SomeClass1 : SomeClass1
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor7.ts(26,5): error TS1207: Decorators cannot be applied to multiple get/set accessors of the same name.
|
||||
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor7.ts(31,5): error TS1207: Decorators cannot be applied to multiple get/set accessors of the same name.
|
||||
|
||||
|
||||
==== tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor7.ts (2 errors) ====
|
||||
declare function dec1<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
|
||||
declare function dec2<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
|
||||
|
||||
class A {
|
||||
@dec1 get x() { return 0; }
|
||||
set x(value: number) { }
|
||||
}
|
||||
|
||||
class B {
|
||||
get x() { return 0; }
|
||||
@dec2 set x(value: number) { }
|
||||
}
|
||||
|
||||
class C {
|
||||
@dec1 set x(value: number) { }
|
||||
get x() { return 0; }
|
||||
}
|
||||
|
||||
class D {
|
||||
set x(value: number) { }
|
||||
@dec2 get x() { return 0; }
|
||||
}
|
||||
|
||||
class E {
|
||||
@dec1 get x() { return 0; }
|
||||
@dec2 set x(value: number) { }
|
||||
~
|
||||
!!! error TS1207: Decorators cannot be applied to multiple get/set accessors of the same name.
|
||||
}
|
||||
|
||||
class F {
|
||||
@dec1 set x(value: number) { }
|
||||
@dec2 get x() { return 0; }
|
||||
~
|
||||
!!! error TS1207: Decorators cannot be applied to multiple get/set accessors of the same name.
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
//// [decoratorOnClassAccessor7.ts]
|
||||
declare function dec1<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
|
||||
declare function dec2<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
|
||||
|
||||
class A {
|
||||
@dec1 get x() { return 0; }
|
||||
set x(value: number) { }
|
||||
}
|
||||
|
||||
class B {
|
||||
get x() { return 0; }
|
||||
@dec2 set x(value: number) { }
|
||||
}
|
||||
|
||||
class C {
|
||||
@dec1 set x(value: number) { }
|
||||
get x() { return 0; }
|
||||
}
|
||||
|
||||
class D {
|
||||
set x(value: number) { }
|
||||
@dec2 get x() { return 0; }
|
||||
}
|
||||
|
||||
class E {
|
||||
@dec1 get x() { return 0; }
|
||||
@dec2 set x(value: number) { }
|
||||
}
|
||||
|
||||
class F {
|
||||
@dec1 set x(value: number) { }
|
||||
@dec2 get x() { return 0; }
|
||||
}
|
||||
|
||||
//// [decoratorOnClassAccessor7.js]
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var A = (function () {
|
||||
function A() {
|
||||
}
|
||||
Object.defineProperty(A.prototype, "x", {
|
||||
get: function () { return 0; },
|
||||
set: function (value) { },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
return A;
|
||||
}());
|
||||
__decorate([
|
||||
dec1
|
||||
], A.prototype, "x", null);
|
||||
var B = (function () {
|
||||
function B() {
|
||||
}
|
||||
Object.defineProperty(B.prototype, "x", {
|
||||
get: function () { return 0; },
|
||||
set: function (value) { },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
return B;
|
||||
}());
|
||||
__decorate([
|
||||
dec2
|
||||
], B.prototype, "x", null);
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
Object.defineProperty(C.prototype, "x", {
|
||||
get: function () { return 0; },
|
||||
set: function (value) { },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
return C;
|
||||
}());
|
||||
__decorate([
|
||||
dec1
|
||||
], C.prototype, "x", null);
|
||||
var D = (function () {
|
||||
function D() {
|
||||
}
|
||||
Object.defineProperty(D.prototype, "x", {
|
||||
get: function () { return 0; },
|
||||
set: function (value) { },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
return D;
|
||||
}());
|
||||
__decorate([
|
||||
dec2
|
||||
], D.prototype, "x", null);
|
||||
var E = (function () {
|
||||
function E() {
|
||||
}
|
||||
Object.defineProperty(E.prototype, "x", {
|
||||
get: function () { return 0; },
|
||||
set: function (value) { },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
return E;
|
||||
}());
|
||||
__decorate([
|
||||
dec1
|
||||
], E.prototype, "x", null);
|
||||
var F = (function () {
|
||||
function F() {
|
||||
}
|
||||
Object.defineProperty(F.prototype, "x", {
|
||||
get: function () { return 0; },
|
||||
set: function (value) { },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
return F;
|
||||
}());
|
||||
__decorate([
|
||||
dec1
|
||||
], F.prototype, "x", null);
|
||||
@@ -0,0 +1,135 @@
|
||||
//// [decoratorOnClassAccessor8.ts]
|
||||
declare function dec<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
|
||||
|
||||
class A {
|
||||
@dec get x() { return 0; }
|
||||
set x(value: number) { }
|
||||
}
|
||||
|
||||
class B {
|
||||
get x() { return 0; }
|
||||
@dec set x(value: number) { }
|
||||
}
|
||||
|
||||
class C {
|
||||
@dec set x(value: number) { }
|
||||
get x() { return 0; }
|
||||
}
|
||||
|
||||
class D {
|
||||
set x(value: number) { }
|
||||
@dec get x() { return 0; }
|
||||
}
|
||||
|
||||
class E {
|
||||
@dec get x() { return 0; }
|
||||
}
|
||||
|
||||
class F {
|
||||
@dec set x(value: number) { }
|
||||
}
|
||||
|
||||
//// [decoratorOnClassAccessor8.js]
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var A = (function () {
|
||||
function A() {
|
||||
}
|
||||
Object.defineProperty(A.prototype, "x", {
|
||||
get: function () { return 0; },
|
||||
set: function (value) { },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
return A;
|
||||
}());
|
||||
__decorate([
|
||||
dec,
|
||||
__metadata("design:type", Object),
|
||||
__metadata("design:paramtypes", [Number])
|
||||
], A.prototype, "x", null);
|
||||
var B = (function () {
|
||||
function B() {
|
||||
}
|
||||
Object.defineProperty(B.prototype, "x", {
|
||||
get: function () { return 0; },
|
||||
set: function (value) { },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
return B;
|
||||
}());
|
||||
__decorate([
|
||||
dec,
|
||||
__metadata("design:type", Number),
|
||||
__metadata("design:paramtypes", [Number])
|
||||
], B.prototype, "x", null);
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
Object.defineProperty(C.prototype, "x", {
|
||||
get: function () { return 0; },
|
||||
set: function (value) { },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
return C;
|
||||
}());
|
||||
__decorate([
|
||||
dec,
|
||||
__metadata("design:type", Number),
|
||||
__metadata("design:paramtypes", [Number])
|
||||
], C.prototype, "x", null);
|
||||
var D = (function () {
|
||||
function D() {
|
||||
}
|
||||
Object.defineProperty(D.prototype, "x", {
|
||||
get: function () { return 0; },
|
||||
set: function (value) { },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
return D;
|
||||
}());
|
||||
__decorate([
|
||||
dec,
|
||||
__metadata("design:type", Object),
|
||||
__metadata("design:paramtypes", [Number])
|
||||
], D.prototype, "x", null);
|
||||
var E = (function () {
|
||||
function E() {
|
||||
}
|
||||
Object.defineProperty(E.prototype, "x", {
|
||||
get: function () { return 0; },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
return E;
|
||||
}());
|
||||
__decorate([
|
||||
dec,
|
||||
__metadata("design:type", Object),
|
||||
__metadata("design:paramtypes", [])
|
||||
], E.prototype, "x", null);
|
||||
var F = (function () {
|
||||
function F() {
|
||||
}
|
||||
Object.defineProperty(F.prototype, "x", {
|
||||
set: function (value) { },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
return F;
|
||||
}());
|
||||
__decorate([
|
||||
dec,
|
||||
__metadata("design:type", Number),
|
||||
__metadata("design:paramtypes", [Number])
|
||||
], F.prototype, "x", null);
|
||||
@@ -0,0 +1,76 @@
|
||||
=== tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor8.ts ===
|
||||
declare function dec<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
|
||||
>dec : Symbol(dec, Decl(decoratorOnClassAccessor8.ts, 0, 0))
|
||||
>T : Symbol(T, Decl(decoratorOnClassAccessor8.ts, 0, 21))
|
||||
>target : Symbol(target, Decl(decoratorOnClassAccessor8.ts, 0, 24))
|
||||
>propertyKey : Symbol(propertyKey, Decl(decoratorOnClassAccessor8.ts, 0, 36))
|
||||
>descriptor : Symbol(descriptor, Decl(decoratorOnClassAccessor8.ts, 0, 57))
|
||||
>TypedPropertyDescriptor : Symbol(TypedPropertyDescriptor, Decl(lib.d.ts, --, --))
|
||||
>T : Symbol(T, Decl(decoratorOnClassAccessor8.ts, 0, 21))
|
||||
>TypedPropertyDescriptor : Symbol(TypedPropertyDescriptor, Decl(lib.d.ts, --, --))
|
||||
>T : Symbol(T, Decl(decoratorOnClassAccessor8.ts, 0, 21))
|
||||
|
||||
class A {
|
||||
>A : Symbol(A, Decl(decoratorOnClassAccessor8.ts, 0, 126))
|
||||
|
||||
@dec get x() { return 0; }
|
||||
>dec : Symbol(dec, Decl(decoratorOnClassAccessor8.ts, 0, 0))
|
||||
>x : Symbol(A.x, Decl(decoratorOnClassAccessor8.ts, 2, 9), Decl(decoratorOnClassAccessor8.ts, 3, 30))
|
||||
|
||||
set x(value: number) { }
|
||||
>x : Symbol(A.x, Decl(decoratorOnClassAccessor8.ts, 2, 9), Decl(decoratorOnClassAccessor8.ts, 3, 30))
|
||||
>value : Symbol(value, Decl(decoratorOnClassAccessor8.ts, 4, 10))
|
||||
}
|
||||
|
||||
class B {
|
||||
>B : Symbol(B, Decl(decoratorOnClassAccessor8.ts, 5, 1))
|
||||
|
||||
get x() { return 0; }
|
||||
>x : Symbol(B.x, Decl(decoratorOnClassAccessor8.ts, 7, 9), Decl(decoratorOnClassAccessor8.ts, 8, 25))
|
||||
|
||||
@dec set x(value: number) { }
|
||||
>dec : Symbol(dec, Decl(decoratorOnClassAccessor8.ts, 0, 0))
|
||||
>x : Symbol(B.x, Decl(decoratorOnClassAccessor8.ts, 7, 9), Decl(decoratorOnClassAccessor8.ts, 8, 25))
|
||||
>value : Symbol(value, Decl(decoratorOnClassAccessor8.ts, 9, 15))
|
||||
}
|
||||
|
||||
class C {
|
||||
>C : Symbol(C, Decl(decoratorOnClassAccessor8.ts, 10, 1))
|
||||
|
||||
@dec set x(value: number) { }
|
||||
>dec : Symbol(dec, Decl(decoratorOnClassAccessor8.ts, 0, 0))
|
||||
>x : Symbol(C.x, Decl(decoratorOnClassAccessor8.ts, 12, 9), Decl(decoratorOnClassAccessor8.ts, 13, 33))
|
||||
>value : Symbol(value, Decl(decoratorOnClassAccessor8.ts, 13, 15))
|
||||
|
||||
get x() { return 0; }
|
||||
>x : Symbol(C.x, Decl(decoratorOnClassAccessor8.ts, 12, 9), Decl(decoratorOnClassAccessor8.ts, 13, 33))
|
||||
}
|
||||
|
||||
class D {
|
||||
>D : Symbol(D, Decl(decoratorOnClassAccessor8.ts, 15, 1))
|
||||
|
||||
set x(value: number) { }
|
||||
>x : Symbol(D.x, Decl(decoratorOnClassAccessor8.ts, 17, 9), Decl(decoratorOnClassAccessor8.ts, 18, 28))
|
||||
>value : Symbol(value, Decl(decoratorOnClassAccessor8.ts, 18, 10))
|
||||
|
||||
@dec get x() { return 0; }
|
||||
>dec : Symbol(dec, Decl(decoratorOnClassAccessor8.ts, 0, 0))
|
||||
>x : Symbol(D.x, Decl(decoratorOnClassAccessor8.ts, 17, 9), Decl(decoratorOnClassAccessor8.ts, 18, 28))
|
||||
}
|
||||
|
||||
class E {
|
||||
>E : Symbol(E, Decl(decoratorOnClassAccessor8.ts, 20, 1))
|
||||
|
||||
@dec get x() { return 0; }
|
||||
>dec : Symbol(dec, Decl(decoratorOnClassAccessor8.ts, 0, 0))
|
||||
>x : Symbol(E.x, Decl(decoratorOnClassAccessor8.ts, 22, 9))
|
||||
}
|
||||
|
||||
class F {
|
||||
>F : Symbol(F, Decl(decoratorOnClassAccessor8.ts, 24, 1))
|
||||
|
||||
@dec set x(value: number) { }
|
||||
>dec : Symbol(dec, Decl(decoratorOnClassAccessor8.ts, 0, 0))
|
||||
>x : Symbol(F.x, Decl(decoratorOnClassAccessor8.ts, 26, 9))
|
||||
>value : Symbol(value, Decl(decoratorOnClassAccessor8.ts, 27, 15))
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
=== tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor8.ts ===
|
||||
declare function dec<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
|
||||
>dec : <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>
|
||||
>T : T
|
||||
>target : any
|
||||
>propertyKey : string
|
||||
>descriptor : TypedPropertyDescriptor<T>
|
||||
>TypedPropertyDescriptor : TypedPropertyDescriptor<T>
|
||||
>T : T
|
||||
>TypedPropertyDescriptor : TypedPropertyDescriptor<T>
|
||||
>T : T
|
||||
|
||||
class A {
|
||||
>A : A
|
||||
|
||||
@dec get x() { return 0; }
|
||||
>dec : <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>
|
||||
>x : number
|
||||
>0 : 0
|
||||
|
||||
set x(value: number) { }
|
||||
>x : number
|
||||
>value : number
|
||||
}
|
||||
|
||||
class B {
|
||||
>B : B
|
||||
|
||||
get x() { return 0; }
|
||||
>x : number
|
||||
>0 : 0
|
||||
|
||||
@dec set x(value: number) { }
|
||||
>dec : <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>
|
||||
>x : number
|
||||
>value : number
|
||||
}
|
||||
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
@dec set x(value: number) { }
|
||||
>dec : <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>
|
||||
>x : number
|
||||
>value : number
|
||||
|
||||
get x() { return 0; }
|
||||
>x : number
|
||||
>0 : 0
|
||||
}
|
||||
|
||||
class D {
|
||||
>D : D
|
||||
|
||||
set x(value: number) { }
|
||||
>x : number
|
||||
>value : number
|
||||
|
||||
@dec get x() { return 0; }
|
||||
>dec : <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>
|
||||
>x : number
|
||||
>0 : 0
|
||||
}
|
||||
|
||||
class E {
|
||||
>E : E
|
||||
|
||||
@dec get x() { return 0; }
|
||||
>dec : <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>
|
||||
>x : number
|
||||
>0 : 0
|
||||
}
|
||||
|
||||
class F {
|
||||
>F : F
|
||||
|
||||
@dec set x(value: number) { }
|
||||
>dec : <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>
|
||||
>x : number
|
||||
>value : number
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
//// [decoratorOnClassConstructor4.ts]
|
||||
declare var dec: any;
|
||||
|
||||
@dec
|
||||
class A {
|
||||
}
|
||||
|
||||
@dec
|
||||
class B {
|
||||
constructor(x: number) {}
|
||||
}
|
||||
|
||||
@dec
|
||||
class C extends A {
|
||||
}
|
||||
|
||||
//// [decoratorOnClassConstructor4.js]
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var A = (function () {
|
||||
function A() {
|
||||
}
|
||||
return A;
|
||||
}());
|
||||
A = __decorate([
|
||||
dec
|
||||
], A);
|
||||
var B = (function () {
|
||||
function B(x) {
|
||||
}
|
||||
return B;
|
||||
}());
|
||||
B = __decorate([
|
||||
dec,
|
||||
__metadata("design:paramtypes", [Number])
|
||||
], B);
|
||||
var C = (function (_super) {
|
||||
__extends(C, _super);
|
||||
function C() {
|
||||
return _super.apply(this, arguments) || this;
|
||||
}
|
||||
return C;
|
||||
}(A));
|
||||
C = __decorate([
|
||||
dec
|
||||
], C);
|
||||
@@ -0,0 +1,28 @@
|
||||
=== tests/cases/conformance/decorators/class/constructor/decoratorOnClassConstructor4.ts ===
|
||||
declare var dec: any;
|
||||
>dec : Symbol(dec, Decl(decoratorOnClassConstructor4.ts, 0, 11))
|
||||
|
||||
@dec
|
||||
>dec : Symbol(dec, Decl(decoratorOnClassConstructor4.ts, 0, 11))
|
||||
|
||||
class A {
|
||||
>A : Symbol(A, Decl(decoratorOnClassConstructor4.ts, 0, 21))
|
||||
}
|
||||
|
||||
@dec
|
||||
>dec : Symbol(dec, Decl(decoratorOnClassConstructor4.ts, 0, 11))
|
||||
|
||||
class B {
|
||||
>B : Symbol(B, Decl(decoratorOnClassConstructor4.ts, 4, 1))
|
||||
|
||||
constructor(x: number) {}
|
||||
>x : Symbol(x, Decl(decoratorOnClassConstructor4.ts, 8, 16))
|
||||
}
|
||||
|
||||
@dec
|
||||
>dec : Symbol(dec, Decl(decoratorOnClassConstructor4.ts, 0, 11))
|
||||
|
||||
class C extends A {
|
||||
>C : Symbol(C, Decl(decoratorOnClassConstructor4.ts, 9, 1))
|
||||
>A : Symbol(A, Decl(decoratorOnClassConstructor4.ts, 0, 21))
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
=== tests/cases/conformance/decorators/class/constructor/decoratorOnClassConstructor4.ts ===
|
||||
declare var dec: any;
|
||||
>dec : any
|
||||
|
||||
@dec
|
||||
>dec : any
|
||||
|
||||
class A {
|
||||
>A : A
|
||||
}
|
||||
|
||||
@dec
|
||||
>dec : any
|
||||
|
||||
class B {
|
||||
>B : B
|
||||
|
||||
constructor(x: number) {}
|
||||
>x : number
|
||||
}
|
||||
|
||||
@dec
|
||||
>dec : any
|
||||
|
||||
class C extends A {
|
||||
>C : C
|
||||
>A : A
|
||||
}
|
||||
@@ -7,6 +7,7 @@ tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(26,9): error T
|
||||
tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(30,16): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
|
||||
tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(34,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
|
||||
tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(38,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
|
||||
tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(46,9): error TS17011: 'super' must be called before accessing a property of 'super' in the constructor of a derived class.
|
||||
tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(46,14): error TS1034: 'super' must be followed by an argument list or member access.
|
||||
tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(58,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
|
||||
tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(62,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
|
||||
@@ -14,7 +15,7 @@ tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(67,9): error T
|
||||
tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(71,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors.
|
||||
|
||||
|
||||
==== tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts (14 errors) ====
|
||||
==== tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts (15 errors) ====
|
||||
//super call in class constructor with no base type
|
||||
class NoBase {
|
||||
constructor() {
|
||||
@@ -79,6 +80,8 @@ tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(71,9): error T
|
||||
//super call with type arguments
|
||||
constructor() {
|
||||
super<string>();
|
||||
~~~~~
|
||||
!!! error TS17011: 'super' must be called before accessing a property of 'super' in the constructor of a derived class.
|
||||
~
|
||||
!!! error TS1034: 'super' must be followed by an argument list or member access.
|
||||
super();
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
//// [explicitAnyAfterSpreadNoImplicitAnyError.ts]
|
||||
({ a: [], ...(null as any) });
|
||||
let x: any;
|
||||
|
||||
|
||||
//// [explicitAnyAfterSpreadNoImplicitAnyError.js]
|
||||
var __assign = (this && this.__assign) || Object.assign || function(t) {
|
||||
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
||||
s = arguments[i];
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
||||
t[p] = s[p];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
(__assign({ a: [] }, null));
|
||||
var x;
|
||||
@@ -0,0 +1,7 @@
|
||||
=== tests/cases/compiler/explicitAnyAfterSpreadNoImplicitAnyError.ts ===
|
||||
({ a: [], ...(null as any) });
|
||||
>a : Symbol(a, Decl(explicitAnyAfterSpreadNoImplicitAnyError.ts, 0, 2))
|
||||
|
||||
let x: any;
|
||||
>x : Symbol(x, Decl(explicitAnyAfterSpreadNoImplicitAnyError.ts, 1, 3))
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
=== tests/cases/compiler/explicitAnyAfterSpreadNoImplicitAnyError.ts ===
|
||||
({ a: [], ...(null as any) });
|
||||
>({ a: [], ...(null as any) }) : any
|
||||
>{ a: [], ...(null as any) } : any
|
||||
>a : undefined[]
|
||||
>[] : undefined[]
|
||||
>(null as any) : any
|
||||
>null as any : any
|
||||
>null : null
|
||||
|
||||
let x: any;
|
||||
>x : any
|
||||
|
||||
@@ -64,8 +64,7 @@ tslib_1.__decorate([
|
||||
tslib_1.__metadata("design:returntype", void 0)
|
||||
], C.prototype, "method", null);
|
||||
C = tslib_1.__decorate([
|
||||
dec,
|
||||
tslib_1.__metadata("design:paramtypes", [])
|
||||
dec
|
||||
], C);
|
||||
//// [script.js]
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
@@ -111,6 +110,5 @@ __decorate([
|
||||
__metadata("design:returntype", void 0)
|
||||
], C.prototype, "method", null);
|
||||
C = __decorate([
|
||||
dec,
|
||||
__metadata("design:paramtypes", [])
|
||||
dec
|
||||
], C);
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
=== tests/cases/compiler/declaration.d.ts ===
|
||||
export declare class D {
|
||||
>D : Symbol(D, Decl(declaration.d.ts, 0, 0))
|
||||
}
|
||||
export declare class E extends D {
|
||||
>E : Symbol(E, Decl(declaration.d.ts, 1, 1))
|
||||
>D : Symbol(D, Decl(declaration.d.ts, 0, 0))
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
=== tests/cases/compiler/declaration.d.ts ===
|
||||
export declare class D {
|
||||
>D : D
|
||||
}
|
||||
export declare class E extends D {
|
||||
>E : E
|
||||
>D : D
|
||||
}
|
||||
@@ -64,8 +64,7 @@ tslib_1.__decorate([
|
||||
tslib_1.__metadata("design:returntype", void 0)
|
||||
], C.prototype, "method", null);
|
||||
C = tslib_1.__decorate([
|
||||
dec,
|
||||
tslib_1.__metadata("design:paramtypes", [])
|
||||
dec
|
||||
], C);
|
||||
//// [script.js]
|
||||
"use strict";
|
||||
@@ -96,6 +95,5 @@ tslib_1.__decorate([
|
||||
tslib_1.__metadata("design:returntype", void 0)
|
||||
], C.prototype, "method", null);
|
||||
C = tslib_1.__decorate([
|
||||
dec,
|
||||
tslib_1.__metadata("design:paramtypes", [])
|
||||
dec
|
||||
], C);
|
||||
|
||||
@@ -63,8 +63,7 @@ tslib_1.__decorate([
|
||||
tslib_1.__metadata("design:returntype", void 0)
|
||||
], C.prototype, "method", null);
|
||||
C = tslib_1.__decorate([
|
||||
dec,
|
||||
tslib_1.__metadata("design:paramtypes", [])
|
||||
dec
|
||||
], C);
|
||||
var o = { a: 1 };
|
||||
var y = tslib_1.__assign({}, o);
|
||||
@@ -113,6 +112,5 @@ __decorate([
|
||||
__metadata("design:returntype", void 0)
|
||||
], C.prototype, "method", null);
|
||||
C = __decorate([
|
||||
dec,
|
||||
__metadata("design:paramtypes", [])
|
||||
dec
|
||||
], C);
|
||||
|
||||
@@ -56,8 +56,7 @@ tslib_1.__decorate([
|
||||
tslib_1.__metadata("design:returntype", void 0)
|
||||
], C.prototype, "method", null);
|
||||
C = tslib_1.__decorate([
|
||||
dec,
|
||||
tslib_1.__metadata("design:paramtypes", [])
|
||||
dec
|
||||
], C);
|
||||
//// [script.js]
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
@@ -103,6 +102,5 @@ __decorate([
|
||||
__metadata("design:returntype", void 0)
|
||||
], C.prototype, "method", null);
|
||||
C = __decorate([
|
||||
dec,
|
||||
__metadata("design:paramtypes", [])
|
||||
dec
|
||||
], C);
|
||||
|
||||
@@ -143,7 +143,14 @@ var g1 = applySpec({
|
||||
});
|
||||
|
||||
// Infers g2: (...args: any[]) => { foo: { bar: { baz: boolean } } }
|
||||
var g2 = applySpec({ foo: { bar: { baz: (x: any) => true } } });
|
||||
var g2 = applySpec({ foo: { bar: { baz: (x: any) => true } } });
|
||||
|
||||
// Repro from #12633
|
||||
|
||||
const foo = <T>(object: T, partial: Partial<T>) => object;
|
||||
let o = {a: 5, b: 7};
|
||||
foo(o, {b: 9});
|
||||
o = foo(o, {b: 9});
|
||||
|
||||
//// [isomorphicMappedTypeInference.js]
|
||||
function box(x) {
|
||||
@@ -244,6 +251,11 @@ var g1 = applySpec({
|
||||
});
|
||||
// Infers g2: (...args: any[]) => { foo: { bar: { baz: boolean } } }
|
||||
var g2 = applySpec({ foo: { bar: { baz: function (x) { return true; } } } });
|
||||
// Repro from #12633
|
||||
var foo = function (object, partial) { return object; };
|
||||
var o = { a: 5, b: 7 };
|
||||
foo(o, { b: 9 });
|
||||
o = foo(o, { b: 9 });
|
||||
|
||||
|
||||
//// [isomorphicMappedTypeInference.d.ts]
|
||||
@@ -311,3 +323,8 @@ declare var g2: (...args: any[]) => {
|
||||
};
|
||||
};
|
||||
};
|
||||
declare const foo: <T>(object: T, partial: Partial<T>) => T;
|
||||
declare let o: {
|
||||
a: number;
|
||||
b: number;
|
||||
};
|
||||
|
||||
@@ -459,3 +459,31 @@ var g2 = applySpec({ foo: { bar: { baz: (x: any) => true } } });
|
||||
>baz : Symbol(baz, Decl(isomorphicMappedTypeInference.ts, 144, 34))
|
||||
>x : Symbol(x, Decl(isomorphicMappedTypeInference.ts, 144, 41))
|
||||
|
||||
// Repro from #12633
|
||||
|
||||
const foo = <T>(object: T, partial: Partial<T>) => object;
|
||||
>foo : Symbol(foo, Decl(isomorphicMappedTypeInference.ts, 148, 5))
|
||||
>T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 148, 13))
|
||||
>object : Symbol(object, Decl(isomorphicMappedTypeInference.ts, 148, 16))
|
||||
>T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 148, 13))
|
||||
>partial : Symbol(partial, Decl(isomorphicMappedTypeInference.ts, 148, 26))
|
||||
>Partial : Symbol(Partial, Decl(lib.d.ts, --, --))
|
||||
>T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 148, 13))
|
||||
>object : Symbol(object, Decl(isomorphicMappedTypeInference.ts, 148, 16))
|
||||
|
||||
let o = {a: 5, b: 7};
|
||||
>o : Symbol(o, Decl(isomorphicMappedTypeInference.ts, 149, 3))
|
||||
>a : Symbol(a, Decl(isomorphicMappedTypeInference.ts, 149, 9))
|
||||
>b : Symbol(b, Decl(isomorphicMappedTypeInference.ts, 149, 14))
|
||||
|
||||
foo(o, {b: 9});
|
||||
>foo : Symbol(foo, Decl(isomorphicMappedTypeInference.ts, 148, 5))
|
||||
>o : Symbol(o, Decl(isomorphicMappedTypeInference.ts, 149, 3))
|
||||
>b : Symbol(b, Decl(isomorphicMappedTypeInference.ts, 150, 8))
|
||||
|
||||
o = foo(o, {b: 9});
|
||||
>o : Symbol(o, Decl(isomorphicMappedTypeInference.ts, 149, 3))
|
||||
>foo : Symbol(foo, Decl(isomorphicMappedTypeInference.ts, 148, 5))
|
||||
>o : Symbol(o, Decl(isomorphicMappedTypeInference.ts, 149, 3))
|
||||
>b : Symbol(b, Decl(isomorphicMappedTypeInference.ts, 151, 12))
|
||||
|
||||
|
||||
@@ -546,3 +546,42 @@ var g2 = applySpec({ foo: { bar: { baz: (x: any) => true } } });
|
||||
>x : any
|
||||
>true : true
|
||||
|
||||
// Repro from #12633
|
||||
|
||||
const foo = <T>(object: T, partial: Partial<T>) => object;
|
||||
>foo : <T>(object: T, partial: Partial<T>) => T
|
||||
><T>(object: T, partial: Partial<T>) => object : <T>(object: T, partial: Partial<T>) => T
|
||||
>T : T
|
||||
>object : T
|
||||
>T : T
|
||||
>partial : Partial<T>
|
||||
>Partial : Partial<T>
|
||||
>T : T
|
||||
>object : T
|
||||
|
||||
let o = {a: 5, b: 7};
|
||||
>o : { a: number; b: number; }
|
||||
>{a: 5, b: 7} : { a: number; b: number; }
|
||||
>a : number
|
||||
>5 : 5
|
||||
>b : number
|
||||
>7 : 7
|
||||
|
||||
foo(o, {b: 9});
|
||||
>foo(o, {b: 9}) : { a: number; b: number; }
|
||||
>foo : <T>(object: T, partial: Partial<T>) => T
|
||||
>o : { a: number; b: number; }
|
||||
>{b: 9} : { b: number; }
|
||||
>b : number
|
||||
>9 : 9
|
||||
|
||||
o = foo(o, {b: 9});
|
||||
>o = foo(o, {b: 9}) : { a: number; b: number; }
|
||||
>o : { a: number; b: number; }
|
||||
>foo(o, {b: 9}) : { a: number; b: number; }
|
||||
>foo : <T>(object: T, partial: Partial<T>) => T
|
||||
>o : { a: number; b: number; }
|
||||
>{b: 9} : { b: number; }
|
||||
>b : number
|
||||
>9 : 9
|
||||
|
||||
|
||||
@@ -219,6 +219,83 @@ function f60<T>(source: T, target: T) {
|
||||
}
|
||||
}
|
||||
|
||||
function f70(func: <T, U>(k1: keyof (T | U), k2: keyof (T & U)) => void) {
|
||||
func<{ a: any, b: any }, { a: any, c: any }>('a', 'a');
|
||||
func<{ a: any, b: any }, { a: any, c: any }>('a', 'b');
|
||||
func<{ a: any, b: any }, { a: any, c: any }>('a', 'c');
|
||||
}
|
||||
|
||||
function f71(func: <T, U>(x: T, y: U) => Partial<T & U>) {
|
||||
let x = func({ a: 1, b: "hello" }, { c: true });
|
||||
x.a; // number | undefined
|
||||
x.b; // string | undefined
|
||||
x.c; // boolean | undefined
|
||||
}
|
||||
|
||||
function f72(func: <T, U, K extends keyof T | keyof U>(x: T, y: U, k: K) => (T & U)[K]) {
|
||||
let a = func({ a: 1, b: "hello" }, { c: true }, 'a'); // number
|
||||
let b = func({ a: 1, b: "hello" }, { c: true }, 'b'); // string
|
||||
let c = func({ a: 1, b: "hello" }, { c: true }, 'c'); // boolean
|
||||
}
|
||||
|
||||
function f73(func: <T, U, K extends keyof (T & U)>(x: T, y: U, k: K) => (T & U)[K]) {
|
||||
let a = func({ a: 1, b: "hello" }, { c: true }, 'a'); // number
|
||||
let b = func({ a: 1, b: "hello" }, { c: true }, 'b'); // string
|
||||
let c = func({ a: 1, b: "hello" }, { c: true }, 'c'); // boolean
|
||||
}
|
||||
|
||||
function f74(func: <T, U, K extends keyof (T | U)>(x: T, y: U, k: K) => (T | U)[K]) {
|
||||
let a = func({ a: 1, b: "hello" }, { a: 2, b: true }, 'a'); // number
|
||||
let b = func({ a: 1, b: "hello" }, { a: 2, b: true }, 'b'); // string | boolean
|
||||
}
|
||||
|
||||
function f80<T extends { a: { x: any } }>(obj: T) {
|
||||
let a1 = obj.a; // { x: any }
|
||||
let a2 = obj['a']; // { x: any }
|
||||
let a3 = obj['a'] as T['a']; // T["a"]
|
||||
let x1 = obj.a.x; // any
|
||||
let x2 = obj['a']['x']; // any
|
||||
let x3 = obj['a']['x'] as T['a']['x']; // T["a"]["x"]
|
||||
}
|
||||
|
||||
function f81<T extends { a: { x: any } }>(obj: T) {
|
||||
return obj['a']['x'] as T['a']['x'];
|
||||
}
|
||||
|
||||
function f82() {
|
||||
let x1 = f81({ a: { x: "hello" } }); // string
|
||||
let x2 = f81({ a: { x: 42 } }); // number
|
||||
}
|
||||
|
||||
function f83<T extends { [x: string]: { x: any } }, K extends keyof T>(obj: T, key: K) {
|
||||
return obj[key]['x'] as T[K]['x'];
|
||||
}
|
||||
|
||||
function f84() {
|
||||
let x1 = f83({ foo: { x: "hello" } }, "foo"); // string
|
||||
let x2 = f83({ bar: { x: 42 } }, "bar"); // number
|
||||
}
|
||||
|
||||
class C1 {
|
||||
x: number;
|
||||
get<K extends keyof this>(key: K) {
|
||||
return this[key];
|
||||
}
|
||||
set<K extends keyof this>(key: K, value: this[K]) {
|
||||
this[key] = value;
|
||||
}
|
||||
foo() {
|
||||
let x1 = this.x; // number
|
||||
let x2 = this["x"]; // number
|
||||
let x3 = this.get("x"); // this["x"]
|
||||
let x4 = getProperty(this, "x"); // this["x"]
|
||||
this.x = 42;
|
||||
this["x"] = 42;
|
||||
this.set("x", 42);
|
||||
setProperty(this, "x", 42);
|
||||
}
|
||||
}
|
||||
|
||||
// Repros from #12011
|
||||
|
||||
class Base {
|
||||
@@ -291,7 +368,68 @@ var empty = one(() => {}) // inferred as {}, expected
|
||||
type Handlers<T> = { [K in keyof T]: (t: T[K]) => void }
|
||||
declare function on<T>(handlerHash: Handlers<T>): T
|
||||
var hashOfEmpty1 = on({ test: () => {} }); // {}
|
||||
var hashOfEmpty2 = on({ test: (x: boolean) => {} }); // { test: boolean }
|
||||
var hashOfEmpty2 = on({ test: (x: boolean) => {} }); // { test: boolean }
|
||||
|
||||
// Repro from #12624
|
||||
|
||||
interface Options1<Data, Computed> {
|
||||
data?: Data
|
||||
computed?: Computed;
|
||||
}
|
||||
|
||||
declare class Component1<Data, Computed> {
|
||||
constructor(options: Options1<Data, Computed>);
|
||||
get<K extends keyof (Data & Computed)>(key: K): (Data & Computed)[K];
|
||||
}
|
||||
|
||||
let c1 = new Component1({
|
||||
data: {
|
||||
hello: ""
|
||||
}
|
||||
});
|
||||
|
||||
c1.get("hello");
|
||||
|
||||
// Repro from #12625
|
||||
|
||||
interface Options2<Data, Computed> {
|
||||
data?: Data
|
||||
computed?: Computed;
|
||||
}
|
||||
|
||||
declare class Component2<Data, Computed> {
|
||||
constructor(options: Options2<Data, Computed>);
|
||||
get<K extends keyof Data | keyof Computed>(key: K): (Data & Computed)[K];
|
||||
}
|
||||
|
||||
// Repro from #12641
|
||||
|
||||
interface R {
|
||||
p: number;
|
||||
}
|
||||
|
||||
function f<K extends keyof R>(p: K) {
|
||||
let a: any;
|
||||
a[p].add; // any
|
||||
}
|
||||
|
||||
// Repro from #12651
|
||||
|
||||
type MethodDescriptor = {
|
||||
name: string;
|
||||
args: any[];
|
||||
returnValue: any;
|
||||
}
|
||||
|
||||
declare function dispatchMethod<M extends MethodDescriptor>(name: M['name'], args: M['args']): M['returnValue'];
|
||||
|
||||
type SomeMethodDescriptor = {
|
||||
name: "someMethod";
|
||||
args: [string, number];
|
||||
returnValue: string[];
|
||||
}
|
||||
|
||||
let result = dispatchMethod<SomeMethodDescriptor>("someMethod", ["hello", 35]);
|
||||
|
||||
//// [keyofAndIndexedAccess.js]
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
@@ -438,6 +576,74 @@ function f60(source, target) {
|
||||
target[k] = source[k];
|
||||
}
|
||||
}
|
||||
function f70(func) {
|
||||
func('a', 'a');
|
||||
func('a', 'b');
|
||||
func('a', 'c');
|
||||
}
|
||||
function f71(func) {
|
||||
var x = func({ a: 1, b: "hello" }, { c: true });
|
||||
x.a; // number | undefined
|
||||
x.b; // string | undefined
|
||||
x.c; // boolean | undefined
|
||||
}
|
||||
function f72(func) {
|
||||
var a = func({ a: 1, b: "hello" }, { c: true }, 'a'); // number
|
||||
var b = func({ a: 1, b: "hello" }, { c: true }, 'b'); // string
|
||||
var c = func({ a: 1, b: "hello" }, { c: true }, 'c'); // boolean
|
||||
}
|
||||
function f73(func) {
|
||||
var a = func({ a: 1, b: "hello" }, { c: true }, 'a'); // number
|
||||
var b = func({ a: 1, b: "hello" }, { c: true }, 'b'); // string
|
||||
var c = func({ a: 1, b: "hello" }, { c: true }, 'c'); // boolean
|
||||
}
|
||||
function f74(func) {
|
||||
var a = func({ a: 1, b: "hello" }, { a: 2, b: true }, 'a'); // number
|
||||
var b = func({ a: 1, b: "hello" }, { a: 2, b: true }, 'b'); // string | boolean
|
||||
}
|
||||
function f80(obj) {
|
||||
var a1 = obj.a; // { x: any }
|
||||
var a2 = obj['a']; // { x: any }
|
||||
var a3 = obj['a']; // T["a"]
|
||||
var x1 = obj.a.x; // any
|
||||
var x2 = obj['a']['x']; // any
|
||||
var x3 = obj['a']['x']; // T["a"]["x"]
|
||||
}
|
||||
function f81(obj) {
|
||||
return obj['a']['x'];
|
||||
}
|
||||
function f82() {
|
||||
var x1 = f81({ a: { x: "hello" } }); // string
|
||||
var x2 = f81({ a: { x: 42 } }); // number
|
||||
}
|
||||
function f83(obj, key) {
|
||||
return obj[key]['x'];
|
||||
}
|
||||
function f84() {
|
||||
var x1 = f83({ foo: { x: "hello" } }, "foo"); // string
|
||||
var x2 = f83({ bar: { x: 42 } }, "bar"); // number
|
||||
}
|
||||
var C1 = (function () {
|
||||
function C1() {
|
||||
}
|
||||
C1.prototype.get = function (key) {
|
||||
return this[key];
|
||||
};
|
||||
C1.prototype.set = function (key, value) {
|
||||
this[key] = value;
|
||||
};
|
||||
C1.prototype.foo = function () {
|
||||
var x1 = this.x; // number
|
||||
var x2 = this["x"]; // number
|
||||
var x3 = this.get("x"); // this["x"]
|
||||
var x4 = getProperty(this, "x"); // this["x"]
|
||||
this.x = 42;
|
||||
this["x"] = 42;
|
||||
this.set("x", 42);
|
||||
setProperty(this, "x", 42);
|
||||
};
|
||||
return C1;
|
||||
}());
|
||||
// Repros from #12011
|
||||
var Base = (function () {
|
||||
function Base() {
|
||||
@@ -496,6 +702,17 @@ var assignTo2 = function (object, key1, key2) {
|
||||
var empty = one(function () { }); // inferred as {}, expected
|
||||
var hashOfEmpty1 = on({ test: function () { } }); // {}
|
||||
var hashOfEmpty2 = on({ test: function (x) { } }); // { test: boolean }
|
||||
var c1 = new Component1({
|
||||
data: {
|
||||
hello: ""
|
||||
}
|
||||
});
|
||||
c1.get("hello");
|
||||
function f(p) {
|
||||
var a;
|
||||
a[p].add; // any
|
||||
}
|
||||
var result = dispatchMethod("someMethod", ["hello", 35]);
|
||||
|
||||
|
||||
//// [keyofAndIndexedAccess.d.ts]
|
||||
@@ -603,6 +820,34 @@ declare function f53<T, K extends keyof T>(obj: {
|
||||
declare function f54<T>(obj: T, key: keyof T): void;
|
||||
declare function f55<T, K extends keyof T>(obj: T, key: K): void;
|
||||
declare function f60<T>(source: T, target: T): void;
|
||||
declare function f70(func: <T, U>(k1: keyof (T | U), k2: keyof (T & U)) => void): void;
|
||||
declare function f71(func: <T, U>(x: T, y: U) => Partial<T & U>): void;
|
||||
declare function f72(func: <T, U, K extends keyof T | keyof U>(x: T, y: U, k: K) => (T & U)[K]): void;
|
||||
declare function f73(func: <T, U, K extends keyof (T & U)>(x: T, y: U, k: K) => (T & U)[K]): void;
|
||||
declare function f74(func: <T, U, K extends keyof (T | U)>(x: T, y: U, k: K) => (T | U)[K]): void;
|
||||
declare function f80<T extends {
|
||||
a: {
|
||||
x: any;
|
||||
};
|
||||
}>(obj: T): void;
|
||||
declare function f81<T extends {
|
||||
a: {
|
||||
x: any;
|
||||
};
|
||||
}>(obj: T): T["a"]["x"];
|
||||
declare function f82(): void;
|
||||
declare function f83<T extends {
|
||||
[x: string]: {
|
||||
x: any;
|
||||
};
|
||||
}, K extends keyof T>(obj: T, key: K): T[K]["x"];
|
||||
declare function f84(): void;
|
||||
declare class C1 {
|
||||
x: number;
|
||||
get<K extends keyof this>(key: K): this[K];
|
||||
set<K extends keyof this>(key: K, value: this[K]): void;
|
||||
foo(): void;
|
||||
}
|
||||
declare class Base {
|
||||
get<K extends keyof this>(prop: K): this[K];
|
||||
set<K extends keyof this>(prop: K, value: this[K]): void;
|
||||
@@ -610,12 +855,12 @@ declare class Base {
|
||||
declare class Person extends Base {
|
||||
parts: number;
|
||||
constructor(parts: number);
|
||||
getParts(): number;
|
||||
getParts(): this["parts"];
|
||||
}
|
||||
declare class OtherPerson {
|
||||
parts: number;
|
||||
constructor(parts: number);
|
||||
getParts(): number;
|
||||
getParts(): this["parts"];
|
||||
}
|
||||
declare function path<T, K1 extends keyof T>(obj: T, key1: K1): T[K1];
|
||||
declare function path<T, K1 extends keyof T, K2 extends keyof T[K1]>(obj: T, key1: K1, key2: K2): T[K1][K2];
|
||||
@@ -640,3 +885,38 @@ declare var hashOfEmpty1: {};
|
||||
declare var hashOfEmpty2: {
|
||||
test: boolean;
|
||||
};
|
||||
interface Options1<Data, Computed> {
|
||||
data?: Data;
|
||||
computed?: Computed;
|
||||
}
|
||||
declare class Component1<Data, Computed> {
|
||||
constructor(options: Options1<Data, Computed>);
|
||||
get<K extends keyof (Data & Computed)>(key: K): (Data & Computed)[K];
|
||||
}
|
||||
declare let c1: Component1<{
|
||||
hello: string;
|
||||
}, {}>;
|
||||
interface Options2<Data, Computed> {
|
||||
data?: Data;
|
||||
computed?: Computed;
|
||||
}
|
||||
declare class Component2<Data, Computed> {
|
||||
constructor(options: Options2<Data, Computed>);
|
||||
get<K extends keyof Data | keyof Computed>(key: K): (Data & Computed)[K];
|
||||
}
|
||||
interface R {
|
||||
p: number;
|
||||
}
|
||||
declare function f<K extends keyof R>(p: K): void;
|
||||
declare type MethodDescriptor = {
|
||||
name: string;
|
||||
args: any[];
|
||||
returnValue: any;
|
||||
};
|
||||
declare function dispatchMethod<M extends MethodDescriptor>(name: M['name'], args: M['args']): M['returnValue'];
|
||||
declare type SomeMethodDescriptor = {
|
||||
name: "someMethod";
|
||||
args: [string, number];
|
||||
returnValue: string[];
|
||||
};
|
||||
declare let result: string[];
|
||||
|
||||
@@ -766,278 +766,813 @@ function f60<T>(source: T, target: T) {
|
||||
}
|
||||
}
|
||||
|
||||
function f70(func: <T, U>(k1: keyof (T | U), k2: keyof (T & U)) => void) {
|
||||
>f70 : Symbol(f70, Decl(keyofAndIndexedAccess.ts, 218, 1))
|
||||
>func : Symbol(func, Decl(keyofAndIndexedAccess.ts, 220, 13))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 220, 20))
|
||||
>U : Symbol(U, Decl(keyofAndIndexedAccess.ts, 220, 22))
|
||||
>k1 : Symbol(k1, Decl(keyofAndIndexedAccess.ts, 220, 26))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 220, 20))
|
||||
>U : Symbol(U, Decl(keyofAndIndexedAccess.ts, 220, 22))
|
||||
>k2 : Symbol(k2, Decl(keyofAndIndexedAccess.ts, 220, 44))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 220, 20))
|
||||
>U : Symbol(U, Decl(keyofAndIndexedAccess.ts, 220, 22))
|
||||
|
||||
func<{ a: any, b: any }, { a: any, c: any }>('a', 'a');
|
||||
>func : Symbol(func, Decl(keyofAndIndexedAccess.ts, 220, 13))
|
||||
>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 221, 10))
|
||||
>b : Symbol(b, Decl(keyofAndIndexedAccess.ts, 221, 18))
|
||||
>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 221, 30))
|
||||
>c : Symbol(c, Decl(keyofAndIndexedAccess.ts, 221, 38))
|
||||
|
||||
func<{ a: any, b: any }, { a: any, c: any }>('a', 'b');
|
||||
>func : Symbol(func, Decl(keyofAndIndexedAccess.ts, 220, 13))
|
||||
>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 222, 10))
|
||||
>b : Symbol(b, Decl(keyofAndIndexedAccess.ts, 222, 18))
|
||||
>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 222, 30))
|
||||
>c : Symbol(c, Decl(keyofAndIndexedAccess.ts, 222, 38))
|
||||
|
||||
func<{ a: any, b: any }, { a: any, c: any }>('a', 'c');
|
||||
>func : Symbol(func, Decl(keyofAndIndexedAccess.ts, 220, 13))
|
||||
>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 223, 10))
|
||||
>b : Symbol(b, Decl(keyofAndIndexedAccess.ts, 223, 18))
|
||||
>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 223, 30))
|
||||
>c : Symbol(c, Decl(keyofAndIndexedAccess.ts, 223, 38))
|
||||
}
|
||||
|
||||
function f71(func: <T, U>(x: T, y: U) => Partial<T & U>) {
|
||||
>f71 : Symbol(f71, Decl(keyofAndIndexedAccess.ts, 224, 1))
|
||||
>func : Symbol(func, Decl(keyofAndIndexedAccess.ts, 226, 13))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 226, 20))
|
||||
>U : Symbol(U, Decl(keyofAndIndexedAccess.ts, 226, 22))
|
||||
>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 226, 26))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 226, 20))
|
||||
>y : Symbol(y, Decl(keyofAndIndexedAccess.ts, 226, 31))
|
||||
>U : Symbol(U, Decl(keyofAndIndexedAccess.ts, 226, 22))
|
||||
>Partial : Symbol(Partial, Decl(lib.d.ts, --, --))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 226, 20))
|
||||
>U : Symbol(U, Decl(keyofAndIndexedAccess.ts, 226, 22))
|
||||
|
||||
let x = func({ a: 1, b: "hello" }, { c: true });
|
||||
>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 227, 7))
|
||||
>func : Symbol(func, Decl(keyofAndIndexedAccess.ts, 226, 13))
|
||||
>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 227, 18))
|
||||
>b : Symbol(b, Decl(keyofAndIndexedAccess.ts, 227, 24))
|
||||
>c : Symbol(c, Decl(keyofAndIndexedAccess.ts, 227, 40))
|
||||
|
||||
x.a; // number | undefined
|
||||
>x.a : Symbol(a)
|
||||
>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 227, 7))
|
||||
>a : Symbol(a)
|
||||
|
||||
x.b; // string | undefined
|
||||
>x.b : Symbol(b)
|
||||
>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 227, 7))
|
||||
>b : Symbol(b)
|
||||
|
||||
x.c; // boolean | undefined
|
||||
>x.c : Symbol(c)
|
||||
>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 227, 7))
|
||||
>c : Symbol(c)
|
||||
}
|
||||
|
||||
function f72(func: <T, U, K extends keyof T | keyof U>(x: T, y: U, k: K) => (T & U)[K]) {
|
||||
>f72 : Symbol(f72, Decl(keyofAndIndexedAccess.ts, 231, 1))
|
||||
>func : Symbol(func, Decl(keyofAndIndexedAccess.ts, 233, 13))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 233, 20))
|
||||
>U : Symbol(U, Decl(keyofAndIndexedAccess.ts, 233, 22))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 233, 25))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 233, 20))
|
||||
>U : Symbol(U, Decl(keyofAndIndexedAccess.ts, 233, 22))
|
||||
>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 233, 55))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 233, 20))
|
||||
>y : Symbol(y, Decl(keyofAndIndexedAccess.ts, 233, 60))
|
||||
>U : Symbol(U, Decl(keyofAndIndexedAccess.ts, 233, 22))
|
||||
>k : Symbol(k, Decl(keyofAndIndexedAccess.ts, 233, 66))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 233, 25))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 233, 20))
|
||||
>U : Symbol(U, Decl(keyofAndIndexedAccess.ts, 233, 22))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 233, 25))
|
||||
|
||||
let a = func({ a: 1, b: "hello" }, { c: true }, 'a'); // number
|
||||
>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 234, 7))
|
||||
>func : Symbol(func, Decl(keyofAndIndexedAccess.ts, 233, 13))
|
||||
>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 234, 18))
|
||||
>b : Symbol(b, Decl(keyofAndIndexedAccess.ts, 234, 24))
|
||||
>c : Symbol(c, Decl(keyofAndIndexedAccess.ts, 234, 40))
|
||||
|
||||
let b = func({ a: 1, b: "hello" }, { c: true }, 'b'); // string
|
||||
>b : Symbol(b, Decl(keyofAndIndexedAccess.ts, 235, 7))
|
||||
>func : Symbol(func, Decl(keyofAndIndexedAccess.ts, 233, 13))
|
||||
>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 235, 18))
|
||||
>b : Symbol(b, Decl(keyofAndIndexedAccess.ts, 235, 24))
|
||||
>c : Symbol(c, Decl(keyofAndIndexedAccess.ts, 235, 40))
|
||||
|
||||
let c = func({ a: 1, b: "hello" }, { c: true }, 'c'); // boolean
|
||||
>c : Symbol(c, Decl(keyofAndIndexedAccess.ts, 236, 7))
|
||||
>func : Symbol(func, Decl(keyofAndIndexedAccess.ts, 233, 13))
|
||||
>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 236, 18))
|
||||
>b : Symbol(b, Decl(keyofAndIndexedAccess.ts, 236, 24))
|
||||
>c : Symbol(c, Decl(keyofAndIndexedAccess.ts, 236, 40))
|
||||
}
|
||||
|
||||
function f73(func: <T, U, K extends keyof (T & U)>(x: T, y: U, k: K) => (T & U)[K]) {
|
||||
>f73 : Symbol(f73, Decl(keyofAndIndexedAccess.ts, 237, 1))
|
||||
>func : Symbol(func, Decl(keyofAndIndexedAccess.ts, 239, 13))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 239, 20))
|
||||
>U : Symbol(U, Decl(keyofAndIndexedAccess.ts, 239, 22))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 239, 25))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 239, 20))
|
||||
>U : Symbol(U, Decl(keyofAndIndexedAccess.ts, 239, 22))
|
||||
>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 239, 51))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 239, 20))
|
||||
>y : Symbol(y, Decl(keyofAndIndexedAccess.ts, 239, 56))
|
||||
>U : Symbol(U, Decl(keyofAndIndexedAccess.ts, 239, 22))
|
||||
>k : Symbol(k, Decl(keyofAndIndexedAccess.ts, 239, 62))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 239, 25))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 239, 20))
|
||||
>U : Symbol(U, Decl(keyofAndIndexedAccess.ts, 239, 22))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 239, 25))
|
||||
|
||||
let a = func({ a: 1, b: "hello" }, { c: true }, 'a'); // number
|
||||
>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 240, 7))
|
||||
>func : Symbol(func, Decl(keyofAndIndexedAccess.ts, 239, 13))
|
||||
>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 240, 18))
|
||||
>b : Symbol(b, Decl(keyofAndIndexedAccess.ts, 240, 24))
|
||||
>c : Symbol(c, Decl(keyofAndIndexedAccess.ts, 240, 40))
|
||||
|
||||
let b = func({ a: 1, b: "hello" }, { c: true }, 'b'); // string
|
||||
>b : Symbol(b, Decl(keyofAndIndexedAccess.ts, 241, 7))
|
||||
>func : Symbol(func, Decl(keyofAndIndexedAccess.ts, 239, 13))
|
||||
>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 241, 18))
|
||||
>b : Symbol(b, Decl(keyofAndIndexedAccess.ts, 241, 24))
|
||||
>c : Symbol(c, Decl(keyofAndIndexedAccess.ts, 241, 40))
|
||||
|
||||
let c = func({ a: 1, b: "hello" }, { c: true }, 'c'); // boolean
|
||||
>c : Symbol(c, Decl(keyofAndIndexedAccess.ts, 242, 7))
|
||||
>func : Symbol(func, Decl(keyofAndIndexedAccess.ts, 239, 13))
|
||||
>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 242, 18))
|
||||
>b : Symbol(b, Decl(keyofAndIndexedAccess.ts, 242, 24))
|
||||
>c : Symbol(c, Decl(keyofAndIndexedAccess.ts, 242, 40))
|
||||
}
|
||||
|
||||
function f74(func: <T, U, K extends keyof (T | U)>(x: T, y: U, k: K) => (T | U)[K]) {
|
||||
>f74 : Symbol(f74, Decl(keyofAndIndexedAccess.ts, 243, 1))
|
||||
>func : Symbol(func, Decl(keyofAndIndexedAccess.ts, 245, 13))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 245, 20))
|
||||
>U : Symbol(U, Decl(keyofAndIndexedAccess.ts, 245, 22))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 245, 25))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 245, 20))
|
||||
>U : Symbol(U, Decl(keyofAndIndexedAccess.ts, 245, 22))
|
||||
>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 245, 51))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 245, 20))
|
||||
>y : Symbol(y, Decl(keyofAndIndexedAccess.ts, 245, 56))
|
||||
>U : Symbol(U, Decl(keyofAndIndexedAccess.ts, 245, 22))
|
||||
>k : Symbol(k, Decl(keyofAndIndexedAccess.ts, 245, 62))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 245, 25))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 245, 20))
|
||||
>U : Symbol(U, Decl(keyofAndIndexedAccess.ts, 245, 22))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 245, 25))
|
||||
|
||||
let a = func({ a: 1, b: "hello" }, { a: 2, b: true }, 'a'); // number
|
||||
>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 246, 7))
|
||||
>func : Symbol(func, Decl(keyofAndIndexedAccess.ts, 245, 13))
|
||||
>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 246, 18))
|
||||
>b : Symbol(b, Decl(keyofAndIndexedAccess.ts, 246, 24))
|
||||
>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 246, 40))
|
||||
>b : Symbol(b, Decl(keyofAndIndexedAccess.ts, 246, 46))
|
||||
|
||||
let b = func({ a: 1, b: "hello" }, { a: 2, b: true }, 'b'); // string | boolean
|
||||
>b : Symbol(b, Decl(keyofAndIndexedAccess.ts, 247, 7))
|
||||
>func : Symbol(func, Decl(keyofAndIndexedAccess.ts, 245, 13))
|
||||
>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 247, 18))
|
||||
>b : Symbol(b, Decl(keyofAndIndexedAccess.ts, 247, 24))
|
||||
>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 247, 40))
|
||||
>b : Symbol(b, Decl(keyofAndIndexedAccess.ts, 247, 46))
|
||||
}
|
||||
|
||||
function f80<T extends { a: { x: any } }>(obj: T) {
|
||||
>f80 : Symbol(f80, Decl(keyofAndIndexedAccess.ts, 248, 1))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 250, 13))
|
||||
>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 250, 24))
|
||||
>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 250, 29))
|
||||
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 250, 42))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 250, 13))
|
||||
|
||||
let a1 = obj.a; // { x: any }
|
||||
>a1 : Symbol(a1, Decl(keyofAndIndexedAccess.ts, 251, 7))
|
||||
>obj.a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 250, 24))
|
||||
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 250, 42))
|
||||
>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 250, 24))
|
||||
|
||||
let a2 = obj['a']; // { x: any }
|
||||
>a2 : Symbol(a2, Decl(keyofAndIndexedAccess.ts, 252, 7))
|
||||
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 250, 42))
|
||||
>'a' : Symbol(a, Decl(keyofAndIndexedAccess.ts, 250, 24))
|
||||
|
||||
let a3 = obj['a'] as T['a']; // T["a"]
|
||||
>a3 : Symbol(a3, Decl(keyofAndIndexedAccess.ts, 253, 7))
|
||||
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 250, 42))
|
||||
>'a' : Symbol(a, Decl(keyofAndIndexedAccess.ts, 250, 24))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 250, 13))
|
||||
|
||||
let x1 = obj.a.x; // any
|
||||
>x1 : Symbol(x1, Decl(keyofAndIndexedAccess.ts, 254, 7))
|
||||
>obj.a.x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 250, 29))
|
||||
>obj.a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 250, 24))
|
||||
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 250, 42))
|
||||
>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 250, 24))
|
||||
>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 250, 29))
|
||||
|
||||
let x2 = obj['a']['x']; // any
|
||||
>x2 : Symbol(x2, Decl(keyofAndIndexedAccess.ts, 255, 7))
|
||||
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 250, 42))
|
||||
>'a' : Symbol(a, Decl(keyofAndIndexedAccess.ts, 250, 24))
|
||||
>'x' : Symbol(x, Decl(keyofAndIndexedAccess.ts, 250, 29))
|
||||
|
||||
let x3 = obj['a']['x'] as T['a']['x']; // T["a"]["x"]
|
||||
>x3 : Symbol(x3, Decl(keyofAndIndexedAccess.ts, 256, 7))
|
||||
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 250, 42))
|
||||
>'a' : Symbol(a, Decl(keyofAndIndexedAccess.ts, 250, 24))
|
||||
>'x' : Symbol(x, Decl(keyofAndIndexedAccess.ts, 250, 29))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 250, 13))
|
||||
}
|
||||
|
||||
function f81<T extends { a: { x: any } }>(obj: T) {
|
||||
>f81 : Symbol(f81, Decl(keyofAndIndexedAccess.ts, 257, 1))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 259, 13))
|
||||
>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 259, 24))
|
||||
>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 259, 29))
|
||||
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 259, 42))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 259, 13))
|
||||
|
||||
return obj['a']['x'] as T['a']['x'];
|
||||
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 259, 42))
|
||||
>'a' : Symbol(a, Decl(keyofAndIndexedAccess.ts, 259, 24))
|
||||
>'x' : Symbol(x, Decl(keyofAndIndexedAccess.ts, 259, 29))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 259, 13))
|
||||
}
|
||||
|
||||
function f82() {
|
||||
>f82 : Symbol(f82, Decl(keyofAndIndexedAccess.ts, 261, 1))
|
||||
|
||||
let x1 = f81({ a: { x: "hello" } }); // string
|
||||
>x1 : Symbol(x1, Decl(keyofAndIndexedAccess.ts, 264, 7))
|
||||
>f81 : Symbol(f81, Decl(keyofAndIndexedAccess.ts, 257, 1))
|
||||
>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 264, 18))
|
||||
>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 264, 23))
|
||||
|
||||
let x2 = f81({ a: { x: 42 } }); // number
|
||||
>x2 : Symbol(x2, Decl(keyofAndIndexedAccess.ts, 265, 7))
|
||||
>f81 : Symbol(f81, Decl(keyofAndIndexedAccess.ts, 257, 1))
|
||||
>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 265, 18))
|
||||
>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 265, 23))
|
||||
}
|
||||
|
||||
function f83<T extends { [x: string]: { x: any } }, K extends keyof T>(obj: T, key: K) {
|
||||
>f83 : Symbol(f83, Decl(keyofAndIndexedAccess.ts, 266, 1))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 268, 13))
|
||||
>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 268, 26))
|
||||
>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 268, 39))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 268, 51))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 268, 13))
|
||||
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 268, 71))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 268, 13))
|
||||
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 268, 78))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 268, 51))
|
||||
|
||||
return obj[key]['x'] as T[K]['x'];
|
||||
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 268, 71))
|
||||
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 268, 78))
|
||||
>'x' : Symbol(x, Decl(keyofAndIndexedAccess.ts, 268, 39))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 268, 13))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 268, 51))
|
||||
}
|
||||
|
||||
function f84() {
|
||||
>f84 : Symbol(f84, Decl(keyofAndIndexedAccess.ts, 270, 1))
|
||||
|
||||
let x1 = f83({ foo: { x: "hello" } }, "foo"); // string
|
||||
>x1 : Symbol(x1, Decl(keyofAndIndexedAccess.ts, 273, 7))
|
||||
>f83 : Symbol(f83, Decl(keyofAndIndexedAccess.ts, 266, 1))
|
||||
>foo : Symbol(foo, Decl(keyofAndIndexedAccess.ts, 273, 18))
|
||||
>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 273, 25))
|
||||
|
||||
let x2 = f83({ bar: { x: 42 } }, "bar"); // number
|
||||
>x2 : Symbol(x2, Decl(keyofAndIndexedAccess.ts, 274, 7))
|
||||
>f83 : Symbol(f83, Decl(keyofAndIndexedAccess.ts, 266, 1))
|
||||
>bar : Symbol(bar, Decl(keyofAndIndexedAccess.ts, 274, 18))
|
||||
>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 274, 25))
|
||||
}
|
||||
|
||||
class C1 {
|
||||
>C1 : Symbol(C1, Decl(keyofAndIndexedAccess.ts, 275, 1))
|
||||
|
||||
x: number;
|
||||
>x : Symbol(C1.x, Decl(keyofAndIndexedAccess.ts, 277, 10))
|
||||
|
||||
get<K extends keyof this>(key: K) {
|
||||
>get : Symbol(C1.get, Decl(keyofAndIndexedAccess.ts, 278, 14))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 279, 8))
|
||||
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 279, 30))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 279, 8))
|
||||
|
||||
return this[key];
|
||||
>this : Symbol(C1, Decl(keyofAndIndexedAccess.ts, 275, 1))
|
||||
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 279, 30))
|
||||
}
|
||||
set<K extends keyof this>(key: K, value: this[K]) {
|
||||
>set : Symbol(C1.set, Decl(keyofAndIndexedAccess.ts, 281, 5))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 282, 8))
|
||||
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 282, 30))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 282, 8))
|
||||
>value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 282, 37))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 282, 8))
|
||||
|
||||
this[key] = value;
|
||||
>this : Symbol(C1, Decl(keyofAndIndexedAccess.ts, 275, 1))
|
||||
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 282, 30))
|
||||
>value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 282, 37))
|
||||
}
|
||||
foo() {
|
||||
>foo : Symbol(C1.foo, Decl(keyofAndIndexedAccess.ts, 284, 5))
|
||||
|
||||
let x1 = this.x; // number
|
||||
>x1 : Symbol(x1, Decl(keyofAndIndexedAccess.ts, 286, 11))
|
||||
>this.x : Symbol(C1.x, Decl(keyofAndIndexedAccess.ts, 277, 10))
|
||||
>this : Symbol(C1, Decl(keyofAndIndexedAccess.ts, 275, 1))
|
||||
>x : Symbol(C1.x, Decl(keyofAndIndexedAccess.ts, 277, 10))
|
||||
|
||||
let x2 = this["x"]; // number
|
||||
>x2 : Symbol(x2, Decl(keyofAndIndexedAccess.ts, 287, 11))
|
||||
>this : Symbol(C1, Decl(keyofAndIndexedAccess.ts, 275, 1))
|
||||
>"x" : Symbol(C1.x, Decl(keyofAndIndexedAccess.ts, 277, 10))
|
||||
|
||||
let x3 = this.get("x"); // this["x"]
|
||||
>x3 : Symbol(x3, Decl(keyofAndIndexedAccess.ts, 288, 11))
|
||||
>this.get : Symbol(C1.get, Decl(keyofAndIndexedAccess.ts, 278, 14))
|
||||
>this : Symbol(C1, Decl(keyofAndIndexedAccess.ts, 275, 1))
|
||||
>get : Symbol(C1.get, Decl(keyofAndIndexedAccess.ts, 278, 14))
|
||||
|
||||
let x4 = getProperty(this, "x"); // this["x"]
|
||||
>x4 : Symbol(x4, Decl(keyofAndIndexedAccess.ts, 289, 11))
|
||||
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 77, 26))
|
||||
>this : Symbol(C1, Decl(keyofAndIndexedAccess.ts, 275, 1))
|
||||
|
||||
this.x = 42;
|
||||
>this.x : Symbol(C1.x, Decl(keyofAndIndexedAccess.ts, 277, 10))
|
||||
>this : Symbol(C1, Decl(keyofAndIndexedAccess.ts, 275, 1))
|
||||
>x : Symbol(C1.x, Decl(keyofAndIndexedAccess.ts, 277, 10))
|
||||
|
||||
this["x"] = 42;
|
||||
>this : Symbol(C1, Decl(keyofAndIndexedAccess.ts, 275, 1))
|
||||
>"x" : Symbol(C1.x, Decl(keyofAndIndexedAccess.ts, 277, 10))
|
||||
|
||||
this.set("x", 42);
|
||||
>this.set : Symbol(C1.set, Decl(keyofAndIndexedAccess.ts, 281, 5))
|
||||
>this : Symbol(C1, Decl(keyofAndIndexedAccess.ts, 275, 1))
|
||||
>set : Symbol(C1.set, Decl(keyofAndIndexedAccess.ts, 281, 5))
|
||||
|
||||
setProperty(this, "x", 42);
|
||||
>setProperty : Symbol(setProperty, Decl(keyofAndIndexedAccess.ts, 81, 1))
|
||||
>this : Symbol(C1, Decl(keyofAndIndexedAccess.ts, 275, 1))
|
||||
}
|
||||
}
|
||||
|
||||
// Repros from #12011
|
||||
|
||||
class Base {
|
||||
>Base : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 218, 1))
|
||||
>Base : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 295, 1))
|
||||
|
||||
get<K extends keyof this>(prop: K) {
|
||||
>get : Symbol(Base.get, Decl(keyofAndIndexedAccess.ts, 222, 12))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 223, 8))
|
||||
>prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 223, 30))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 223, 8))
|
||||
>get : Symbol(Base.get, Decl(keyofAndIndexedAccess.ts, 299, 12))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 300, 8))
|
||||
>prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 300, 30))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 300, 8))
|
||||
|
||||
return this[prop];
|
||||
>this : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 218, 1))
|
||||
>prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 223, 30))
|
||||
>this : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 295, 1))
|
||||
>prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 300, 30))
|
||||
}
|
||||
set<K extends keyof this>(prop: K, value: this[K]) {
|
||||
>set : Symbol(Base.set, Decl(keyofAndIndexedAccess.ts, 225, 5))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 226, 8))
|
||||
>prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 226, 30))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 226, 8))
|
||||
>value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 226, 38))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 226, 8))
|
||||
>set : Symbol(Base.set, Decl(keyofAndIndexedAccess.ts, 302, 5))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 303, 8))
|
||||
>prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 303, 30))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 303, 8))
|
||||
>value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 303, 38))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 303, 8))
|
||||
|
||||
this[prop] = value;
|
||||
>this : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 218, 1))
|
||||
>prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 226, 30))
|
||||
>value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 226, 38))
|
||||
>this : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 295, 1))
|
||||
>prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 303, 30))
|
||||
>value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 303, 38))
|
||||
}
|
||||
}
|
||||
|
||||
class Person extends Base {
|
||||
>Person : Symbol(Person, Decl(keyofAndIndexedAccess.ts, 229, 1))
|
||||
>Base : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 218, 1))
|
||||
>Person : Symbol(Person, Decl(keyofAndIndexedAccess.ts, 306, 1))
|
||||
>Base : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 295, 1))
|
||||
|
||||
parts: number;
|
||||
>parts : Symbol(Person.parts, Decl(keyofAndIndexedAccess.ts, 231, 27))
|
||||
>parts : Symbol(Person.parts, Decl(keyofAndIndexedAccess.ts, 308, 27))
|
||||
|
||||
constructor(parts: number) {
|
||||
>parts : Symbol(parts, Decl(keyofAndIndexedAccess.ts, 233, 16))
|
||||
>parts : Symbol(parts, Decl(keyofAndIndexedAccess.ts, 310, 16))
|
||||
|
||||
super();
|
||||
>super : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 218, 1))
|
||||
>super : Symbol(Base, Decl(keyofAndIndexedAccess.ts, 295, 1))
|
||||
|
||||
this.set("parts", parts);
|
||||
>this.set : Symbol(Base.set, Decl(keyofAndIndexedAccess.ts, 225, 5))
|
||||
>this : Symbol(Person, Decl(keyofAndIndexedAccess.ts, 229, 1))
|
||||
>set : Symbol(Base.set, Decl(keyofAndIndexedAccess.ts, 225, 5))
|
||||
>parts : Symbol(parts, Decl(keyofAndIndexedAccess.ts, 233, 16))
|
||||
>this.set : Symbol(Base.set, Decl(keyofAndIndexedAccess.ts, 302, 5))
|
||||
>this : Symbol(Person, Decl(keyofAndIndexedAccess.ts, 306, 1))
|
||||
>set : Symbol(Base.set, Decl(keyofAndIndexedAccess.ts, 302, 5))
|
||||
>parts : Symbol(parts, Decl(keyofAndIndexedAccess.ts, 310, 16))
|
||||
}
|
||||
getParts() {
|
||||
>getParts : Symbol(Person.getParts, Decl(keyofAndIndexedAccess.ts, 236, 5))
|
||||
>getParts : Symbol(Person.getParts, Decl(keyofAndIndexedAccess.ts, 313, 5))
|
||||
|
||||
return this.get("parts")
|
||||
>this.get : Symbol(Base.get, Decl(keyofAndIndexedAccess.ts, 222, 12))
|
||||
>this : Symbol(Person, Decl(keyofAndIndexedAccess.ts, 229, 1))
|
||||
>get : Symbol(Base.get, Decl(keyofAndIndexedAccess.ts, 222, 12))
|
||||
>this.get : Symbol(Base.get, Decl(keyofAndIndexedAccess.ts, 299, 12))
|
||||
>this : Symbol(Person, Decl(keyofAndIndexedAccess.ts, 306, 1))
|
||||
>get : Symbol(Base.get, Decl(keyofAndIndexedAccess.ts, 299, 12))
|
||||
}
|
||||
}
|
||||
|
||||
class OtherPerson {
|
||||
>OtherPerson : Symbol(OtherPerson, Decl(keyofAndIndexedAccess.ts, 240, 1))
|
||||
>OtherPerson : Symbol(OtherPerson, Decl(keyofAndIndexedAccess.ts, 317, 1))
|
||||
|
||||
parts: number;
|
||||
>parts : Symbol(OtherPerson.parts, Decl(keyofAndIndexedAccess.ts, 242, 19))
|
||||
>parts : Symbol(OtherPerson.parts, Decl(keyofAndIndexedAccess.ts, 319, 19))
|
||||
|
||||
constructor(parts: number) {
|
||||
>parts : Symbol(parts, Decl(keyofAndIndexedAccess.ts, 244, 16))
|
||||
>parts : Symbol(parts, Decl(keyofAndIndexedAccess.ts, 321, 16))
|
||||
|
||||
setProperty(this, "parts", parts);
|
||||
>setProperty : Symbol(setProperty, Decl(keyofAndIndexedAccess.ts, 81, 1))
|
||||
>this : Symbol(OtherPerson, Decl(keyofAndIndexedAccess.ts, 240, 1))
|
||||
>parts : Symbol(parts, Decl(keyofAndIndexedAccess.ts, 244, 16))
|
||||
>this : Symbol(OtherPerson, Decl(keyofAndIndexedAccess.ts, 317, 1))
|
||||
>parts : Symbol(parts, Decl(keyofAndIndexedAccess.ts, 321, 16))
|
||||
}
|
||||
getParts() {
|
||||
>getParts : Symbol(OtherPerson.getParts, Decl(keyofAndIndexedAccess.ts, 246, 5))
|
||||
>getParts : Symbol(OtherPerson.getParts, Decl(keyofAndIndexedAccess.ts, 323, 5))
|
||||
|
||||
return getProperty(this, "parts")
|
||||
>getProperty : Symbol(getProperty, Decl(keyofAndIndexedAccess.ts, 77, 26))
|
||||
>this : Symbol(OtherPerson, Decl(keyofAndIndexedAccess.ts, 240, 1))
|
||||
>this : Symbol(OtherPerson, Decl(keyofAndIndexedAccess.ts, 317, 1))
|
||||
}
|
||||
}
|
||||
|
||||
// Modified repro from #12544
|
||||
|
||||
function path<T, K1 extends keyof T>(obj: T, key1: K1): T[K1];
|
||||
>path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 250, 1), Decl(keyofAndIndexedAccess.ts, 254, 62), Decl(keyofAndIndexedAccess.ts, 255, 100), Decl(keyofAndIndexedAccess.ts, 256, 142), Decl(keyofAndIndexedAccess.ts, 257, 59))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 254, 14))
|
||||
>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 254, 16))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 254, 14))
|
||||
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 254, 37))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 254, 14))
|
||||
>key1 : Symbol(key1, Decl(keyofAndIndexedAccess.ts, 254, 44))
|
||||
>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 254, 16))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 254, 14))
|
||||
>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 254, 16))
|
||||
>path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 327, 1), Decl(keyofAndIndexedAccess.ts, 331, 62), Decl(keyofAndIndexedAccess.ts, 332, 100), Decl(keyofAndIndexedAccess.ts, 333, 142), Decl(keyofAndIndexedAccess.ts, 334, 59))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 331, 14))
|
||||
>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 331, 16))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 331, 14))
|
||||
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 331, 37))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 331, 14))
|
||||
>key1 : Symbol(key1, Decl(keyofAndIndexedAccess.ts, 331, 44))
|
||||
>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 331, 16))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 331, 14))
|
||||
>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 331, 16))
|
||||
|
||||
function path<T, K1 extends keyof T, K2 extends keyof T[K1]>(obj: T, key1: K1, key2: K2): T[K1][K2];
|
||||
>path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 250, 1), Decl(keyofAndIndexedAccess.ts, 254, 62), Decl(keyofAndIndexedAccess.ts, 255, 100), Decl(keyofAndIndexedAccess.ts, 256, 142), Decl(keyofAndIndexedAccess.ts, 257, 59))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 255, 14))
|
||||
>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 255, 16))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 255, 14))
|
||||
>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 255, 36))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 255, 14))
|
||||
>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 255, 16))
|
||||
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 255, 61))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 255, 14))
|
||||
>key1 : Symbol(key1, Decl(keyofAndIndexedAccess.ts, 255, 68))
|
||||
>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 255, 16))
|
||||
>key2 : Symbol(key2, Decl(keyofAndIndexedAccess.ts, 255, 78))
|
||||
>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 255, 36))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 255, 14))
|
||||
>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 255, 16))
|
||||
>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 255, 36))
|
||||
>path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 327, 1), Decl(keyofAndIndexedAccess.ts, 331, 62), Decl(keyofAndIndexedAccess.ts, 332, 100), Decl(keyofAndIndexedAccess.ts, 333, 142), Decl(keyofAndIndexedAccess.ts, 334, 59))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 332, 14))
|
||||
>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 332, 16))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 332, 14))
|
||||
>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 332, 36))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 332, 14))
|
||||
>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 332, 16))
|
||||
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 332, 61))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 332, 14))
|
||||
>key1 : Symbol(key1, Decl(keyofAndIndexedAccess.ts, 332, 68))
|
||||
>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 332, 16))
|
||||
>key2 : Symbol(key2, Decl(keyofAndIndexedAccess.ts, 332, 78))
|
||||
>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 332, 36))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 332, 14))
|
||||
>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 332, 16))
|
||||
>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 332, 36))
|
||||
|
||||
function path<T, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2]>(obj: T, key1: K1, key2: K2, key3: K3): T[K1][K2][K3];
|
||||
>path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 250, 1), Decl(keyofAndIndexedAccess.ts, 254, 62), Decl(keyofAndIndexedAccess.ts, 255, 100), Decl(keyofAndIndexedAccess.ts, 256, 142), Decl(keyofAndIndexedAccess.ts, 257, 59))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 256, 14))
|
||||
>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 256, 16))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 256, 14))
|
||||
>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 256, 36))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 256, 14))
|
||||
>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 256, 16))
|
||||
>K3 : Symbol(K3, Decl(keyofAndIndexedAccess.ts, 256, 60))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 256, 14))
|
||||
>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 256, 16))
|
||||
>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 256, 36))
|
||||
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 256, 89))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 256, 14))
|
||||
>key1 : Symbol(key1, Decl(keyofAndIndexedAccess.ts, 256, 96))
|
||||
>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 256, 16))
|
||||
>key2 : Symbol(key2, Decl(keyofAndIndexedAccess.ts, 256, 106))
|
||||
>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 256, 36))
|
||||
>key3 : Symbol(key3, Decl(keyofAndIndexedAccess.ts, 256, 116))
|
||||
>K3 : Symbol(K3, Decl(keyofAndIndexedAccess.ts, 256, 60))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 256, 14))
|
||||
>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 256, 16))
|
||||
>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 256, 36))
|
||||
>K3 : Symbol(K3, Decl(keyofAndIndexedAccess.ts, 256, 60))
|
||||
>path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 327, 1), Decl(keyofAndIndexedAccess.ts, 331, 62), Decl(keyofAndIndexedAccess.ts, 332, 100), Decl(keyofAndIndexedAccess.ts, 333, 142), Decl(keyofAndIndexedAccess.ts, 334, 59))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 333, 14))
|
||||
>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 333, 16))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 333, 14))
|
||||
>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 333, 36))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 333, 14))
|
||||
>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 333, 16))
|
||||
>K3 : Symbol(K3, Decl(keyofAndIndexedAccess.ts, 333, 60))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 333, 14))
|
||||
>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 333, 16))
|
||||
>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 333, 36))
|
||||
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 333, 89))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 333, 14))
|
||||
>key1 : Symbol(key1, Decl(keyofAndIndexedAccess.ts, 333, 96))
|
||||
>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 333, 16))
|
||||
>key2 : Symbol(key2, Decl(keyofAndIndexedAccess.ts, 333, 106))
|
||||
>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 333, 36))
|
||||
>key3 : Symbol(key3, Decl(keyofAndIndexedAccess.ts, 333, 116))
|
||||
>K3 : Symbol(K3, Decl(keyofAndIndexedAccess.ts, 333, 60))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 333, 14))
|
||||
>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 333, 16))
|
||||
>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 333, 36))
|
||||
>K3 : Symbol(K3, Decl(keyofAndIndexedAccess.ts, 333, 60))
|
||||
|
||||
function path(obj: any, ...keys: (string | number)[]): any;
|
||||
>path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 250, 1), Decl(keyofAndIndexedAccess.ts, 254, 62), Decl(keyofAndIndexedAccess.ts, 255, 100), Decl(keyofAndIndexedAccess.ts, 256, 142), Decl(keyofAndIndexedAccess.ts, 257, 59))
|
||||
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 257, 14))
|
||||
>keys : Symbol(keys, Decl(keyofAndIndexedAccess.ts, 257, 23))
|
||||
>path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 327, 1), Decl(keyofAndIndexedAccess.ts, 331, 62), Decl(keyofAndIndexedAccess.ts, 332, 100), Decl(keyofAndIndexedAccess.ts, 333, 142), Decl(keyofAndIndexedAccess.ts, 334, 59))
|
||||
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 334, 14))
|
||||
>keys : Symbol(keys, Decl(keyofAndIndexedAccess.ts, 334, 23))
|
||||
|
||||
function path(obj: any, ...keys: (string | number)[]): any {
|
||||
>path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 250, 1), Decl(keyofAndIndexedAccess.ts, 254, 62), Decl(keyofAndIndexedAccess.ts, 255, 100), Decl(keyofAndIndexedAccess.ts, 256, 142), Decl(keyofAndIndexedAccess.ts, 257, 59))
|
||||
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 258, 14))
|
||||
>keys : Symbol(keys, Decl(keyofAndIndexedAccess.ts, 258, 23))
|
||||
>path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 327, 1), Decl(keyofAndIndexedAccess.ts, 331, 62), Decl(keyofAndIndexedAccess.ts, 332, 100), Decl(keyofAndIndexedAccess.ts, 333, 142), Decl(keyofAndIndexedAccess.ts, 334, 59))
|
||||
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 335, 14))
|
||||
>keys : Symbol(keys, Decl(keyofAndIndexedAccess.ts, 335, 23))
|
||||
|
||||
let result = obj;
|
||||
>result : Symbol(result, Decl(keyofAndIndexedAccess.ts, 259, 7))
|
||||
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 258, 14))
|
||||
>result : Symbol(result, Decl(keyofAndIndexedAccess.ts, 336, 7))
|
||||
>obj : Symbol(obj, Decl(keyofAndIndexedAccess.ts, 335, 14))
|
||||
|
||||
for (let k of keys) {
|
||||
>k : Symbol(k, Decl(keyofAndIndexedAccess.ts, 260, 12))
|
||||
>keys : Symbol(keys, Decl(keyofAndIndexedAccess.ts, 258, 23))
|
||||
>k : Symbol(k, Decl(keyofAndIndexedAccess.ts, 337, 12))
|
||||
>keys : Symbol(keys, Decl(keyofAndIndexedAccess.ts, 335, 23))
|
||||
|
||||
result = result[k];
|
||||
>result : Symbol(result, Decl(keyofAndIndexedAccess.ts, 259, 7))
|
||||
>result : Symbol(result, Decl(keyofAndIndexedAccess.ts, 259, 7))
|
||||
>k : Symbol(k, Decl(keyofAndIndexedAccess.ts, 260, 12))
|
||||
>result : Symbol(result, Decl(keyofAndIndexedAccess.ts, 336, 7))
|
||||
>result : Symbol(result, Decl(keyofAndIndexedAccess.ts, 336, 7))
|
||||
>k : Symbol(k, Decl(keyofAndIndexedAccess.ts, 337, 12))
|
||||
}
|
||||
return result;
|
||||
>result : Symbol(result, Decl(keyofAndIndexedAccess.ts, 259, 7))
|
||||
>result : Symbol(result, Decl(keyofAndIndexedAccess.ts, 336, 7))
|
||||
}
|
||||
|
||||
type Thing = {
|
||||
>Thing : Symbol(Thing, Decl(keyofAndIndexedAccess.ts, 264, 1))
|
||||
>Thing : Symbol(Thing, Decl(keyofAndIndexedAccess.ts, 341, 1))
|
||||
|
||||
a: { x: number, y: string },
|
||||
>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 266, 14))
|
||||
>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 267, 8))
|
||||
>y : Symbol(y, Decl(keyofAndIndexedAccess.ts, 267, 19))
|
||||
>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 343, 14))
|
||||
>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 344, 8))
|
||||
>y : Symbol(y, Decl(keyofAndIndexedAccess.ts, 344, 19))
|
||||
|
||||
b: boolean
|
||||
>b : Symbol(b, Decl(keyofAndIndexedAccess.ts, 267, 32))
|
||||
>b : Symbol(b, Decl(keyofAndIndexedAccess.ts, 344, 32))
|
||||
|
||||
};
|
||||
|
||||
|
||||
function f1(thing: Thing) {
|
||||
>f1 : Symbol(f1, Decl(keyofAndIndexedAccess.ts, 269, 2))
|
||||
>thing : Symbol(thing, Decl(keyofAndIndexedAccess.ts, 272, 12))
|
||||
>Thing : Symbol(Thing, Decl(keyofAndIndexedAccess.ts, 264, 1))
|
||||
>f1 : Symbol(f1, Decl(keyofAndIndexedAccess.ts, 346, 2))
|
||||
>thing : Symbol(thing, Decl(keyofAndIndexedAccess.ts, 349, 12))
|
||||
>Thing : Symbol(Thing, Decl(keyofAndIndexedAccess.ts, 341, 1))
|
||||
|
||||
let x1 = path(thing, 'a'); // { x: number, y: string }
|
||||
>x1 : Symbol(x1, Decl(keyofAndIndexedAccess.ts, 273, 7))
|
||||
>path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 250, 1), Decl(keyofAndIndexedAccess.ts, 254, 62), Decl(keyofAndIndexedAccess.ts, 255, 100), Decl(keyofAndIndexedAccess.ts, 256, 142), Decl(keyofAndIndexedAccess.ts, 257, 59))
|
||||
>thing : Symbol(thing, Decl(keyofAndIndexedAccess.ts, 272, 12))
|
||||
>x1 : Symbol(x1, Decl(keyofAndIndexedAccess.ts, 350, 7))
|
||||
>path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 327, 1), Decl(keyofAndIndexedAccess.ts, 331, 62), Decl(keyofAndIndexedAccess.ts, 332, 100), Decl(keyofAndIndexedAccess.ts, 333, 142), Decl(keyofAndIndexedAccess.ts, 334, 59))
|
||||
>thing : Symbol(thing, Decl(keyofAndIndexedAccess.ts, 349, 12))
|
||||
|
||||
let x2 = path(thing, 'a', 'y'); // string
|
||||
>x2 : Symbol(x2, Decl(keyofAndIndexedAccess.ts, 274, 7))
|
||||
>path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 250, 1), Decl(keyofAndIndexedAccess.ts, 254, 62), Decl(keyofAndIndexedAccess.ts, 255, 100), Decl(keyofAndIndexedAccess.ts, 256, 142), Decl(keyofAndIndexedAccess.ts, 257, 59))
|
||||
>thing : Symbol(thing, Decl(keyofAndIndexedAccess.ts, 272, 12))
|
||||
>x2 : Symbol(x2, Decl(keyofAndIndexedAccess.ts, 351, 7))
|
||||
>path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 327, 1), Decl(keyofAndIndexedAccess.ts, 331, 62), Decl(keyofAndIndexedAccess.ts, 332, 100), Decl(keyofAndIndexedAccess.ts, 333, 142), Decl(keyofAndIndexedAccess.ts, 334, 59))
|
||||
>thing : Symbol(thing, Decl(keyofAndIndexedAccess.ts, 349, 12))
|
||||
|
||||
let x3 = path(thing, 'b'); // boolean
|
||||
>x3 : Symbol(x3, Decl(keyofAndIndexedAccess.ts, 275, 7))
|
||||
>path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 250, 1), Decl(keyofAndIndexedAccess.ts, 254, 62), Decl(keyofAndIndexedAccess.ts, 255, 100), Decl(keyofAndIndexedAccess.ts, 256, 142), Decl(keyofAndIndexedAccess.ts, 257, 59))
|
||||
>thing : Symbol(thing, Decl(keyofAndIndexedAccess.ts, 272, 12))
|
||||
>x3 : Symbol(x3, Decl(keyofAndIndexedAccess.ts, 352, 7))
|
||||
>path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 327, 1), Decl(keyofAndIndexedAccess.ts, 331, 62), Decl(keyofAndIndexedAccess.ts, 332, 100), Decl(keyofAndIndexedAccess.ts, 333, 142), Decl(keyofAndIndexedAccess.ts, 334, 59))
|
||||
>thing : Symbol(thing, Decl(keyofAndIndexedAccess.ts, 349, 12))
|
||||
|
||||
let x4 = path(thing, ...['a', 'x']); // any
|
||||
>x4 : Symbol(x4, Decl(keyofAndIndexedAccess.ts, 276, 7))
|
||||
>path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 250, 1), Decl(keyofAndIndexedAccess.ts, 254, 62), Decl(keyofAndIndexedAccess.ts, 255, 100), Decl(keyofAndIndexedAccess.ts, 256, 142), Decl(keyofAndIndexedAccess.ts, 257, 59))
|
||||
>thing : Symbol(thing, Decl(keyofAndIndexedAccess.ts, 272, 12))
|
||||
>x4 : Symbol(x4, Decl(keyofAndIndexedAccess.ts, 353, 7))
|
||||
>path : Symbol(path, Decl(keyofAndIndexedAccess.ts, 327, 1), Decl(keyofAndIndexedAccess.ts, 331, 62), Decl(keyofAndIndexedAccess.ts, 332, 100), Decl(keyofAndIndexedAccess.ts, 333, 142), Decl(keyofAndIndexedAccess.ts, 334, 59))
|
||||
>thing : Symbol(thing, Decl(keyofAndIndexedAccess.ts, 349, 12))
|
||||
}
|
||||
|
||||
// Repro from comment in #12114
|
||||
|
||||
const assignTo2 = <T, K1 extends keyof T, K2 extends keyof T[K1]>(object: T, key1: K1, key2: K2) =>
|
||||
>assignTo2 : Symbol(assignTo2, Decl(keyofAndIndexedAccess.ts, 281, 5))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 281, 19))
|
||||
>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 281, 21))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 281, 19))
|
||||
>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 281, 41))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 281, 19))
|
||||
>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 281, 21))
|
||||
>object : Symbol(object, Decl(keyofAndIndexedAccess.ts, 281, 66))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 281, 19))
|
||||
>key1 : Symbol(key1, Decl(keyofAndIndexedAccess.ts, 281, 76))
|
||||
>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 281, 21))
|
||||
>key2 : Symbol(key2, Decl(keyofAndIndexedAccess.ts, 281, 86))
|
||||
>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 281, 41))
|
||||
>assignTo2 : Symbol(assignTo2, Decl(keyofAndIndexedAccess.ts, 358, 5))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 358, 19))
|
||||
>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 358, 21))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 358, 19))
|
||||
>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 358, 41))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 358, 19))
|
||||
>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 358, 21))
|
||||
>object : Symbol(object, Decl(keyofAndIndexedAccess.ts, 358, 66))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 358, 19))
|
||||
>key1 : Symbol(key1, Decl(keyofAndIndexedAccess.ts, 358, 76))
|
||||
>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 358, 21))
|
||||
>key2 : Symbol(key2, Decl(keyofAndIndexedAccess.ts, 358, 86))
|
||||
>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 358, 41))
|
||||
|
||||
(value: T[K1][K2]) => object[key1][key2] = value;
|
||||
>value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 282, 5))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 281, 19))
|
||||
>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 281, 21))
|
||||
>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 281, 41))
|
||||
>object : Symbol(object, Decl(keyofAndIndexedAccess.ts, 281, 66))
|
||||
>key1 : Symbol(key1, Decl(keyofAndIndexedAccess.ts, 281, 76))
|
||||
>key2 : Symbol(key2, Decl(keyofAndIndexedAccess.ts, 281, 86))
|
||||
>value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 282, 5))
|
||||
>value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 359, 5))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 358, 19))
|
||||
>K1 : Symbol(K1, Decl(keyofAndIndexedAccess.ts, 358, 21))
|
||||
>K2 : Symbol(K2, Decl(keyofAndIndexedAccess.ts, 358, 41))
|
||||
>object : Symbol(object, Decl(keyofAndIndexedAccess.ts, 358, 66))
|
||||
>key1 : Symbol(key1, Decl(keyofAndIndexedAccess.ts, 358, 76))
|
||||
>key2 : Symbol(key2, Decl(keyofAndIndexedAccess.ts, 358, 86))
|
||||
>value : Symbol(value, Decl(keyofAndIndexedAccess.ts, 359, 5))
|
||||
|
||||
// Modified repro from #12573
|
||||
|
||||
declare function one<T>(handler: (t: T) => void): T
|
||||
>one : Symbol(one, Decl(keyofAndIndexedAccess.ts, 282, 53))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 286, 21))
|
||||
>handler : Symbol(handler, Decl(keyofAndIndexedAccess.ts, 286, 24))
|
||||
>t : Symbol(t, Decl(keyofAndIndexedAccess.ts, 286, 34))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 286, 21))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 286, 21))
|
||||
>one : Symbol(one, Decl(keyofAndIndexedAccess.ts, 359, 53))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 363, 21))
|
||||
>handler : Symbol(handler, Decl(keyofAndIndexedAccess.ts, 363, 24))
|
||||
>t : Symbol(t, Decl(keyofAndIndexedAccess.ts, 363, 34))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 363, 21))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 363, 21))
|
||||
|
||||
var empty = one(() => {}) // inferred as {}, expected
|
||||
>empty : Symbol(empty, Decl(keyofAndIndexedAccess.ts, 287, 3))
|
||||
>one : Symbol(one, Decl(keyofAndIndexedAccess.ts, 282, 53))
|
||||
>empty : Symbol(empty, Decl(keyofAndIndexedAccess.ts, 364, 3))
|
||||
>one : Symbol(one, Decl(keyofAndIndexedAccess.ts, 359, 53))
|
||||
|
||||
type Handlers<T> = { [K in keyof T]: (t: T[K]) => void }
|
||||
>Handlers : Symbol(Handlers, Decl(keyofAndIndexedAccess.ts, 287, 25))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 289, 14))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 289, 22))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 289, 14))
|
||||
>t : Symbol(t, Decl(keyofAndIndexedAccess.ts, 289, 38))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 289, 14))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 289, 22))
|
||||
>Handlers : Symbol(Handlers, Decl(keyofAndIndexedAccess.ts, 364, 25))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 366, 14))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 366, 22))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 366, 14))
|
||||
>t : Symbol(t, Decl(keyofAndIndexedAccess.ts, 366, 38))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 366, 14))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 366, 22))
|
||||
|
||||
declare function on<T>(handlerHash: Handlers<T>): T
|
||||
>on : Symbol(on, Decl(keyofAndIndexedAccess.ts, 289, 56))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 290, 20))
|
||||
>handlerHash : Symbol(handlerHash, Decl(keyofAndIndexedAccess.ts, 290, 23))
|
||||
>Handlers : Symbol(Handlers, Decl(keyofAndIndexedAccess.ts, 287, 25))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 290, 20))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 290, 20))
|
||||
>on : Symbol(on, Decl(keyofAndIndexedAccess.ts, 366, 56))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 367, 20))
|
||||
>handlerHash : Symbol(handlerHash, Decl(keyofAndIndexedAccess.ts, 367, 23))
|
||||
>Handlers : Symbol(Handlers, Decl(keyofAndIndexedAccess.ts, 364, 25))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 367, 20))
|
||||
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 367, 20))
|
||||
|
||||
var hashOfEmpty1 = on({ test: () => {} }); // {}
|
||||
>hashOfEmpty1 : Symbol(hashOfEmpty1, Decl(keyofAndIndexedAccess.ts, 291, 3))
|
||||
>on : Symbol(on, Decl(keyofAndIndexedAccess.ts, 289, 56))
|
||||
>test : Symbol(test, Decl(keyofAndIndexedAccess.ts, 291, 23))
|
||||
>hashOfEmpty1 : Symbol(hashOfEmpty1, Decl(keyofAndIndexedAccess.ts, 368, 3))
|
||||
>on : Symbol(on, Decl(keyofAndIndexedAccess.ts, 366, 56))
|
||||
>test : Symbol(test, Decl(keyofAndIndexedAccess.ts, 368, 23))
|
||||
|
||||
var hashOfEmpty2 = on({ test: (x: boolean) => {} }); // { test: boolean }
|
||||
>hashOfEmpty2 : Symbol(hashOfEmpty2, Decl(keyofAndIndexedAccess.ts, 292, 3))
|
||||
>on : Symbol(on, Decl(keyofAndIndexedAccess.ts, 289, 56))
|
||||
>test : Symbol(test, Decl(keyofAndIndexedAccess.ts, 292, 23))
|
||||
>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 292, 31))
|
||||
>hashOfEmpty2 : Symbol(hashOfEmpty2, Decl(keyofAndIndexedAccess.ts, 369, 3))
|
||||
>on : Symbol(on, Decl(keyofAndIndexedAccess.ts, 366, 56))
|
||||
>test : Symbol(test, Decl(keyofAndIndexedAccess.ts, 369, 23))
|
||||
>x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 369, 31))
|
||||
|
||||
// Repro from #12624
|
||||
|
||||
interface Options1<Data, Computed> {
|
||||
>Options1 : Symbol(Options1, Decl(keyofAndIndexedAccess.ts, 369, 52))
|
||||
>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 373, 19))
|
||||
>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 373, 24))
|
||||
|
||||
data?: Data
|
||||
>data : Symbol(Options1.data, Decl(keyofAndIndexedAccess.ts, 373, 36))
|
||||
>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 373, 19))
|
||||
|
||||
computed?: Computed;
|
||||
>computed : Symbol(Options1.computed, Decl(keyofAndIndexedAccess.ts, 374, 15))
|
||||
>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 373, 24))
|
||||
}
|
||||
|
||||
declare class Component1<Data, Computed> {
|
||||
>Component1 : Symbol(Component1, Decl(keyofAndIndexedAccess.ts, 376, 1))
|
||||
>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 378, 25))
|
||||
>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 378, 30))
|
||||
|
||||
constructor(options: Options1<Data, Computed>);
|
||||
>options : Symbol(options, Decl(keyofAndIndexedAccess.ts, 379, 16))
|
||||
>Options1 : Symbol(Options1, Decl(keyofAndIndexedAccess.ts, 369, 52))
|
||||
>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 378, 25))
|
||||
>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 378, 30))
|
||||
|
||||
get<K extends keyof (Data & Computed)>(key: K): (Data & Computed)[K];
|
||||
>get : Symbol(Component1.get, Decl(keyofAndIndexedAccess.ts, 379, 51))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 380, 8))
|
||||
>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 378, 25))
|
||||
>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 378, 30))
|
||||
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 380, 43))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 380, 8))
|
||||
>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 378, 25))
|
||||
>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 378, 30))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 380, 8))
|
||||
}
|
||||
|
||||
let c1 = new Component1({
|
||||
>c1 : Symbol(c1, Decl(keyofAndIndexedAccess.ts, 383, 3))
|
||||
>Component1 : Symbol(Component1, Decl(keyofAndIndexedAccess.ts, 376, 1))
|
||||
|
||||
data: {
|
||||
>data : Symbol(data, Decl(keyofAndIndexedAccess.ts, 383, 25))
|
||||
|
||||
hello: ""
|
||||
>hello : Symbol(hello, Decl(keyofAndIndexedAccess.ts, 384, 11))
|
||||
}
|
||||
});
|
||||
|
||||
c1.get("hello");
|
||||
>c1.get : Symbol(Component1.get, Decl(keyofAndIndexedAccess.ts, 379, 51))
|
||||
>c1 : Symbol(c1, Decl(keyofAndIndexedAccess.ts, 383, 3))
|
||||
>get : Symbol(Component1.get, Decl(keyofAndIndexedAccess.ts, 379, 51))
|
||||
|
||||
// Repro from #12625
|
||||
|
||||
interface Options2<Data, Computed> {
|
||||
>Options2 : Symbol(Options2, Decl(keyofAndIndexedAccess.ts, 389, 16))
|
||||
>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 393, 19))
|
||||
>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 393, 24))
|
||||
|
||||
data?: Data
|
||||
>data : Symbol(Options2.data, Decl(keyofAndIndexedAccess.ts, 393, 36))
|
||||
>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 393, 19))
|
||||
|
||||
computed?: Computed;
|
||||
>computed : Symbol(Options2.computed, Decl(keyofAndIndexedAccess.ts, 394, 15))
|
||||
>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 393, 24))
|
||||
}
|
||||
|
||||
declare class Component2<Data, Computed> {
|
||||
>Component2 : Symbol(Component2, Decl(keyofAndIndexedAccess.ts, 396, 1))
|
||||
>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 398, 25))
|
||||
>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 398, 30))
|
||||
|
||||
constructor(options: Options2<Data, Computed>);
|
||||
>options : Symbol(options, Decl(keyofAndIndexedAccess.ts, 399, 16))
|
||||
>Options2 : Symbol(Options2, Decl(keyofAndIndexedAccess.ts, 389, 16))
|
||||
>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 398, 25))
|
||||
>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 398, 30))
|
||||
|
||||
get<K extends keyof Data | keyof Computed>(key: K): (Data & Computed)[K];
|
||||
>get : Symbol(Component2.get, Decl(keyofAndIndexedAccess.ts, 399, 51))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 400, 8))
|
||||
>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 398, 25))
|
||||
>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 398, 30))
|
||||
>key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 400, 47))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 400, 8))
|
||||
>Data : Symbol(Data, Decl(keyofAndIndexedAccess.ts, 398, 25))
|
||||
>Computed : Symbol(Computed, Decl(keyofAndIndexedAccess.ts, 398, 30))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 400, 8))
|
||||
}
|
||||
|
||||
// Repro from #12641
|
||||
|
||||
interface R {
|
||||
>R : Symbol(R, Decl(keyofAndIndexedAccess.ts, 401, 1))
|
||||
|
||||
p: number;
|
||||
>p : Symbol(R.p, Decl(keyofAndIndexedAccess.ts, 405, 13))
|
||||
}
|
||||
|
||||
function f<K extends keyof R>(p: K) {
|
||||
>f : Symbol(f, Decl(keyofAndIndexedAccess.ts, 407, 1))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 409, 11))
|
||||
>R : Symbol(R, Decl(keyofAndIndexedAccess.ts, 401, 1))
|
||||
>p : Symbol(p, Decl(keyofAndIndexedAccess.ts, 409, 30))
|
||||
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 409, 11))
|
||||
|
||||
let a: any;
|
||||
>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 410, 7))
|
||||
|
||||
a[p].add; // any
|
||||
>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 410, 7))
|
||||
>p : Symbol(p, Decl(keyofAndIndexedAccess.ts, 409, 30))
|
||||
}
|
||||
|
||||
// Repro from #12651
|
||||
|
||||
type MethodDescriptor = {
|
||||
>MethodDescriptor : Symbol(MethodDescriptor, Decl(keyofAndIndexedAccess.ts, 412, 1))
|
||||
|
||||
name: string;
|
||||
>name : Symbol(name, Decl(keyofAndIndexedAccess.ts, 416, 25))
|
||||
|
||||
args: any[];
|
||||
>args : Symbol(args, Decl(keyofAndIndexedAccess.ts, 417, 14))
|
||||
|
||||
returnValue: any;
|
||||
>returnValue : Symbol(returnValue, Decl(keyofAndIndexedAccess.ts, 418, 13))
|
||||
}
|
||||
|
||||
declare function dispatchMethod<M extends MethodDescriptor>(name: M['name'], args: M['args']): M['returnValue'];
|
||||
>dispatchMethod : Symbol(dispatchMethod, Decl(keyofAndIndexedAccess.ts, 420, 1))
|
||||
>M : Symbol(M, Decl(keyofAndIndexedAccess.ts, 422, 32))
|
||||
>MethodDescriptor : Symbol(MethodDescriptor, Decl(keyofAndIndexedAccess.ts, 412, 1))
|
||||
>name : Symbol(name, Decl(keyofAndIndexedAccess.ts, 422, 60))
|
||||
>M : Symbol(M, Decl(keyofAndIndexedAccess.ts, 422, 32))
|
||||
>args : Symbol(args, Decl(keyofAndIndexedAccess.ts, 422, 76))
|
||||
>M : Symbol(M, Decl(keyofAndIndexedAccess.ts, 422, 32))
|
||||
>M : Symbol(M, Decl(keyofAndIndexedAccess.ts, 422, 32))
|
||||
|
||||
type SomeMethodDescriptor = {
|
||||
>SomeMethodDescriptor : Symbol(SomeMethodDescriptor, Decl(keyofAndIndexedAccess.ts, 422, 112))
|
||||
|
||||
name: "someMethod";
|
||||
>name : Symbol(name, Decl(keyofAndIndexedAccess.ts, 424, 29))
|
||||
|
||||
args: [string, number];
|
||||
>args : Symbol(args, Decl(keyofAndIndexedAccess.ts, 425, 20))
|
||||
|
||||
returnValue: string[];
|
||||
>returnValue : Symbol(returnValue, Decl(keyofAndIndexedAccess.ts, 426, 24))
|
||||
}
|
||||
|
||||
let result = dispatchMethod<SomeMethodDescriptor>("someMethod", ["hello", 35]);
|
||||
>result : Symbol(result, Decl(keyofAndIndexedAccess.ts, 430, 3))
|
||||
>dispatchMethod : Symbol(dispatchMethod, Decl(keyofAndIndexedAccess.ts, 420, 1))
|
||||
>SomeMethodDescriptor : Symbol(SomeMethodDescriptor, Decl(keyofAndIndexedAccess.ts, 422, 112))
|
||||
|
||||
|
||||
@@ -626,8 +626,8 @@ function f33<S extends Shape, K extends keyof S>(shape: S, key: K) {
|
||||
>K : K
|
||||
|
||||
let name = getProperty(shape, "name");
|
||||
>name : string
|
||||
>getProperty(shape, "name") : string
|
||||
>name : S["name"]
|
||||
>getProperty(shape, "name") : S["name"]
|
||||
>getProperty : <T, K extends keyof T>(obj: T, key: K) => T[K]
|
||||
>shape : S
|
||||
>"name" : "name"
|
||||
@@ -780,8 +780,8 @@ function f52<T>(obj: { [x: string]: boolean }, k: keyof T, s: string, n: number)
|
||||
>n : number
|
||||
|
||||
const x3 = obj[k];
|
||||
>x3 : boolean
|
||||
>obj[k] : boolean
|
||||
>x3 : { [x: string]: boolean; }[keyof T]
|
||||
>obj[k] : { [x: string]: boolean; }[keyof T]
|
||||
>obj : { [x: string]: boolean; }
|
||||
>k : keyof T
|
||||
}
|
||||
@@ -888,6 +888,503 @@ function f60<T>(source: T, target: T) {
|
||||
}
|
||||
}
|
||||
|
||||
function f70(func: <T, U>(k1: keyof (T | U), k2: keyof (T & U)) => void) {
|
||||
>f70 : (func: <T, U>(k1: keyof (T | U), k2: keyof (T & U)) => void) => void
|
||||
>func : <T, U>(k1: keyof (T | U), k2: keyof (T & U)) => void
|
||||
>T : T
|
||||
>U : U
|
||||
>k1 : keyof (T | U)
|
||||
>T : T
|
||||
>U : U
|
||||
>k2 : keyof (T & U)
|
||||
>T : T
|
||||
>U : U
|
||||
|
||||
func<{ a: any, b: any }, { a: any, c: any }>('a', 'a');
|
||||
>func<{ a: any, b: any }, { a: any, c: any }>('a', 'a') : void
|
||||
>func : <T, U>(k1: keyof (T | U), k2: keyof (T & U)) => void
|
||||
>a : any
|
||||
>b : any
|
||||
>a : any
|
||||
>c : any
|
||||
>'a' : "a"
|
||||
>'a' : "a"
|
||||
|
||||
func<{ a: any, b: any }, { a: any, c: any }>('a', 'b');
|
||||
>func<{ a: any, b: any }, { a: any, c: any }>('a', 'b') : void
|
||||
>func : <T, U>(k1: keyof (T | U), k2: keyof (T & U)) => void
|
||||
>a : any
|
||||
>b : any
|
||||
>a : any
|
||||
>c : any
|
||||
>'a' : "a"
|
||||
>'b' : "b"
|
||||
|
||||
func<{ a: any, b: any }, { a: any, c: any }>('a', 'c');
|
||||
>func<{ a: any, b: any }, { a: any, c: any }>('a', 'c') : void
|
||||
>func : <T, U>(k1: keyof (T | U), k2: keyof (T & U)) => void
|
||||
>a : any
|
||||
>b : any
|
||||
>a : any
|
||||
>c : any
|
||||
>'a' : "a"
|
||||
>'c' : "c"
|
||||
}
|
||||
|
||||
function f71(func: <T, U>(x: T, y: U) => Partial<T & U>) {
|
||||
>f71 : (func: <T, U>(x: T, y: U) => Partial<T & U>) => void
|
||||
>func : <T, U>(x: T, y: U) => Partial<T & U>
|
||||
>T : T
|
||||
>U : U
|
||||
>x : T
|
||||
>T : T
|
||||
>y : U
|
||||
>U : U
|
||||
>Partial : Partial<T>
|
||||
>T : T
|
||||
>U : U
|
||||
|
||||
let x = func({ a: 1, b: "hello" }, { c: true });
|
||||
>x : Partial<{ a: number; b: string; } & { c: boolean; }>
|
||||
>func({ a: 1, b: "hello" }, { c: true }) : Partial<{ a: number; b: string; } & { c: boolean; }>
|
||||
>func : <T, U>(x: T, y: U) => Partial<T & U>
|
||||
>{ a: 1, b: "hello" } : { a: number; b: string; }
|
||||
>a : number
|
||||
>1 : 1
|
||||
>b : string
|
||||
>"hello" : "hello"
|
||||
>{ c: true } : { c: true; }
|
||||
>c : boolean
|
||||
>true : true
|
||||
|
||||
x.a; // number | undefined
|
||||
>x.a : number | undefined
|
||||
>x : Partial<{ a: number; b: string; } & { c: boolean; }>
|
||||
>a : number | undefined
|
||||
|
||||
x.b; // string | undefined
|
||||
>x.b : string | undefined
|
||||
>x : Partial<{ a: number; b: string; } & { c: boolean; }>
|
||||
>b : string | undefined
|
||||
|
||||
x.c; // boolean | undefined
|
||||
>x.c : boolean | undefined
|
||||
>x : Partial<{ a: number; b: string; } & { c: boolean; }>
|
||||
>c : boolean | undefined
|
||||
}
|
||||
|
||||
function f72(func: <T, U, K extends keyof T | keyof U>(x: T, y: U, k: K) => (T & U)[K]) {
|
||||
>f72 : (func: <T, U, K extends keyof T | keyof U>(x: T, y: U, k: K) => (T & U)[K]) => void
|
||||
>func : <T, U, K extends keyof T | keyof U>(x: T, y: U, k: K) => (T & U)[K]
|
||||
>T : T
|
||||
>U : U
|
||||
>K : K
|
||||
>T : T
|
||||
>U : U
|
||||
>x : T
|
||||
>T : T
|
||||
>y : U
|
||||
>U : U
|
||||
>k : K
|
||||
>K : K
|
||||
>T : T
|
||||
>U : U
|
||||
>K : K
|
||||
|
||||
let a = func({ a: 1, b: "hello" }, { c: true }, 'a'); // number
|
||||
>a : number
|
||||
>func({ a: 1, b: "hello" }, { c: true }, 'a') : number
|
||||
>func : <T, U, K extends keyof T | keyof U>(x: T, y: U, k: K) => (T & U)[K]
|
||||
>{ a: 1, b: "hello" } : { a: number; b: string; }
|
||||
>a : number
|
||||
>1 : 1
|
||||
>b : string
|
||||
>"hello" : "hello"
|
||||
>{ c: true } : { c: true; }
|
||||
>c : boolean
|
||||
>true : true
|
||||
>'a' : "a"
|
||||
|
||||
let b = func({ a: 1, b: "hello" }, { c: true }, 'b'); // string
|
||||
>b : string
|
||||
>func({ a: 1, b: "hello" }, { c: true }, 'b') : string
|
||||
>func : <T, U, K extends keyof T | keyof U>(x: T, y: U, k: K) => (T & U)[K]
|
||||
>{ a: 1, b: "hello" } : { a: number; b: string; }
|
||||
>a : number
|
||||
>1 : 1
|
||||
>b : string
|
||||
>"hello" : "hello"
|
||||
>{ c: true } : { c: true; }
|
||||
>c : boolean
|
||||
>true : true
|
||||
>'b' : "b"
|
||||
|
||||
let c = func({ a: 1, b: "hello" }, { c: true }, 'c'); // boolean
|
||||
>c : boolean
|
||||
>func({ a: 1, b: "hello" }, { c: true }, 'c') : boolean
|
||||
>func : <T, U, K extends keyof T | keyof U>(x: T, y: U, k: K) => (T & U)[K]
|
||||
>{ a: 1, b: "hello" } : { a: number; b: string; }
|
||||
>a : number
|
||||
>1 : 1
|
||||
>b : string
|
||||
>"hello" : "hello"
|
||||
>{ c: true } : { c: true; }
|
||||
>c : boolean
|
||||
>true : true
|
||||
>'c' : "c"
|
||||
}
|
||||
|
||||
function f73(func: <T, U, K extends keyof (T & U)>(x: T, y: U, k: K) => (T & U)[K]) {
|
||||
>f73 : (func: <T, U, K extends keyof (T & U)>(x: T, y: U, k: K) => (T & U)[K]) => void
|
||||
>func : <T, U, K extends keyof (T & U)>(x: T, y: U, k: K) => (T & U)[K]
|
||||
>T : T
|
||||
>U : U
|
||||
>K : K
|
||||
>T : T
|
||||
>U : U
|
||||
>x : T
|
||||
>T : T
|
||||
>y : U
|
||||
>U : U
|
||||
>k : K
|
||||
>K : K
|
||||
>T : T
|
||||
>U : U
|
||||
>K : K
|
||||
|
||||
let a = func({ a: 1, b: "hello" }, { c: true }, 'a'); // number
|
||||
>a : number
|
||||
>func({ a: 1, b: "hello" }, { c: true }, 'a') : number
|
||||
>func : <T, U, K extends keyof (T & U)>(x: T, y: U, k: K) => (T & U)[K]
|
||||
>{ a: 1, b: "hello" } : { a: number; b: string; }
|
||||
>a : number
|
||||
>1 : 1
|
||||
>b : string
|
||||
>"hello" : "hello"
|
||||
>{ c: true } : { c: true; }
|
||||
>c : boolean
|
||||
>true : true
|
||||
>'a' : "a"
|
||||
|
||||
let b = func({ a: 1, b: "hello" }, { c: true }, 'b'); // string
|
||||
>b : string
|
||||
>func({ a: 1, b: "hello" }, { c: true }, 'b') : string
|
||||
>func : <T, U, K extends keyof (T & U)>(x: T, y: U, k: K) => (T & U)[K]
|
||||
>{ a: 1, b: "hello" } : { a: number; b: string; }
|
||||
>a : number
|
||||
>1 : 1
|
||||
>b : string
|
||||
>"hello" : "hello"
|
||||
>{ c: true } : { c: true; }
|
||||
>c : boolean
|
||||
>true : true
|
||||
>'b' : "b"
|
||||
|
||||
let c = func({ a: 1, b: "hello" }, { c: true }, 'c'); // boolean
|
||||
>c : boolean
|
||||
>func({ a: 1, b: "hello" }, { c: true }, 'c') : boolean
|
||||
>func : <T, U, K extends keyof (T & U)>(x: T, y: U, k: K) => (T & U)[K]
|
||||
>{ a: 1, b: "hello" } : { a: number; b: string; }
|
||||
>a : number
|
||||
>1 : 1
|
||||
>b : string
|
||||
>"hello" : "hello"
|
||||
>{ c: true } : { c: true; }
|
||||
>c : boolean
|
||||
>true : true
|
||||
>'c' : "c"
|
||||
}
|
||||
|
||||
function f74(func: <T, U, K extends keyof (T | U)>(x: T, y: U, k: K) => (T | U)[K]) {
|
||||
>f74 : (func: <T, U, K extends keyof (T | U)>(x: T, y: U, k: K) => (T | U)[K]) => void
|
||||
>func : <T, U, K extends keyof (T | U)>(x: T, y: U, k: K) => (T | U)[K]
|
||||
>T : T
|
||||
>U : U
|
||||
>K : K
|
||||
>T : T
|
||||
>U : U
|
||||
>x : T
|
||||
>T : T
|
||||
>y : U
|
||||
>U : U
|
||||
>k : K
|
||||
>K : K
|
||||
>T : T
|
||||
>U : U
|
||||
>K : K
|
||||
|
||||
let a = func({ a: 1, b: "hello" }, { a: 2, b: true }, 'a'); // number
|
||||
>a : number
|
||||
>func({ a: 1, b: "hello" }, { a: 2, b: true }, 'a') : number
|
||||
>func : <T, U, K extends keyof (T | U)>(x: T, y: U, k: K) => (T | U)[K]
|
||||
>{ a: 1, b: "hello" } : { a: number; b: string; }
|
||||
>a : number
|
||||
>1 : 1
|
||||
>b : string
|
||||
>"hello" : "hello"
|
||||
>{ a: 2, b: true } : { a: number; b: true; }
|
||||
>a : number
|
||||
>2 : 2
|
||||
>b : boolean
|
||||
>true : true
|
||||
>'a' : "a"
|
||||
|
||||
let b = func({ a: 1, b: "hello" }, { a: 2, b: true }, 'b'); // string | boolean
|
||||
>b : string | boolean
|
||||
>func({ a: 1, b: "hello" }, { a: 2, b: true }, 'b') : string | boolean
|
||||
>func : <T, U, K extends keyof (T | U)>(x: T, y: U, k: K) => (T | U)[K]
|
||||
>{ a: 1, b: "hello" } : { a: number; b: string; }
|
||||
>a : number
|
||||
>1 : 1
|
||||
>b : string
|
||||
>"hello" : "hello"
|
||||
>{ a: 2, b: true } : { a: number; b: true; }
|
||||
>a : number
|
||||
>2 : 2
|
||||
>b : boolean
|
||||
>true : true
|
||||
>'b' : "b"
|
||||
}
|
||||
|
||||
function f80<T extends { a: { x: any } }>(obj: T) {
|
||||
>f80 : <T extends { a: { x: any; }; }>(obj: T) => void
|
||||
>T : T
|
||||
>a : { x: any; }
|
||||
>x : any
|
||||
>obj : T
|
||||
>T : T
|
||||
|
||||
let a1 = obj.a; // { x: any }
|
||||
>a1 : { x: any; }
|
||||
>obj.a : { x: any; }
|
||||
>obj : T
|
||||
>a : { x: any; }
|
||||
|
||||
let a2 = obj['a']; // { x: any }
|
||||
>a2 : { x: any; }
|
||||
>obj['a'] : { x: any; }
|
||||
>obj : T
|
||||
>'a' : "a"
|
||||
|
||||
let a3 = obj['a'] as T['a']; // T["a"]
|
||||
>a3 : T["a"]
|
||||
>obj['a'] as T['a'] : T["a"]
|
||||
>obj['a'] : { x: any; }
|
||||
>obj : T
|
||||
>'a' : "a"
|
||||
>T : T
|
||||
|
||||
let x1 = obj.a.x; // any
|
||||
>x1 : any
|
||||
>obj.a.x : any
|
||||
>obj.a : { x: any; }
|
||||
>obj : T
|
||||
>a : { x: any; }
|
||||
>x : any
|
||||
|
||||
let x2 = obj['a']['x']; // any
|
||||
>x2 : any
|
||||
>obj['a']['x'] : any
|
||||
>obj['a'] : { x: any; }
|
||||
>obj : T
|
||||
>'a' : "a"
|
||||
>'x' : "x"
|
||||
|
||||
let x3 = obj['a']['x'] as T['a']['x']; // T["a"]["x"]
|
||||
>x3 : T["a"]["x"]
|
||||
>obj['a']['x'] as T['a']['x'] : T["a"]["x"]
|
||||
>obj['a']['x'] : any
|
||||
>obj['a'] : { x: any; }
|
||||
>obj : T
|
||||
>'a' : "a"
|
||||
>'x' : "x"
|
||||
>T : T
|
||||
}
|
||||
|
||||
function f81<T extends { a: { x: any } }>(obj: T) {
|
||||
>f81 : <T extends { a: { x: any; }; }>(obj: T) => T["a"]["x"]
|
||||
>T : T
|
||||
>a : { x: any; }
|
||||
>x : any
|
||||
>obj : T
|
||||
>T : T
|
||||
|
||||
return obj['a']['x'] as T['a']['x'];
|
||||
>obj['a']['x'] as T['a']['x'] : T["a"]["x"]
|
||||
>obj['a']['x'] : any
|
||||
>obj['a'] : { x: any; }
|
||||
>obj : T
|
||||
>'a' : "a"
|
||||
>'x' : "x"
|
||||
>T : T
|
||||
}
|
||||
|
||||
function f82() {
|
||||
>f82 : () => void
|
||||
|
||||
let x1 = f81({ a: { x: "hello" } }); // string
|
||||
>x1 : string
|
||||
>f81({ a: { x: "hello" } }) : string
|
||||
>f81 : <T extends { a: { x: any; }; }>(obj: T) => T["a"]["x"]
|
||||
>{ a: { x: "hello" } } : { a: { x: string; }; }
|
||||
>a : { x: string; }
|
||||
>{ x: "hello" } : { x: string; }
|
||||
>x : string
|
||||
>"hello" : "hello"
|
||||
|
||||
let x2 = f81({ a: { x: 42 } }); // number
|
||||
>x2 : number
|
||||
>f81({ a: { x: 42 } }) : number
|
||||
>f81 : <T extends { a: { x: any; }; }>(obj: T) => T["a"]["x"]
|
||||
>{ a: { x: 42 } } : { a: { x: number; }; }
|
||||
>a : { x: number; }
|
||||
>{ x: 42 } : { x: number; }
|
||||
>x : number
|
||||
>42 : 42
|
||||
}
|
||||
|
||||
function f83<T extends { [x: string]: { x: any } }, K extends keyof T>(obj: T, key: K) {
|
||||
>f83 : <T extends { [x: string]: { x: any; }; }, K extends keyof T>(obj: T, key: K) => T[K]["x"]
|
||||
>T : T
|
||||
>x : string
|
||||
>x : any
|
||||
>K : K
|
||||
>T : T
|
||||
>obj : T
|
||||
>T : T
|
||||
>key : K
|
||||
>K : K
|
||||
|
||||
return obj[key]['x'] as T[K]['x'];
|
||||
>obj[key]['x'] as T[K]['x'] : T[K]["x"]
|
||||
>obj[key]['x'] : any
|
||||
>obj[key] : T[K]
|
||||
>obj : T
|
||||
>key : K
|
||||
>'x' : "x"
|
||||
>T : T
|
||||
>K : K
|
||||
}
|
||||
|
||||
function f84() {
|
||||
>f84 : () => void
|
||||
|
||||
let x1 = f83({ foo: { x: "hello" } }, "foo"); // string
|
||||
>x1 : string
|
||||
>f83({ foo: { x: "hello" } }, "foo") : string
|
||||
>f83 : <T extends { [x: string]: { x: any; }; }, K extends keyof T>(obj: T, key: K) => T[K]["x"]
|
||||
>{ foo: { x: "hello" } } : { foo: { x: string; }; }
|
||||
>foo : { x: string; }
|
||||
>{ x: "hello" } : { x: string; }
|
||||
>x : string
|
||||
>"hello" : "hello"
|
||||
>"foo" : "foo"
|
||||
|
||||
let x2 = f83({ bar: { x: 42 } }, "bar"); // number
|
||||
>x2 : number
|
||||
>f83({ bar: { x: 42 } }, "bar") : number
|
||||
>f83 : <T extends { [x: string]: { x: any; }; }, K extends keyof T>(obj: T, key: K) => T[K]["x"]
|
||||
>{ bar: { x: 42 } } : { bar: { x: number; }; }
|
||||
>bar : { x: number; }
|
||||
>{ x: 42 } : { x: number; }
|
||||
>x : number
|
||||
>42 : 42
|
||||
>"bar" : "bar"
|
||||
}
|
||||
|
||||
class C1 {
|
||||
>C1 : C1
|
||||
|
||||
x: number;
|
||||
>x : number
|
||||
|
||||
get<K extends keyof this>(key: K) {
|
||||
>get : <K extends keyof this>(key: K) => this[K]
|
||||
>K : K
|
||||
>key : K
|
||||
>K : K
|
||||
|
||||
return this[key];
|
||||
>this[key] : this[K]
|
||||
>this : this
|
||||
>key : K
|
||||
}
|
||||
set<K extends keyof this>(key: K, value: this[K]) {
|
||||
>set : <K extends keyof this>(key: K, value: this[K]) => void
|
||||
>K : K
|
||||
>key : K
|
||||
>K : K
|
||||
>value : this[K]
|
||||
>K : K
|
||||
|
||||
this[key] = value;
|
||||
>this[key] = value : this[K]
|
||||
>this[key] : this[K]
|
||||
>this : this
|
||||
>key : K
|
||||
>value : this[K]
|
||||
}
|
||||
foo() {
|
||||
>foo : () => void
|
||||
|
||||
let x1 = this.x; // number
|
||||
>x1 : number
|
||||
>this.x : number
|
||||
>this : this
|
||||
>x : number
|
||||
|
||||
let x2 = this["x"]; // number
|
||||
>x2 : number
|
||||
>this["x"] : number
|
||||
>this : this
|
||||
>"x" : "x"
|
||||
|
||||
let x3 = this.get("x"); // this["x"]
|
||||
>x3 : this["x"]
|
||||
>this.get("x") : this["x"]
|
||||
>this.get : <K extends keyof this>(key: K) => this[K]
|
||||
>this : this
|
||||
>get : <K extends keyof this>(key: K) => this[K]
|
||||
>"x" : "x"
|
||||
|
||||
let x4 = getProperty(this, "x"); // this["x"]
|
||||
>x4 : this["x"]
|
||||
>getProperty(this, "x") : this["x"]
|
||||
>getProperty : <T, K extends keyof T>(obj: T, key: K) => T[K]
|
||||
>this : this
|
||||
>"x" : "x"
|
||||
|
||||
this.x = 42;
|
||||
>this.x = 42 : 42
|
||||
>this.x : number
|
||||
>this : this
|
||||
>x : number
|
||||
>42 : 42
|
||||
|
||||
this["x"] = 42;
|
||||
>this["x"] = 42 : 42
|
||||
>this["x"] : number
|
||||
>this : this
|
||||
>"x" : "x"
|
||||
>42 : 42
|
||||
|
||||
this.set("x", 42);
|
||||
>this.set("x", 42) : void
|
||||
>this.set : <K extends keyof this>(key: K, value: this[K]) => void
|
||||
>this : this
|
||||
>set : <K extends keyof this>(key: K, value: this[K]) => void
|
||||
>"x" : "x"
|
||||
>42 : 42
|
||||
|
||||
setProperty(this, "x", 42);
|
||||
>setProperty(this, "x", 42) : void
|
||||
>setProperty : <T, K extends keyof T>(obj: T, key: K, value: T[K]) => void
|
||||
>this : this
|
||||
>"x" : "x"
|
||||
>42 : 42
|
||||
}
|
||||
}
|
||||
|
||||
// Repros from #12011
|
||||
|
||||
class Base {
|
||||
@@ -944,10 +1441,10 @@ class Person extends Base {
|
||||
>parts : number
|
||||
}
|
||||
getParts() {
|
||||
>getParts : () => number
|
||||
>getParts : () => this["parts"]
|
||||
|
||||
return this.get("parts")
|
||||
>this.get("parts") : number
|
||||
>this.get("parts") : this["parts"]
|
||||
>this.get : <K extends keyof this>(prop: K) => this[K]
|
||||
>this : this
|
||||
>get : <K extends keyof this>(prop: K) => this[K]
|
||||
@@ -972,10 +1469,10 @@ class OtherPerson {
|
||||
>parts : number
|
||||
}
|
||||
getParts() {
|
||||
>getParts : () => number
|
||||
>getParts : () => this["parts"]
|
||||
|
||||
return getProperty(this, "parts")
|
||||
>getProperty(this, "parts") : number
|
||||
>getProperty(this, "parts") : this["parts"]
|
||||
>getProperty : <T, K extends keyof T>(obj: T, key: K) => T[K]
|
||||
>this : this
|
||||
>"parts" : "parts"
|
||||
@@ -1202,3 +1699,179 @@ var hashOfEmpty2 = on({ test: (x: boolean) => {} }); // { test: boolean }
|
||||
>(x: boolean) => {} : (x: boolean) => void
|
||||
>x : boolean
|
||||
|
||||
// Repro from #12624
|
||||
|
||||
interface Options1<Data, Computed> {
|
||||
>Options1 : Options1<Data, Computed>
|
||||
>Data : Data
|
||||
>Computed : Computed
|
||||
|
||||
data?: Data
|
||||
>data : Data | undefined
|
||||
>Data : Data
|
||||
|
||||
computed?: Computed;
|
||||
>computed : Computed | undefined
|
||||
>Computed : Computed
|
||||
}
|
||||
|
||||
declare class Component1<Data, Computed> {
|
||||
>Component1 : Component1<Data, Computed>
|
||||
>Data : Data
|
||||
>Computed : Computed
|
||||
|
||||
constructor(options: Options1<Data, Computed>);
|
||||
>options : Options1<Data, Computed>
|
||||
>Options1 : Options1<Data, Computed>
|
||||
>Data : Data
|
||||
>Computed : Computed
|
||||
|
||||
get<K extends keyof (Data & Computed)>(key: K): (Data & Computed)[K];
|
||||
>get : <K extends keyof (Data & Computed)>(key: K) => (Data & Computed)[K]
|
||||
>K : K
|
||||
>Data : Data
|
||||
>Computed : Computed
|
||||
>key : K
|
||||
>K : K
|
||||
>Data : Data
|
||||
>Computed : Computed
|
||||
>K : K
|
||||
}
|
||||
|
||||
let c1 = new Component1({
|
||||
>c1 : Component1<{ hello: string; }, {}>
|
||||
>new Component1({ data: { hello: "" }}) : Component1<{ hello: string; }, {}>
|
||||
>Component1 : typeof Component1
|
||||
>{ data: { hello: "" }} : { data: { hello: string; }; }
|
||||
|
||||
data: {
|
||||
>data : { hello: string; }
|
||||
>{ hello: "" } : { hello: string; }
|
||||
|
||||
hello: ""
|
||||
>hello : string
|
||||
>"" : ""
|
||||
}
|
||||
});
|
||||
|
||||
c1.get("hello");
|
||||
>c1.get("hello") : string
|
||||
>c1.get : <K extends "hello">(key: K) => ({ hello: string; } & {})[K]
|
||||
>c1 : Component1<{ hello: string; }, {}>
|
||||
>get : <K extends "hello">(key: K) => ({ hello: string; } & {})[K]
|
||||
>"hello" : "hello"
|
||||
|
||||
// Repro from #12625
|
||||
|
||||
interface Options2<Data, Computed> {
|
||||
>Options2 : Options2<Data, Computed>
|
||||
>Data : Data
|
||||
>Computed : Computed
|
||||
|
||||
data?: Data
|
||||
>data : Data | undefined
|
||||
>Data : Data
|
||||
|
||||
computed?: Computed;
|
||||
>computed : Computed | undefined
|
||||
>Computed : Computed
|
||||
}
|
||||
|
||||
declare class Component2<Data, Computed> {
|
||||
>Component2 : Component2<Data, Computed>
|
||||
>Data : Data
|
||||
>Computed : Computed
|
||||
|
||||
constructor(options: Options2<Data, Computed>);
|
||||
>options : Options2<Data, Computed>
|
||||
>Options2 : Options2<Data, Computed>
|
||||
>Data : Data
|
||||
>Computed : Computed
|
||||
|
||||
get<K extends keyof Data | keyof Computed>(key: K): (Data & Computed)[K];
|
||||
>get : <K extends keyof Data | keyof Computed>(key: K) => (Data & Computed)[K]
|
||||
>K : K
|
||||
>Data : Data
|
||||
>Computed : Computed
|
||||
>key : K
|
||||
>K : K
|
||||
>Data : Data
|
||||
>Computed : Computed
|
||||
>K : K
|
||||
}
|
||||
|
||||
// Repro from #12641
|
||||
|
||||
interface R {
|
||||
>R : R
|
||||
|
||||
p: number;
|
||||
>p : number
|
||||
}
|
||||
|
||||
function f<K extends keyof R>(p: K) {
|
||||
>f : <K extends "p">(p: K) => void
|
||||
>K : K
|
||||
>R : R
|
||||
>p : K
|
||||
>K : K
|
||||
|
||||
let a: any;
|
||||
>a : any
|
||||
|
||||
a[p].add; // any
|
||||
>a[p].add : any
|
||||
>a[p] : any
|
||||
>a : any
|
||||
>p : K
|
||||
>add : any
|
||||
}
|
||||
|
||||
// Repro from #12651
|
||||
|
||||
type MethodDescriptor = {
|
||||
>MethodDescriptor : MethodDescriptor
|
||||
|
||||
name: string;
|
||||
>name : string
|
||||
|
||||
args: any[];
|
||||
>args : any[]
|
||||
|
||||
returnValue: any;
|
||||
>returnValue : any
|
||||
}
|
||||
|
||||
declare function dispatchMethod<M extends MethodDescriptor>(name: M['name'], args: M['args']): M['returnValue'];
|
||||
>dispatchMethod : <M extends MethodDescriptor>(name: M["name"], args: M["args"]) => M["returnValue"]
|
||||
>M : M
|
||||
>MethodDescriptor : MethodDescriptor
|
||||
>name : M["name"]
|
||||
>M : M
|
||||
>args : M["args"]
|
||||
>M : M
|
||||
>M : M
|
||||
|
||||
type SomeMethodDescriptor = {
|
||||
>SomeMethodDescriptor : SomeMethodDescriptor
|
||||
|
||||
name: "someMethod";
|
||||
>name : "someMethod"
|
||||
|
||||
args: [string, number];
|
||||
>args : [string, number]
|
||||
|
||||
returnValue: string[];
|
||||
>returnValue : string[]
|
||||
}
|
||||
|
||||
let result = dispatchMethod<SomeMethodDescriptor>("someMethod", ["hello", 35]);
|
||||
>result : string[]
|
||||
>dispatchMethod<SomeMethodDescriptor>("someMethod", ["hello", 35]) : string[]
|
||||
>dispatchMethod : <M extends MethodDescriptor>(name: M["name"], args: M["args"]) => M["returnValue"]
|
||||
>SomeMethodDescriptor : SomeMethodDescriptor
|
||||
>"someMethod" : "someMethod"
|
||||
>["hello", 35] : [string, number]
|
||||
>"hello" : "hello"
|
||||
>35 : 35
|
||||
|
||||
|
||||
@@ -21,9 +21,14 @@ tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(64,33): error
|
||||
tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(66,24): error TS2345: Argument of type '"size"' is not assignable to parameter of type '"name" | "width" | "height" | "visible"'.
|
||||
tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(67,24): error TS2345: Argument of type '"name" | "size"' is not assignable to parameter of type '"name" | "width" | "height" | "visible"'.
|
||||
Type '"size"' is not assignable to type '"name" | "width" | "height" | "visible"'.
|
||||
tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(72,5): error TS2536: Type 'keyof (T & U)' cannot be used to index type 'T | U'.
|
||||
tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(76,5): error TS2322: Type 'T | U' is not assignable to type 'T & U'.
|
||||
Type 'T' is not assignable to type 'T & U'.
|
||||
Type 'T' is not assignable to type 'U'.
|
||||
tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(77,5): error TS2322: Type 'keyof (T & U)' is not assignable to type 'keyof (T | U)'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts (21 errors) ====
|
||||
==== tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts (24 errors) ====
|
||||
class Shape {
|
||||
name: string;
|
||||
width: number;
|
||||
@@ -135,4 +140,23 @@ tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(67,24): error
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '"name" | "size"' is not assignable to parameter of type '"name" | "width" | "height" | "visible"'.
|
||||
!!! error TS2345: Type '"size"' is not assignable to type '"name" | "width" | "height" | "visible"'.
|
||||
}
|
||||
|
||||
function f20<T, U>(k1: keyof (T | U), k2: keyof (T & U), o1: T | U, o2: T & U) {
|
||||
o1[k1];
|
||||
o1[k2]; // Error
|
||||
~~~~~~
|
||||
!!! error TS2536: Type 'keyof (T & U)' cannot be used to index type 'T | U'.
|
||||
o2[k1];
|
||||
o2[k2];
|
||||
o1 = o2;
|
||||
o2 = o1; // Error
|
||||
~~
|
||||
!!! error TS2322: Type 'T | U' is not assignable to type 'T & U'.
|
||||
!!! error TS2322: Type 'T' is not assignable to type 'T & U'.
|
||||
!!! error TS2322: Type 'T' is not assignable to type 'U'.
|
||||
k1 = k2; // Error
|
||||
~~
|
||||
!!! error TS2322: Type 'keyof (T & U)' is not assignable to type 'keyof (T | U)'.
|
||||
k2 = k1;
|
||||
}
|
||||
@@ -66,6 +66,17 @@ function f10(shape: Shape) {
|
||||
setProperty(shape, "name", "rectangle");
|
||||
setProperty(shape, "size", 10); // Error
|
||||
setProperty(shape, cond ? "name" : "size", 10); // Error
|
||||
}
|
||||
|
||||
function f20<T, U>(k1: keyof (T | U), k2: keyof (T & U), o1: T | U, o2: T & U) {
|
||||
o1[k1];
|
||||
o1[k2]; // Error
|
||||
o2[k1];
|
||||
o2[k2];
|
||||
o1 = o2;
|
||||
o2 = o1; // Error
|
||||
k1 = k2; // Error
|
||||
k2 = k1;
|
||||
}
|
||||
|
||||
//// [keyofAndIndexedAccessErrors.js]
|
||||
@@ -88,3 +99,13 @@ function f10(shape) {
|
||||
setProperty(shape, "size", 10); // Error
|
||||
setProperty(shape, cond ? "name" : "size", 10); // Error
|
||||
}
|
||||
function f20(k1, k2, o1, o2) {
|
||||
o1[k1];
|
||||
o1[k2]; // Error
|
||||
o2[k1];
|
||||
o2[k2];
|
||||
o1 = o2;
|
||||
o2 = o1; // Error
|
||||
k1 = k2; // Error
|
||||
k2 = k1;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
tests/cases/compiler/keyofIsLiteralContexualType.ts(5,9): error TS2322: Type '("a" | "b" | "c")[]' is not assignable to type 'keyof T[]'.
|
||||
Type '"a" | "b" | "c"' is not assignable to type 'keyof T'.
|
||||
Type '"a" | "b" | "c"' is not assignable to type '"a" | "b"'.
|
||||
Type '"c"' is not assignable to type 'keyof T'.
|
||||
Type '"c"' is not assignable to type '"a" | "b"'.
|
||||
Type '"c"' is not assignable to type 'keyof T'.
|
||||
Type '"c"' is not assignable to type '"a" | "b"'.
|
||||
tests/cases/compiler/keyofIsLiteralContexualType.ts(13,11): error TS2339: Property 'b' does not exist on type 'Pick<{ a: number; b: number; c: number; }, "a" | "c">'.
|
||||
|
||||
|
||||
@@ -16,10 +14,8 @@ tests/cases/compiler/keyofIsLiteralContexualType.ts(13,11): error TS2339: Proper
|
||||
~
|
||||
!!! error TS2322: Type '("a" | "b" | "c")[]' is not assignable to type 'keyof T[]'.
|
||||
!!! error TS2322: Type '"a" | "b" | "c"' is not assignable to type 'keyof T'.
|
||||
!!! error TS2322: Type '"a" | "b" | "c"' is not assignable to type '"a" | "b"'.
|
||||
!!! error TS2322: Type '"c"' is not assignable to type 'keyof T'.
|
||||
!!! error TS2322: Type '"c"' is not assignable to type '"a" | "b"'.
|
||||
!!! error TS2322: Type '"c"' is not assignable to type 'keyof T'.
|
||||
!!! error TS2322: Type '"c"' is not assignable to type '"a" | "b"'.
|
||||
}
|
||||
|
||||
// Repro from #12455
|
||||
|
||||
@@ -20,9 +20,25 @@ tests/cases/conformance/types/mapped/mappedTypeErrors.ts(60,9): error TS2403: Su
|
||||
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(61,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type '{ [P in keyof T]: T[P]; }', but here has type '{ readonly [P in keyof T]: T[P]; }'.
|
||||
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(62,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type '{ [P in keyof T]: T[P]; }', but here has type '{ readonly [P in keyof T]?: T[P] | undefined; }'.
|
||||
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(67,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type '{ [P in keyof T]: T[P]; }', but here has type '{ [P in keyof T]: T[P][]; }'.
|
||||
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(76,45): error TS2345: Argument of type '{ x: number; }' is not assignable to parameter of type 'Readonly<{ x: number; y: number; }>'.
|
||||
Property 'y' is missing in type '{ x: number; }'.
|
||||
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(78,59): error TS2345: Argument of type '{ x: number; y: number; z: number; }' is not assignable to parameter of type 'Readonly<{ x: number; y: number; }>'.
|
||||
Object literal may only specify known properties, and 'z' does not exist in type 'Readonly<{ x: number; y: number; }>'.
|
||||
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(84,58): error TS2345: Argument of type '{ x: number; y: number; z: number; }' is not assignable to parameter of type 'Partial<{ x: number; y: number; }>'.
|
||||
Object literal may only specify known properties, and 'z' does not exist in type 'Partial<{ x: number; y: number; }>'.
|
||||
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(106,15): error TS2345: Argument of type '{ a: undefined; }' is not assignable to parameter of type 'Pick<Foo, "a">'.
|
||||
Types of property 'a' are incompatible.
|
||||
Type 'undefined' is not assignable to type 'string'.
|
||||
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(107,17): error TS2345: Argument of type '{ c: boolean; }' is not assignable to parameter of type 'Pick<Foo, "a" | "b">'.
|
||||
Object literal may only specify known properties, and 'c' does not exist in type 'Pick<Foo, "a" | "b">'.
|
||||
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(124,12): error TS2345: Argument of type '{ a: undefined; }' is not assignable to parameter of type 'Pick<Foo, "a">'.
|
||||
Types of property 'a' are incompatible.
|
||||
Type 'undefined' is not assignable to type 'string'.
|
||||
tests/cases/conformance/types/mapped/mappedTypeErrors.ts(125,14): error TS2345: Argument of type '{ c: boolean; }' is not assignable to parameter of type 'Pick<Foo, "a" | "b">'.
|
||||
Object literal may only specify known properties, and 'c' does not exist in type 'Pick<Foo, "a" | "b">'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/mapped/mappedTypeErrors.ts (14 errors) ====
|
||||
==== tests/cases/conformance/types/mapped/mappedTypeErrors.ts (21 errors) ====
|
||||
|
||||
interface Shape {
|
||||
name: string;
|
||||
@@ -126,4 +142,85 @@ tests/cases/conformance/types/mapped/mappedTypeErrors.ts(67,9): error TS2403: Su
|
||||
var x: { [P in keyof T]: T[P][] }; // Error
|
||||
~
|
||||
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type '{ [P in keyof T]: T[P]; }', but here has type '{ [P in keyof T]: T[P][]; }'.
|
||||
}
|
||||
}
|
||||
|
||||
// Check that inferences to mapped types are secondary
|
||||
|
||||
declare function objAndReadonly<T>(primary: T, secondary: Readonly<T>): T;
|
||||
declare function objAndPartial<T>(primary: T, secondary: Partial<T>): T;
|
||||
|
||||
function f20() {
|
||||
let x1 = objAndReadonly({ x: 0, y: 0 }, { x: 1 }); // Error
|
||||
~~~~~~~~
|
||||
!!! error TS2345: Argument of type '{ x: number; }' is not assignable to parameter of type 'Readonly<{ x: number; y: number; }>'.
|
||||
!!! error TS2345: Property 'y' is missing in type '{ x: number; }'.
|
||||
let x2 = objAndReadonly({ x: 0, y: 0 }, { x: 1, y: 1 });
|
||||
let x3 = objAndReadonly({ x: 0, y: 0 }, { x: 1, y: 1, z: 1 }); // Error
|
||||
~~~~
|
||||
!!! error TS2345: Argument of type '{ x: number; y: number; z: number; }' is not assignable to parameter of type 'Readonly<{ x: number; y: number; }>'.
|
||||
!!! error TS2345: Object literal may only specify known properties, and 'z' does not exist in type 'Readonly<{ x: number; y: number; }>'.
|
||||
}
|
||||
|
||||
function f21() {
|
||||
let x1 = objAndPartial({ x: 0, y: 0 }, { x: 1 });
|
||||
let x2 = objAndPartial({ x: 0, y: 0 }, { x: 1, y: 1 });
|
||||
let x3 = objAndPartial({ x: 0, y: 0 }, { x: 1, y: 1, z: 1 }); // Error
|
||||
~~~~
|
||||
!!! error TS2345: Argument of type '{ x: number; y: number; z: number; }' is not assignable to parameter of type 'Partial<{ x: number; y: number; }>'.
|
||||
!!! error TS2345: Object literal may only specify known properties, and 'z' does not exist in type 'Partial<{ x: number; y: number; }>'.
|
||||
}
|
||||
|
||||
// Verify use of Pick<T, K> for setState functions (#12793)
|
||||
|
||||
interface Foo {
|
||||
a: string;
|
||||
b?: number;
|
||||
}
|
||||
|
||||
function setState<T, K extends keyof T>(obj: T, props: Pick<T, K>) {
|
||||
for (let k in props) {
|
||||
obj[k] = props[k];
|
||||
}
|
||||
}
|
||||
|
||||
let foo: Foo = { a: "hello", b: 42 };
|
||||
setState(foo, { a: "test", b: 43 })
|
||||
setState(foo, { a: "hi" });
|
||||
setState(foo, { b: undefined });
|
||||
setState(foo, { });
|
||||
setState(foo, foo);
|
||||
setState(foo, { a: undefined }); // Error
|
||||
~~~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '{ a: undefined; }' is not assignable to parameter of type 'Pick<Foo, "a">'.
|
||||
!!! error TS2345: Types of property 'a' are incompatible.
|
||||
!!! error TS2345: Type 'undefined' is not assignable to type 'string'.
|
||||
setState(foo, { c: true }); // Error
|
||||
~~~~~~~
|
||||
!!! error TS2345: Argument of type '{ c: boolean; }' is not assignable to parameter of type 'Pick<Foo, "a" | "b">'.
|
||||
!!! error TS2345: Object literal may only specify known properties, and 'c' does not exist in type 'Pick<Foo, "a" | "b">'.
|
||||
|
||||
class C<T> {
|
||||
state: T;
|
||||
setState<K extends keyof T>(props: Pick<T, K>) {
|
||||
for (let k in props) {
|
||||
this.state[k] = props[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let c = new C<Foo>();
|
||||
c.setState({ a: "test", b: 43 });
|
||||
c.setState({ a: "hi" });
|
||||
c.setState({ b: undefined });
|
||||
c.setState({ });
|
||||
c.setState(foo);
|
||||
c.setState({ a: undefined }); // Error
|
||||
~~~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '{ a: undefined; }' is not assignable to parameter of type 'Pick<Foo, "a">'.
|
||||
!!! error TS2345: Types of property 'a' are incompatible.
|
||||
!!! error TS2345: Type 'undefined' is not assignable to type 'string'.
|
||||
c.setState({ c: true }); // Error
|
||||
~~~~~~~
|
||||
!!! error TS2345: Argument of type '{ c: boolean; }' is not assignable to parameter of type 'Pick<Foo, "a" | "b">'.
|
||||
!!! error TS2345: Object literal may only specify known properties, and 'c' does not exist in type 'Pick<Foo, "a" | "b">'.
|
||||
|
||||
@@ -66,7 +66,65 @@ function f11<T>() {
|
||||
function f12<T>() {
|
||||
var x: { [P in keyof T]: T[P] };
|
||||
var x: { [P in keyof T]: T[P][] }; // Error
|
||||
}
|
||||
}
|
||||
|
||||
// Check that inferences to mapped types are secondary
|
||||
|
||||
declare function objAndReadonly<T>(primary: T, secondary: Readonly<T>): T;
|
||||
declare function objAndPartial<T>(primary: T, secondary: Partial<T>): T;
|
||||
|
||||
function f20() {
|
||||
let x1 = objAndReadonly({ x: 0, y: 0 }, { x: 1 }); // Error
|
||||
let x2 = objAndReadonly({ x: 0, y: 0 }, { x: 1, y: 1 });
|
||||
let x3 = objAndReadonly({ x: 0, y: 0 }, { x: 1, y: 1, z: 1 }); // Error
|
||||
}
|
||||
|
||||
function f21() {
|
||||
let x1 = objAndPartial({ x: 0, y: 0 }, { x: 1 });
|
||||
let x2 = objAndPartial({ x: 0, y: 0 }, { x: 1, y: 1 });
|
||||
let x3 = objAndPartial({ x: 0, y: 0 }, { x: 1, y: 1, z: 1 }); // Error
|
||||
}
|
||||
|
||||
// Verify use of Pick<T, K> for setState functions (#12793)
|
||||
|
||||
interface Foo {
|
||||
a: string;
|
||||
b?: number;
|
||||
}
|
||||
|
||||
function setState<T, K extends keyof T>(obj: T, props: Pick<T, K>) {
|
||||
for (let k in props) {
|
||||
obj[k] = props[k];
|
||||
}
|
||||
}
|
||||
|
||||
let foo: Foo = { a: "hello", b: 42 };
|
||||
setState(foo, { a: "test", b: 43 })
|
||||
setState(foo, { a: "hi" });
|
||||
setState(foo, { b: undefined });
|
||||
setState(foo, { });
|
||||
setState(foo, foo);
|
||||
setState(foo, { a: undefined }); // Error
|
||||
setState(foo, { c: true }); // Error
|
||||
|
||||
class C<T> {
|
||||
state: T;
|
||||
setState<K extends keyof T>(props: Pick<T, K>) {
|
||||
for (let k in props) {
|
||||
this.state[k] = props[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let c = new C<Foo>();
|
||||
c.setState({ a: "test", b: 43 });
|
||||
c.setState({ a: "hi" });
|
||||
c.setState({ b: undefined });
|
||||
c.setState({ });
|
||||
c.setState(foo);
|
||||
c.setState({ a: undefined }); // Error
|
||||
c.setState({ c: true }); // Error
|
||||
|
||||
|
||||
//// [mappedTypeErrors.js]
|
||||
function f1(x) {
|
||||
@@ -97,6 +155,47 @@ function f12() {
|
||||
var x;
|
||||
var x; // Error
|
||||
}
|
||||
function f20() {
|
||||
var x1 = objAndReadonly({ x: 0, y: 0 }, { x: 1 }); // Error
|
||||
var x2 = objAndReadonly({ x: 0, y: 0 }, { x: 1, y: 1 });
|
||||
var x3 = objAndReadonly({ x: 0, y: 0 }, { x: 1, y: 1, z: 1 }); // Error
|
||||
}
|
||||
function f21() {
|
||||
var x1 = objAndPartial({ x: 0, y: 0 }, { x: 1 });
|
||||
var x2 = objAndPartial({ x: 0, y: 0 }, { x: 1, y: 1 });
|
||||
var x3 = objAndPartial({ x: 0, y: 0 }, { x: 1, y: 1, z: 1 }); // Error
|
||||
}
|
||||
function setState(obj, props) {
|
||||
for (var k in props) {
|
||||
obj[k] = props[k];
|
||||
}
|
||||
}
|
||||
var foo = { a: "hello", b: 42 };
|
||||
setState(foo, { a: "test", b: 43 });
|
||||
setState(foo, { a: "hi" });
|
||||
setState(foo, { b: undefined });
|
||||
setState(foo, {});
|
||||
setState(foo, foo);
|
||||
setState(foo, { a: undefined }); // Error
|
||||
setState(foo, { c: true }); // Error
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.setState = function (props) {
|
||||
for (var k in props) {
|
||||
this.state[k] = props[k];
|
||||
}
|
||||
};
|
||||
return C;
|
||||
}());
|
||||
var c = new C();
|
||||
c.setState({ a: "test", b: 43 });
|
||||
c.setState({ a: "hi" });
|
||||
c.setState({ b: undefined });
|
||||
c.setState({});
|
||||
c.setState(foo);
|
||||
c.setState({ a: undefined }); // Error
|
||||
c.setState({ c: true }); // Error
|
||||
|
||||
|
||||
//// [mappedTypeErrors.d.ts]
|
||||
@@ -137,3 +236,18 @@ declare function f4<T extends keyof Named>(x: T): void;
|
||||
declare function f10<T>(): void;
|
||||
declare function f11<T>(): void;
|
||||
declare function f12<T>(): void;
|
||||
declare function objAndReadonly<T>(primary: T, secondary: Readonly<T>): T;
|
||||
declare function objAndPartial<T>(primary: T, secondary: Partial<T>): T;
|
||||
declare function f20(): void;
|
||||
declare function f21(): void;
|
||||
interface Foo {
|
||||
a: string;
|
||||
b?: number;
|
||||
}
|
||||
declare function setState<T, K extends keyof T>(obj: T, props: Pick<T, K>): void;
|
||||
declare let foo: Foo;
|
||||
declare class C<T> {
|
||||
state: T;
|
||||
setState<K extends keyof T>(props: Pick<T, K>): void;
|
||||
}
|
||||
declare let c: C<Foo>;
|
||||
|
||||
@@ -1,145 +1,133 @@
|
||||
//// [mappedTypeModifiers.ts]
|
||||
|
||||
type T = { a: number, b: string };
|
||||
type TU = { a: number | undefined, b: string | undefined };
|
||||
type TP = { a?: number, b?: string };
|
||||
type TR = { readonly a: number, readonly b: string };
|
||||
type TPR = { readonly a?: number, readonly b?: string };
|
||||
|
||||
// Validate they all have the same keys
|
||||
var v00: "a" | "b";
|
||||
var v00: keyof T;
|
||||
var v00: keyof TU;
|
||||
var v00: keyof TP;
|
||||
var v00: keyof TR;
|
||||
var v00: keyof TPR;
|
||||
|
||||
// Validate that non-isomorphic mapped types strip modifiers
|
||||
var v01: T;
|
||||
var v01: Pick<TR, keyof T>;
|
||||
var v01: Pick<Readonly<T>, keyof T>;
|
||||
var v01: { [P in keyof T]: T[P] };
|
||||
var v01: Pick<T, keyof T>;
|
||||
var v01: Pick<Pick<T, keyof T>, keyof T>;
|
||||
|
||||
// Validate that non-isomorphic mapped types strip modifiers
|
||||
var v02: TU;
|
||||
var v02: Pick<TP, keyof T>;
|
||||
var v02: Pick<TPR, keyof T>;
|
||||
var v02: Pick<Partial<T>, keyof T>;
|
||||
var v02: Pick<Partial<Readonly<T>>, keyof T>;
|
||||
var v02: TP;
|
||||
var v02: { [P in keyof T]?: T[P] };
|
||||
var v02: Partial<T>;
|
||||
var v02: { [P in keyof TP]: TP[P] }
|
||||
var v02: Pick<TP, keyof TP>;
|
||||
|
||||
// Validate that isomorphic mapped types preserve optional modifier
|
||||
var v03: TP;
|
||||
var v03: Partial<T>;
|
||||
var v03: TR;
|
||||
var v03: { readonly [P in keyof T]: T[P] };
|
||||
var v03: Readonly<T>;
|
||||
var v03: { [P in keyof TR]: TR[P] }
|
||||
var v03: Pick<TR, keyof TR>;
|
||||
|
||||
// Validate that isomorphic mapped types preserve readonly modifier
|
||||
var v04: TR;
|
||||
var v04: Readonly<T>;
|
||||
|
||||
// Validate that isomorphic mapped types preserve both partial and readonly modifiers
|
||||
var v05: TPR;
|
||||
var v05: Partial<TR>;
|
||||
var v05: Readonly<TP>;
|
||||
var v05: Partial<Readonly<T>>;
|
||||
var v05: Readonly<Partial<T>>;
|
||||
var v04: TPR;
|
||||
var v04: { readonly [P in keyof T]?: T[P] };
|
||||
var v04: Partial<TR>;
|
||||
var v04: Readonly<TP>;
|
||||
var v04: Partial<Readonly<T>>;
|
||||
var v04: Readonly<Partial<T>>;
|
||||
var v04: { [P in keyof TPR]: TPR[P] }
|
||||
var v04: Pick<TPR, keyof T>;
|
||||
|
||||
type Boxified<T> = { [P in keyof T]: { x: T[P] } };
|
||||
|
||||
type B = { a: { x: number }, b: { x: string } };
|
||||
type BU = { a: { x: number } | undefined, b: { x: string } | undefined };
|
||||
type BP = { a?: { x: number }, b?: { x: string } };
|
||||
type BR = { readonly a: { x: number }, readonly b: { x: string } };
|
||||
type BPR = { readonly a?: { x: number }, readonly b?: { x: string } };
|
||||
|
||||
// Validate they all have the same keys
|
||||
var b00: "a" | "b";
|
||||
var b00: keyof B;
|
||||
var b00: keyof BU;
|
||||
var b00: keyof BP;
|
||||
var b00: keyof BR;
|
||||
var b00: keyof BPR;
|
||||
|
||||
// Validate that non-isomorphic mapped types strip modifiers
|
||||
var b01: B;
|
||||
var b01: Pick<BR, keyof B>;
|
||||
var b01: Pick<Readonly<BR>, keyof B>;
|
||||
var b01: { [P in keyof B]: B[P] };
|
||||
var b01: Pick<B, keyof B>;
|
||||
var b01: Pick<Pick<B, keyof B>, keyof B>;
|
||||
|
||||
// Validate that non-isomorphic mapped types strip modifiers
|
||||
var b02: BU;
|
||||
var b02: Pick<BP, keyof B>;
|
||||
var b02: Pick<BPR, keyof B>;
|
||||
var b02: Pick<Partial<B>, keyof B>;
|
||||
var b02: Pick<Partial<Readonly<B>>, keyof B>;
|
||||
var b02: BP;
|
||||
var b02: { [P in keyof B]?: B[P] };
|
||||
var b02: Partial<B>;
|
||||
var b02: { [P in keyof BP]: BP[P] }
|
||||
var b02: Pick<BP, keyof BP>;
|
||||
|
||||
// Validate that isomorphic mapped types preserve optional modifier
|
||||
var b03: BP;
|
||||
var b03: Partial<B>;
|
||||
var b03: BR;
|
||||
var b03: { readonly [P in keyof B]: B[P] };
|
||||
var b03: Readonly<B>;
|
||||
var b03: { [P in keyof BR]: BR[P] }
|
||||
var b03: Pick<BR, keyof BR>;
|
||||
|
||||
// Validate that isomorphic mapped types preserve readonly modifier
|
||||
var b04: BR;
|
||||
var b04: Readonly<B>;
|
||||
|
||||
// Validate that isomorphic mapped types preserve both partial and readonly modifiers
|
||||
var b05: BPR;
|
||||
var b05: Partial<BR>;
|
||||
var b05: Readonly<BP>;
|
||||
var b05: Partial<Readonly<B>>;
|
||||
var b05: Readonly<Partial<B>>;
|
||||
var b04: BPR;
|
||||
var b04: { readonly [P in keyof B]?: B[P] };
|
||||
var b04: Partial<BR>;
|
||||
var b04: Readonly<BP>;
|
||||
var b04: Partial<Readonly<B>>;
|
||||
var b04: Readonly<Partial<B>>;
|
||||
var b04: { [P in keyof BPR]: BPR[P] }
|
||||
var b04: Pick<BPR, keyof BPR>;
|
||||
|
||||
//// [mappedTypeModifiers.js]
|
||||
// Validate they all have the same keys
|
||||
var v00;
|
||||
var v00;
|
||||
var v00;
|
||||
var v00;
|
||||
var v00;
|
||||
var v00;
|
||||
// Validate that non-isomorphic mapped types strip modifiers
|
||||
var v01;
|
||||
var v01;
|
||||
var v01;
|
||||
// Validate that non-isomorphic mapped types strip modifiers
|
||||
var v01;
|
||||
var v02;
|
||||
var v02;
|
||||
var v02;
|
||||
var v02;
|
||||
var v02;
|
||||
// Validate that isomorphic mapped types preserve optional modifier
|
||||
var v03;
|
||||
var v03;
|
||||
// Validate that isomorphic mapped types preserve readonly modifier
|
||||
var v03;
|
||||
var v03;
|
||||
var v03;
|
||||
var v04;
|
||||
var v04;
|
||||
var v04;
|
||||
var v04;
|
||||
var v04;
|
||||
var v04;
|
||||
var v04;
|
||||
var v04;
|
||||
// Validate that isomorphic mapped types preserve both partial and readonly modifiers
|
||||
var v05;
|
||||
var v05;
|
||||
var v05;
|
||||
var v05;
|
||||
var v05;
|
||||
// Validate they all have the same keys
|
||||
var b00;
|
||||
var b00;
|
||||
var b00;
|
||||
var b00;
|
||||
var b00;
|
||||
var b00;
|
||||
// Validate that non-isomorphic mapped types strip modifiers
|
||||
var b01;
|
||||
var b01;
|
||||
var b01;
|
||||
// Validate that non-isomorphic mapped types strip modifiers
|
||||
var b01;
|
||||
var b02;
|
||||
var b02;
|
||||
var b02;
|
||||
var b02;
|
||||
var b02;
|
||||
// Validate that isomorphic mapped types preserve optional modifier
|
||||
var b03;
|
||||
var b03;
|
||||
// Validate that isomorphic mapped types preserve readonly modifier
|
||||
var b03;
|
||||
var b03;
|
||||
var b03;
|
||||
var b04;
|
||||
var b04;
|
||||
var b04;
|
||||
var b04;
|
||||
var b04;
|
||||
var b04;
|
||||
var b04;
|
||||
var b04;
|
||||
// Validate that isomorphic mapped types preserve both partial and readonly modifiers
|
||||
var b05;
|
||||
var b05;
|
||||
var b05;
|
||||
var b05;
|
||||
var b05;
|
||||
|
||||
@@ -5,309 +5,351 @@ type T = { a: number, b: string };
|
||||
>a : Symbol(a, Decl(mappedTypeModifiers.ts, 1, 10))
|
||||
>b : Symbol(b, Decl(mappedTypeModifiers.ts, 1, 21))
|
||||
|
||||
type TU = { a: number | undefined, b: string | undefined };
|
||||
>TU : Symbol(TU, Decl(mappedTypeModifiers.ts, 1, 34))
|
||||
>a : Symbol(a, Decl(mappedTypeModifiers.ts, 2, 11))
|
||||
>b : Symbol(b, Decl(mappedTypeModifiers.ts, 2, 34))
|
||||
|
||||
type TP = { a?: number, b?: string };
|
||||
>TP : Symbol(TP, Decl(mappedTypeModifiers.ts, 2, 59))
|
||||
>a : Symbol(a, Decl(mappedTypeModifiers.ts, 3, 11))
|
||||
>b : Symbol(b, Decl(mappedTypeModifiers.ts, 3, 23))
|
||||
>TP : Symbol(TP, Decl(mappedTypeModifiers.ts, 1, 34))
|
||||
>a : Symbol(a, Decl(mappedTypeModifiers.ts, 2, 11))
|
||||
>b : Symbol(b, Decl(mappedTypeModifiers.ts, 2, 23))
|
||||
|
||||
type TR = { readonly a: number, readonly b: string };
|
||||
>TR : Symbol(TR, Decl(mappedTypeModifiers.ts, 3, 37))
|
||||
>a : Symbol(a, Decl(mappedTypeModifiers.ts, 4, 11))
|
||||
>b : Symbol(b, Decl(mappedTypeModifiers.ts, 4, 31))
|
||||
>TR : Symbol(TR, Decl(mappedTypeModifiers.ts, 2, 37))
|
||||
>a : Symbol(a, Decl(mappedTypeModifiers.ts, 3, 11))
|
||||
>b : Symbol(b, Decl(mappedTypeModifiers.ts, 3, 31))
|
||||
|
||||
type TPR = { readonly a?: number, readonly b?: string };
|
||||
>TPR : Symbol(TPR, Decl(mappedTypeModifiers.ts, 4, 53))
|
||||
>a : Symbol(a, Decl(mappedTypeModifiers.ts, 5, 12))
|
||||
>b : Symbol(b, Decl(mappedTypeModifiers.ts, 5, 33))
|
||||
>TPR : Symbol(TPR, Decl(mappedTypeModifiers.ts, 3, 53))
|
||||
>a : Symbol(a, Decl(mappedTypeModifiers.ts, 4, 12))
|
||||
>b : Symbol(b, Decl(mappedTypeModifiers.ts, 4, 33))
|
||||
|
||||
// Validate they all have the same keys
|
||||
var v00: "a" | "b";
|
||||
>v00 : Symbol(v00, Decl(mappedTypeModifiers.ts, 8, 3), Decl(mappedTypeModifiers.ts, 9, 3), Decl(mappedTypeModifiers.ts, 10, 3), Decl(mappedTypeModifiers.ts, 11, 3), Decl(mappedTypeModifiers.ts, 12, 3), Decl(mappedTypeModifiers.ts, 13, 3))
|
||||
>v00 : Symbol(v00, Decl(mappedTypeModifiers.ts, 6, 3), Decl(mappedTypeModifiers.ts, 7, 3), Decl(mappedTypeModifiers.ts, 8, 3), Decl(mappedTypeModifiers.ts, 9, 3), Decl(mappedTypeModifiers.ts, 10, 3))
|
||||
|
||||
var v00: keyof T;
|
||||
>v00 : Symbol(v00, Decl(mappedTypeModifiers.ts, 8, 3), Decl(mappedTypeModifiers.ts, 9, 3), Decl(mappedTypeModifiers.ts, 10, 3), Decl(mappedTypeModifiers.ts, 11, 3), Decl(mappedTypeModifiers.ts, 12, 3), Decl(mappedTypeModifiers.ts, 13, 3))
|
||||
>v00 : Symbol(v00, Decl(mappedTypeModifiers.ts, 6, 3), Decl(mappedTypeModifiers.ts, 7, 3), Decl(mappedTypeModifiers.ts, 8, 3), Decl(mappedTypeModifiers.ts, 9, 3), Decl(mappedTypeModifiers.ts, 10, 3))
|
||||
>T : Symbol(T, Decl(mappedTypeModifiers.ts, 0, 0))
|
||||
|
||||
var v00: keyof TU;
|
||||
>v00 : Symbol(v00, Decl(mappedTypeModifiers.ts, 8, 3), Decl(mappedTypeModifiers.ts, 9, 3), Decl(mappedTypeModifiers.ts, 10, 3), Decl(mappedTypeModifiers.ts, 11, 3), Decl(mappedTypeModifiers.ts, 12, 3), Decl(mappedTypeModifiers.ts, 13, 3))
|
||||
>TU : Symbol(TU, Decl(mappedTypeModifiers.ts, 1, 34))
|
||||
|
||||
var v00: keyof TP;
|
||||
>v00 : Symbol(v00, Decl(mappedTypeModifiers.ts, 8, 3), Decl(mappedTypeModifiers.ts, 9, 3), Decl(mappedTypeModifiers.ts, 10, 3), Decl(mappedTypeModifiers.ts, 11, 3), Decl(mappedTypeModifiers.ts, 12, 3), Decl(mappedTypeModifiers.ts, 13, 3))
|
||||
>TP : Symbol(TP, Decl(mappedTypeModifiers.ts, 2, 59))
|
||||
>v00 : Symbol(v00, Decl(mappedTypeModifiers.ts, 6, 3), Decl(mappedTypeModifiers.ts, 7, 3), Decl(mappedTypeModifiers.ts, 8, 3), Decl(mappedTypeModifiers.ts, 9, 3), Decl(mappedTypeModifiers.ts, 10, 3))
|
||||
>TP : Symbol(TP, Decl(mappedTypeModifiers.ts, 1, 34))
|
||||
|
||||
var v00: keyof TR;
|
||||
>v00 : Symbol(v00, Decl(mappedTypeModifiers.ts, 8, 3), Decl(mappedTypeModifiers.ts, 9, 3), Decl(mappedTypeModifiers.ts, 10, 3), Decl(mappedTypeModifiers.ts, 11, 3), Decl(mappedTypeModifiers.ts, 12, 3), Decl(mappedTypeModifiers.ts, 13, 3))
|
||||
>TR : Symbol(TR, Decl(mappedTypeModifiers.ts, 3, 37))
|
||||
>v00 : Symbol(v00, Decl(mappedTypeModifiers.ts, 6, 3), Decl(mappedTypeModifiers.ts, 7, 3), Decl(mappedTypeModifiers.ts, 8, 3), Decl(mappedTypeModifiers.ts, 9, 3), Decl(mappedTypeModifiers.ts, 10, 3))
|
||||
>TR : Symbol(TR, Decl(mappedTypeModifiers.ts, 2, 37))
|
||||
|
||||
var v00: keyof TPR;
|
||||
>v00 : Symbol(v00, Decl(mappedTypeModifiers.ts, 8, 3), Decl(mappedTypeModifiers.ts, 9, 3), Decl(mappedTypeModifiers.ts, 10, 3), Decl(mappedTypeModifiers.ts, 11, 3), Decl(mappedTypeModifiers.ts, 12, 3), Decl(mappedTypeModifiers.ts, 13, 3))
|
||||
>TPR : Symbol(TPR, Decl(mappedTypeModifiers.ts, 4, 53))
|
||||
>v00 : Symbol(v00, Decl(mappedTypeModifiers.ts, 6, 3), Decl(mappedTypeModifiers.ts, 7, 3), Decl(mappedTypeModifiers.ts, 8, 3), Decl(mappedTypeModifiers.ts, 9, 3), Decl(mappedTypeModifiers.ts, 10, 3))
|
||||
>TPR : Symbol(TPR, Decl(mappedTypeModifiers.ts, 3, 53))
|
||||
|
||||
// Validate that non-isomorphic mapped types strip modifiers
|
||||
var v01: T;
|
||||
>v01 : Symbol(v01, Decl(mappedTypeModifiers.ts, 16, 3), Decl(mappedTypeModifiers.ts, 17, 3), Decl(mappedTypeModifiers.ts, 18, 3))
|
||||
>v01 : Symbol(v01, Decl(mappedTypeModifiers.ts, 12, 3), Decl(mappedTypeModifiers.ts, 13, 3), Decl(mappedTypeModifiers.ts, 14, 3), Decl(mappedTypeModifiers.ts, 15, 3))
|
||||
>T : Symbol(T, Decl(mappedTypeModifiers.ts, 0, 0))
|
||||
|
||||
var v01: Pick<TR, keyof T>;
|
||||
>v01 : Symbol(v01, Decl(mappedTypeModifiers.ts, 16, 3), Decl(mappedTypeModifiers.ts, 17, 3), Decl(mappedTypeModifiers.ts, 18, 3))
|
||||
var v01: { [P in keyof T]: T[P] };
|
||||
>v01 : Symbol(v01, Decl(mappedTypeModifiers.ts, 12, 3), Decl(mappedTypeModifiers.ts, 13, 3), Decl(mappedTypeModifiers.ts, 14, 3), Decl(mappedTypeModifiers.ts, 15, 3))
|
||||
>P : Symbol(P, Decl(mappedTypeModifiers.ts, 13, 12))
|
||||
>T : Symbol(T, Decl(mappedTypeModifiers.ts, 0, 0))
|
||||
>T : Symbol(T, Decl(mappedTypeModifiers.ts, 0, 0))
|
||||
>P : Symbol(P, Decl(mappedTypeModifiers.ts, 13, 12))
|
||||
|
||||
var v01: Pick<T, keyof T>;
|
||||
>v01 : Symbol(v01, Decl(mappedTypeModifiers.ts, 12, 3), Decl(mappedTypeModifiers.ts, 13, 3), Decl(mappedTypeModifiers.ts, 14, 3), Decl(mappedTypeModifiers.ts, 15, 3))
|
||||
>Pick : Symbol(Pick, Decl(lib.d.ts, --, --))
|
||||
>TR : Symbol(TR, Decl(mappedTypeModifiers.ts, 3, 37))
|
||||
>T : Symbol(T, Decl(mappedTypeModifiers.ts, 0, 0))
|
||||
>T : Symbol(T, Decl(mappedTypeModifiers.ts, 0, 0))
|
||||
|
||||
var v01: Pick<Readonly<T>, keyof T>;
|
||||
>v01 : Symbol(v01, Decl(mappedTypeModifiers.ts, 16, 3), Decl(mappedTypeModifiers.ts, 17, 3), Decl(mappedTypeModifiers.ts, 18, 3))
|
||||
var v01: Pick<Pick<T, keyof T>, keyof T>;
|
||||
>v01 : Symbol(v01, Decl(mappedTypeModifiers.ts, 12, 3), Decl(mappedTypeModifiers.ts, 13, 3), Decl(mappedTypeModifiers.ts, 14, 3), Decl(mappedTypeModifiers.ts, 15, 3))
|
||||
>Pick : Symbol(Pick, Decl(lib.d.ts, --, --))
|
||||
>Readonly : Symbol(Readonly, Decl(lib.d.ts, --, --))
|
||||
>T : Symbol(T, Decl(mappedTypeModifiers.ts, 0, 0))
|
||||
>T : Symbol(T, Decl(mappedTypeModifiers.ts, 0, 0))
|
||||
|
||||
// Validate that non-isomorphic mapped types strip modifiers
|
||||
var v02: TU;
|
||||
>v02 : Symbol(v02, Decl(mappedTypeModifiers.ts, 21, 3), Decl(mappedTypeModifiers.ts, 22, 3), Decl(mappedTypeModifiers.ts, 23, 3), Decl(mappedTypeModifiers.ts, 24, 3), Decl(mappedTypeModifiers.ts, 25, 3))
|
||||
>TU : Symbol(TU, Decl(mappedTypeModifiers.ts, 1, 34))
|
||||
|
||||
var v02: Pick<TP, keyof T>;
|
||||
>v02 : Symbol(v02, Decl(mappedTypeModifiers.ts, 21, 3), Decl(mappedTypeModifiers.ts, 22, 3), Decl(mappedTypeModifiers.ts, 23, 3), Decl(mappedTypeModifiers.ts, 24, 3), Decl(mappedTypeModifiers.ts, 25, 3))
|
||||
>Pick : Symbol(Pick, Decl(lib.d.ts, --, --))
|
||||
>TP : Symbol(TP, Decl(mappedTypeModifiers.ts, 2, 59))
|
||||
>T : Symbol(T, Decl(mappedTypeModifiers.ts, 0, 0))
|
||||
|
||||
var v02: Pick<TPR, keyof T>;
|
||||
>v02 : Symbol(v02, Decl(mappedTypeModifiers.ts, 21, 3), Decl(mappedTypeModifiers.ts, 22, 3), Decl(mappedTypeModifiers.ts, 23, 3), Decl(mappedTypeModifiers.ts, 24, 3), Decl(mappedTypeModifiers.ts, 25, 3))
|
||||
>Pick : Symbol(Pick, Decl(lib.d.ts, --, --))
|
||||
>TPR : Symbol(TPR, Decl(mappedTypeModifiers.ts, 4, 53))
|
||||
>T : Symbol(T, Decl(mappedTypeModifiers.ts, 0, 0))
|
||||
|
||||
var v02: Pick<Partial<T>, keyof T>;
|
||||
>v02 : Symbol(v02, Decl(mappedTypeModifiers.ts, 21, 3), Decl(mappedTypeModifiers.ts, 22, 3), Decl(mappedTypeModifiers.ts, 23, 3), Decl(mappedTypeModifiers.ts, 24, 3), Decl(mappedTypeModifiers.ts, 25, 3))
|
||||
>Pick : Symbol(Pick, Decl(lib.d.ts, --, --))
|
||||
>Partial : Symbol(Partial, Decl(lib.d.ts, --, --))
|
||||
>T : Symbol(T, Decl(mappedTypeModifiers.ts, 0, 0))
|
||||
>T : Symbol(T, Decl(mappedTypeModifiers.ts, 0, 0))
|
||||
|
||||
var v02: Pick<Partial<Readonly<T>>, keyof T>;
|
||||
>v02 : Symbol(v02, Decl(mappedTypeModifiers.ts, 21, 3), Decl(mappedTypeModifiers.ts, 22, 3), Decl(mappedTypeModifiers.ts, 23, 3), Decl(mappedTypeModifiers.ts, 24, 3), Decl(mappedTypeModifiers.ts, 25, 3))
|
||||
>Pick : Symbol(Pick, Decl(lib.d.ts, --, --))
|
||||
>Partial : Symbol(Partial, Decl(lib.d.ts, --, --))
|
||||
>Readonly : Symbol(Readonly, Decl(lib.d.ts, --, --))
|
||||
var v02: TP;
|
||||
>v02 : Symbol(v02, Decl(mappedTypeModifiers.ts, 17, 3), Decl(mappedTypeModifiers.ts, 18, 3), Decl(mappedTypeModifiers.ts, 19, 3), Decl(mappedTypeModifiers.ts, 20, 3), Decl(mappedTypeModifiers.ts, 21, 3))
|
||||
>TP : Symbol(TP, Decl(mappedTypeModifiers.ts, 1, 34))
|
||||
|
||||
var v02: { [P in keyof T]?: T[P] };
|
||||
>v02 : Symbol(v02, Decl(mappedTypeModifiers.ts, 17, 3), Decl(mappedTypeModifiers.ts, 18, 3), Decl(mappedTypeModifiers.ts, 19, 3), Decl(mappedTypeModifiers.ts, 20, 3), Decl(mappedTypeModifiers.ts, 21, 3))
|
||||
>P : Symbol(P, Decl(mappedTypeModifiers.ts, 18, 12))
|
||||
>T : Symbol(T, Decl(mappedTypeModifiers.ts, 0, 0))
|
||||
>T : Symbol(T, Decl(mappedTypeModifiers.ts, 0, 0))
|
||||
>P : Symbol(P, Decl(mappedTypeModifiers.ts, 18, 12))
|
||||
|
||||
// Validate that isomorphic mapped types preserve optional modifier
|
||||
var v03: TP;
|
||||
>v03 : Symbol(v03, Decl(mappedTypeModifiers.ts, 28, 3), Decl(mappedTypeModifiers.ts, 29, 3))
|
||||
>TP : Symbol(TP, Decl(mappedTypeModifiers.ts, 2, 59))
|
||||
|
||||
var v03: Partial<T>;
|
||||
>v03 : Symbol(v03, Decl(mappedTypeModifiers.ts, 28, 3), Decl(mappedTypeModifiers.ts, 29, 3))
|
||||
var v02: Partial<T>;
|
||||
>v02 : Symbol(v02, Decl(mappedTypeModifiers.ts, 17, 3), Decl(mappedTypeModifiers.ts, 18, 3), Decl(mappedTypeModifiers.ts, 19, 3), Decl(mappedTypeModifiers.ts, 20, 3), Decl(mappedTypeModifiers.ts, 21, 3))
|
||||
>Partial : Symbol(Partial, Decl(lib.d.ts, --, --))
|
||||
>T : Symbol(T, Decl(mappedTypeModifiers.ts, 0, 0))
|
||||
|
||||
// Validate that isomorphic mapped types preserve readonly modifier
|
||||
var v04: TR;
|
||||
>v04 : Symbol(v04, Decl(mappedTypeModifiers.ts, 32, 3), Decl(mappedTypeModifiers.ts, 33, 3))
|
||||
>TR : Symbol(TR, Decl(mappedTypeModifiers.ts, 3, 37))
|
||||
var v02: { [P in keyof TP]: TP[P] }
|
||||
>v02 : Symbol(v02, Decl(mappedTypeModifiers.ts, 17, 3), Decl(mappedTypeModifiers.ts, 18, 3), Decl(mappedTypeModifiers.ts, 19, 3), Decl(mappedTypeModifiers.ts, 20, 3), Decl(mappedTypeModifiers.ts, 21, 3))
|
||||
>P : Symbol(P, Decl(mappedTypeModifiers.ts, 20, 12))
|
||||
>TP : Symbol(TP, Decl(mappedTypeModifiers.ts, 1, 34))
|
||||
>TP : Symbol(TP, Decl(mappedTypeModifiers.ts, 1, 34))
|
||||
>P : Symbol(P, Decl(mappedTypeModifiers.ts, 20, 12))
|
||||
|
||||
var v04: Readonly<T>;
|
||||
>v04 : Symbol(v04, Decl(mappedTypeModifiers.ts, 32, 3), Decl(mappedTypeModifiers.ts, 33, 3))
|
||||
var v02: Pick<TP, keyof TP>;
|
||||
>v02 : Symbol(v02, Decl(mappedTypeModifiers.ts, 17, 3), Decl(mappedTypeModifiers.ts, 18, 3), Decl(mappedTypeModifiers.ts, 19, 3), Decl(mappedTypeModifiers.ts, 20, 3), Decl(mappedTypeModifiers.ts, 21, 3))
|
||||
>Pick : Symbol(Pick, Decl(lib.d.ts, --, --))
|
||||
>TP : Symbol(TP, Decl(mappedTypeModifiers.ts, 1, 34))
|
||||
>TP : Symbol(TP, Decl(mappedTypeModifiers.ts, 1, 34))
|
||||
|
||||
var v03: TR;
|
||||
>v03 : Symbol(v03, Decl(mappedTypeModifiers.ts, 23, 3), Decl(mappedTypeModifiers.ts, 24, 3), Decl(mappedTypeModifiers.ts, 25, 3), Decl(mappedTypeModifiers.ts, 26, 3), Decl(mappedTypeModifiers.ts, 27, 3))
|
||||
>TR : Symbol(TR, Decl(mappedTypeModifiers.ts, 2, 37))
|
||||
|
||||
var v03: { readonly [P in keyof T]: T[P] };
|
||||
>v03 : Symbol(v03, Decl(mappedTypeModifiers.ts, 23, 3), Decl(mappedTypeModifiers.ts, 24, 3), Decl(mappedTypeModifiers.ts, 25, 3), Decl(mappedTypeModifiers.ts, 26, 3), Decl(mappedTypeModifiers.ts, 27, 3))
|
||||
>P : Symbol(P, Decl(mappedTypeModifiers.ts, 24, 21))
|
||||
>T : Symbol(T, Decl(mappedTypeModifiers.ts, 0, 0))
|
||||
>T : Symbol(T, Decl(mappedTypeModifiers.ts, 0, 0))
|
||||
>P : Symbol(P, Decl(mappedTypeModifiers.ts, 24, 21))
|
||||
|
||||
var v03: Readonly<T>;
|
||||
>v03 : Symbol(v03, Decl(mappedTypeModifiers.ts, 23, 3), Decl(mappedTypeModifiers.ts, 24, 3), Decl(mappedTypeModifiers.ts, 25, 3), Decl(mappedTypeModifiers.ts, 26, 3), Decl(mappedTypeModifiers.ts, 27, 3))
|
||||
>Readonly : Symbol(Readonly, Decl(lib.d.ts, --, --))
|
||||
>T : Symbol(T, Decl(mappedTypeModifiers.ts, 0, 0))
|
||||
|
||||
// Validate that isomorphic mapped types preserve both partial and readonly modifiers
|
||||
var v05: TPR;
|
||||
>v05 : Symbol(v05, Decl(mappedTypeModifiers.ts, 36, 3), Decl(mappedTypeModifiers.ts, 37, 3), Decl(mappedTypeModifiers.ts, 38, 3), Decl(mappedTypeModifiers.ts, 39, 3), Decl(mappedTypeModifiers.ts, 40, 3))
|
||||
>TPR : Symbol(TPR, Decl(mappedTypeModifiers.ts, 4, 53))
|
||||
var v03: { [P in keyof TR]: TR[P] }
|
||||
>v03 : Symbol(v03, Decl(mappedTypeModifiers.ts, 23, 3), Decl(mappedTypeModifiers.ts, 24, 3), Decl(mappedTypeModifiers.ts, 25, 3), Decl(mappedTypeModifiers.ts, 26, 3), Decl(mappedTypeModifiers.ts, 27, 3))
|
||||
>P : Symbol(P, Decl(mappedTypeModifiers.ts, 26, 12))
|
||||
>TR : Symbol(TR, Decl(mappedTypeModifiers.ts, 2, 37))
|
||||
>TR : Symbol(TR, Decl(mappedTypeModifiers.ts, 2, 37))
|
||||
>P : Symbol(P, Decl(mappedTypeModifiers.ts, 26, 12))
|
||||
|
||||
var v05: Partial<TR>;
|
||||
>v05 : Symbol(v05, Decl(mappedTypeModifiers.ts, 36, 3), Decl(mappedTypeModifiers.ts, 37, 3), Decl(mappedTypeModifiers.ts, 38, 3), Decl(mappedTypeModifiers.ts, 39, 3), Decl(mappedTypeModifiers.ts, 40, 3))
|
||||
var v03: Pick<TR, keyof TR>;
|
||||
>v03 : Symbol(v03, Decl(mappedTypeModifiers.ts, 23, 3), Decl(mappedTypeModifiers.ts, 24, 3), Decl(mappedTypeModifiers.ts, 25, 3), Decl(mappedTypeModifiers.ts, 26, 3), Decl(mappedTypeModifiers.ts, 27, 3))
|
||||
>Pick : Symbol(Pick, Decl(lib.d.ts, --, --))
|
||||
>TR : Symbol(TR, Decl(mappedTypeModifiers.ts, 2, 37))
|
||||
>TR : Symbol(TR, Decl(mappedTypeModifiers.ts, 2, 37))
|
||||
|
||||
var v04: TPR;
|
||||
>v04 : Symbol(v04, Decl(mappedTypeModifiers.ts, 29, 3), Decl(mappedTypeModifiers.ts, 30, 3), Decl(mappedTypeModifiers.ts, 31, 3), Decl(mappedTypeModifiers.ts, 32, 3), Decl(mappedTypeModifiers.ts, 33, 3), Decl(mappedTypeModifiers.ts, 34, 3), Decl(mappedTypeModifiers.ts, 35, 3), Decl(mappedTypeModifiers.ts, 36, 3))
|
||||
>TPR : Symbol(TPR, Decl(mappedTypeModifiers.ts, 3, 53))
|
||||
|
||||
var v04: { readonly [P in keyof T]?: T[P] };
|
||||
>v04 : Symbol(v04, Decl(mappedTypeModifiers.ts, 29, 3), Decl(mappedTypeModifiers.ts, 30, 3), Decl(mappedTypeModifiers.ts, 31, 3), Decl(mappedTypeModifiers.ts, 32, 3), Decl(mappedTypeModifiers.ts, 33, 3), Decl(mappedTypeModifiers.ts, 34, 3), Decl(mappedTypeModifiers.ts, 35, 3), Decl(mappedTypeModifiers.ts, 36, 3))
|
||||
>P : Symbol(P, Decl(mappedTypeModifiers.ts, 30, 21))
|
||||
>T : Symbol(T, Decl(mappedTypeModifiers.ts, 0, 0))
|
||||
>T : Symbol(T, Decl(mappedTypeModifiers.ts, 0, 0))
|
||||
>P : Symbol(P, Decl(mappedTypeModifiers.ts, 30, 21))
|
||||
|
||||
var v04: Partial<TR>;
|
||||
>v04 : Symbol(v04, Decl(mappedTypeModifiers.ts, 29, 3), Decl(mappedTypeModifiers.ts, 30, 3), Decl(mappedTypeModifiers.ts, 31, 3), Decl(mappedTypeModifiers.ts, 32, 3), Decl(mappedTypeModifiers.ts, 33, 3), Decl(mappedTypeModifiers.ts, 34, 3), Decl(mappedTypeModifiers.ts, 35, 3), Decl(mappedTypeModifiers.ts, 36, 3))
|
||||
>Partial : Symbol(Partial, Decl(lib.d.ts, --, --))
|
||||
>TR : Symbol(TR, Decl(mappedTypeModifiers.ts, 3, 37))
|
||||
>TR : Symbol(TR, Decl(mappedTypeModifiers.ts, 2, 37))
|
||||
|
||||
var v05: Readonly<TP>;
|
||||
>v05 : Symbol(v05, Decl(mappedTypeModifiers.ts, 36, 3), Decl(mappedTypeModifiers.ts, 37, 3), Decl(mappedTypeModifiers.ts, 38, 3), Decl(mappedTypeModifiers.ts, 39, 3), Decl(mappedTypeModifiers.ts, 40, 3))
|
||||
var v04: Readonly<TP>;
|
||||
>v04 : Symbol(v04, Decl(mappedTypeModifiers.ts, 29, 3), Decl(mappedTypeModifiers.ts, 30, 3), Decl(mappedTypeModifiers.ts, 31, 3), Decl(mappedTypeModifiers.ts, 32, 3), Decl(mappedTypeModifiers.ts, 33, 3), Decl(mappedTypeModifiers.ts, 34, 3), Decl(mappedTypeModifiers.ts, 35, 3), Decl(mappedTypeModifiers.ts, 36, 3))
|
||||
>Readonly : Symbol(Readonly, Decl(lib.d.ts, --, --))
|
||||
>TP : Symbol(TP, Decl(mappedTypeModifiers.ts, 2, 59))
|
||||
>TP : Symbol(TP, Decl(mappedTypeModifiers.ts, 1, 34))
|
||||
|
||||
var v05: Partial<Readonly<T>>;
|
||||
>v05 : Symbol(v05, Decl(mappedTypeModifiers.ts, 36, 3), Decl(mappedTypeModifiers.ts, 37, 3), Decl(mappedTypeModifiers.ts, 38, 3), Decl(mappedTypeModifiers.ts, 39, 3), Decl(mappedTypeModifiers.ts, 40, 3))
|
||||
var v04: Partial<Readonly<T>>;
|
||||
>v04 : Symbol(v04, Decl(mappedTypeModifiers.ts, 29, 3), Decl(mappedTypeModifiers.ts, 30, 3), Decl(mappedTypeModifiers.ts, 31, 3), Decl(mappedTypeModifiers.ts, 32, 3), Decl(mappedTypeModifiers.ts, 33, 3), Decl(mappedTypeModifiers.ts, 34, 3), Decl(mappedTypeModifiers.ts, 35, 3), Decl(mappedTypeModifiers.ts, 36, 3))
|
||||
>Partial : Symbol(Partial, Decl(lib.d.ts, --, --))
|
||||
>Readonly : Symbol(Readonly, Decl(lib.d.ts, --, --))
|
||||
>T : Symbol(T, Decl(mappedTypeModifiers.ts, 0, 0))
|
||||
|
||||
var v05: Readonly<Partial<T>>;
|
||||
>v05 : Symbol(v05, Decl(mappedTypeModifiers.ts, 36, 3), Decl(mappedTypeModifiers.ts, 37, 3), Decl(mappedTypeModifiers.ts, 38, 3), Decl(mappedTypeModifiers.ts, 39, 3), Decl(mappedTypeModifiers.ts, 40, 3))
|
||||
var v04: Readonly<Partial<T>>;
|
||||
>v04 : Symbol(v04, Decl(mappedTypeModifiers.ts, 29, 3), Decl(mappedTypeModifiers.ts, 30, 3), Decl(mappedTypeModifiers.ts, 31, 3), Decl(mappedTypeModifiers.ts, 32, 3), Decl(mappedTypeModifiers.ts, 33, 3), Decl(mappedTypeModifiers.ts, 34, 3), Decl(mappedTypeModifiers.ts, 35, 3), Decl(mappedTypeModifiers.ts, 36, 3))
|
||||
>Readonly : Symbol(Readonly, Decl(lib.d.ts, --, --))
|
||||
>Partial : Symbol(Partial, Decl(lib.d.ts, --, --))
|
||||
>T : Symbol(T, Decl(mappedTypeModifiers.ts, 0, 0))
|
||||
|
||||
var v04: { [P in keyof TPR]: TPR[P] }
|
||||
>v04 : Symbol(v04, Decl(mappedTypeModifiers.ts, 29, 3), Decl(mappedTypeModifiers.ts, 30, 3), Decl(mappedTypeModifiers.ts, 31, 3), Decl(mappedTypeModifiers.ts, 32, 3), Decl(mappedTypeModifiers.ts, 33, 3), Decl(mappedTypeModifiers.ts, 34, 3), Decl(mappedTypeModifiers.ts, 35, 3), Decl(mappedTypeModifiers.ts, 36, 3))
|
||||
>P : Symbol(P, Decl(mappedTypeModifiers.ts, 35, 12))
|
||||
>TPR : Symbol(TPR, Decl(mappedTypeModifiers.ts, 3, 53))
|
||||
>TPR : Symbol(TPR, Decl(mappedTypeModifiers.ts, 3, 53))
|
||||
>P : Symbol(P, Decl(mappedTypeModifiers.ts, 35, 12))
|
||||
|
||||
var v04: Pick<TPR, keyof T>;
|
||||
>v04 : Symbol(v04, Decl(mappedTypeModifiers.ts, 29, 3), Decl(mappedTypeModifiers.ts, 30, 3), Decl(mappedTypeModifiers.ts, 31, 3), Decl(mappedTypeModifiers.ts, 32, 3), Decl(mappedTypeModifiers.ts, 33, 3), Decl(mappedTypeModifiers.ts, 34, 3), Decl(mappedTypeModifiers.ts, 35, 3), Decl(mappedTypeModifiers.ts, 36, 3))
|
||||
>Pick : Symbol(Pick, Decl(lib.d.ts, --, --))
|
||||
>TPR : Symbol(TPR, Decl(mappedTypeModifiers.ts, 3, 53))
|
||||
>T : Symbol(T, Decl(mappedTypeModifiers.ts, 0, 0))
|
||||
|
||||
type Boxified<T> = { [P in keyof T]: { x: T[P] } };
|
||||
>Boxified : Symbol(Boxified, Decl(mappedTypeModifiers.ts, 40, 30))
|
||||
>T : Symbol(T, Decl(mappedTypeModifiers.ts, 42, 14))
|
||||
>P : Symbol(P, Decl(mappedTypeModifiers.ts, 42, 22))
|
||||
>T : Symbol(T, Decl(mappedTypeModifiers.ts, 42, 14))
|
||||
>x : Symbol(x, Decl(mappedTypeModifiers.ts, 42, 38))
|
||||
>T : Symbol(T, Decl(mappedTypeModifiers.ts, 42, 14))
|
||||
>P : Symbol(P, Decl(mappedTypeModifiers.ts, 42, 22))
|
||||
>Boxified : Symbol(Boxified, Decl(mappedTypeModifiers.ts, 36, 28))
|
||||
>T : Symbol(T, Decl(mappedTypeModifiers.ts, 38, 14))
|
||||
>P : Symbol(P, Decl(mappedTypeModifiers.ts, 38, 22))
|
||||
>T : Symbol(T, Decl(mappedTypeModifiers.ts, 38, 14))
|
||||
>x : Symbol(x, Decl(mappedTypeModifiers.ts, 38, 38))
|
||||
>T : Symbol(T, Decl(mappedTypeModifiers.ts, 38, 14))
|
||||
>P : Symbol(P, Decl(mappedTypeModifiers.ts, 38, 22))
|
||||
|
||||
type B = { a: { x: number }, b: { x: string } };
|
||||
>B : Symbol(B, Decl(mappedTypeModifiers.ts, 42, 51))
|
||||
>a : Symbol(a, Decl(mappedTypeModifiers.ts, 44, 10))
|
||||
>x : Symbol(x, Decl(mappedTypeModifiers.ts, 44, 15))
|
||||
>b : Symbol(b, Decl(mappedTypeModifiers.ts, 44, 28))
|
||||
>x : Symbol(x, Decl(mappedTypeModifiers.ts, 44, 33))
|
||||
|
||||
type BU = { a: { x: number } | undefined, b: { x: string } | undefined };
|
||||
>BU : Symbol(BU, Decl(mappedTypeModifiers.ts, 44, 48))
|
||||
>a : Symbol(a, Decl(mappedTypeModifiers.ts, 45, 11))
|
||||
>x : Symbol(x, Decl(mappedTypeModifiers.ts, 45, 16))
|
||||
>b : Symbol(b, Decl(mappedTypeModifiers.ts, 45, 41))
|
||||
>x : Symbol(x, Decl(mappedTypeModifiers.ts, 45, 46))
|
||||
>B : Symbol(B, Decl(mappedTypeModifiers.ts, 38, 51))
|
||||
>a : Symbol(a, Decl(mappedTypeModifiers.ts, 40, 10))
|
||||
>x : Symbol(x, Decl(mappedTypeModifiers.ts, 40, 15))
|
||||
>b : Symbol(b, Decl(mappedTypeModifiers.ts, 40, 28))
|
||||
>x : Symbol(x, Decl(mappedTypeModifiers.ts, 40, 33))
|
||||
|
||||
type BP = { a?: { x: number }, b?: { x: string } };
|
||||
>BP : Symbol(BP, Decl(mappedTypeModifiers.ts, 45, 73))
|
||||
>a : Symbol(a, Decl(mappedTypeModifiers.ts, 46, 11))
|
||||
>x : Symbol(x, Decl(mappedTypeModifiers.ts, 46, 17))
|
||||
>b : Symbol(b, Decl(mappedTypeModifiers.ts, 46, 30))
|
||||
>x : Symbol(x, Decl(mappedTypeModifiers.ts, 46, 36))
|
||||
>BP : Symbol(BP, Decl(mappedTypeModifiers.ts, 40, 48))
|
||||
>a : Symbol(a, Decl(mappedTypeModifiers.ts, 41, 11))
|
||||
>x : Symbol(x, Decl(mappedTypeModifiers.ts, 41, 17))
|
||||
>b : Symbol(b, Decl(mappedTypeModifiers.ts, 41, 30))
|
||||
>x : Symbol(x, Decl(mappedTypeModifiers.ts, 41, 36))
|
||||
|
||||
type BR = { readonly a: { x: number }, readonly b: { x: string } };
|
||||
>BR : Symbol(BR, Decl(mappedTypeModifiers.ts, 46, 51))
|
||||
>a : Symbol(a, Decl(mappedTypeModifiers.ts, 47, 11))
|
||||
>x : Symbol(x, Decl(mappedTypeModifiers.ts, 47, 25))
|
||||
>b : Symbol(b, Decl(mappedTypeModifiers.ts, 47, 38))
|
||||
>x : Symbol(x, Decl(mappedTypeModifiers.ts, 47, 52))
|
||||
>BR : Symbol(BR, Decl(mappedTypeModifiers.ts, 41, 51))
|
||||
>a : Symbol(a, Decl(mappedTypeModifiers.ts, 42, 11))
|
||||
>x : Symbol(x, Decl(mappedTypeModifiers.ts, 42, 25))
|
||||
>b : Symbol(b, Decl(mappedTypeModifiers.ts, 42, 38))
|
||||
>x : Symbol(x, Decl(mappedTypeModifiers.ts, 42, 52))
|
||||
|
||||
type BPR = { readonly a?: { x: number }, readonly b?: { x: string } };
|
||||
>BPR : Symbol(BPR, Decl(mappedTypeModifiers.ts, 47, 67))
|
||||
>a : Symbol(a, Decl(mappedTypeModifiers.ts, 48, 12))
|
||||
>x : Symbol(x, Decl(mappedTypeModifiers.ts, 48, 27))
|
||||
>b : Symbol(b, Decl(mappedTypeModifiers.ts, 48, 40))
|
||||
>x : Symbol(x, Decl(mappedTypeModifiers.ts, 48, 55))
|
||||
>BPR : Symbol(BPR, Decl(mappedTypeModifiers.ts, 42, 67))
|
||||
>a : Symbol(a, Decl(mappedTypeModifiers.ts, 43, 12))
|
||||
>x : Symbol(x, Decl(mappedTypeModifiers.ts, 43, 27))
|
||||
>b : Symbol(b, Decl(mappedTypeModifiers.ts, 43, 40))
|
||||
>x : Symbol(x, Decl(mappedTypeModifiers.ts, 43, 55))
|
||||
|
||||
// Validate they all have the same keys
|
||||
var b00: "a" | "b";
|
||||
>b00 : Symbol(b00, Decl(mappedTypeModifiers.ts, 51, 3), Decl(mappedTypeModifiers.ts, 52, 3), Decl(mappedTypeModifiers.ts, 53, 3), Decl(mappedTypeModifiers.ts, 54, 3), Decl(mappedTypeModifiers.ts, 55, 3), Decl(mappedTypeModifiers.ts, 56, 3))
|
||||
>b00 : Symbol(b00, Decl(mappedTypeModifiers.ts, 45, 3), Decl(mappedTypeModifiers.ts, 46, 3), Decl(mappedTypeModifiers.ts, 47, 3), Decl(mappedTypeModifiers.ts, 48, 3), Decl(mappedTypeModifiers.ts, 49, 3))
|
||||
|
||||
var b00: keyof B;
|
||||
>b00 : Symbol(b00, Decl(mappedTypeModifiers.ts, 51, 3), Decl(mappedTypeModifiers.ts, 52, 3), Decl(mappedTypeModifiers.ts, 53, 3), Decl(mappedTypeModifiers.ts, 54, 3), Decl(mappedTypeModifiers.ts, 55, 3), Decl(mappedTypeModifiers.ts, 56, 3))
|
||||
>B : Symbol(B, Decl(mappedTypeModifiers.ts, 42, 51))
|
||||
|
||||
var b00: keyof BU;
|
||||
>b00 : Symbol(b00, Decl(mappedTypeModifiers.ts, 51, 3), Decl(mappedTypeModifiers.ts, 52, 3), Decl(mappedTypeModifiers.ts, 53, 3), Decl(mappedTypeModifiers.ts, 54, 3), Decl(mappedTypeModifiers.ts, 55, 3), Decl(mappedTypeModifiers.ts, 56, 3))
|
||||
>BU : Symbol(BU, Decl(mappedTypeModifiers.ts, 44, 48))
|
||||
>b00 : Symbol(b00, Decl(mappedTypeModifiers.ts, 45, 3), Decl(mappedTypeModifiers.ts, 46, 3), Decl(mappedTypeModifiers.ts, 47, 3), Decl(mappedTypeModifiers.ts, 48, 3), Decl(mappedTypeModifiers.ts, 49, 3))
|
||||
>B : Symbol(B, Decl(mappedTypeModifiers.ts, 38, 51))
|
||||
|
||||
var b00: keyof BP;
|
||||
>b00 : Symbol(b00, Decl(mappedTypeModifiers.ts, 51, 3), Decl(mappedTypeModifiers.ts, 52, 3), Decl(mappedTypeModifiers.ts, 53, 3), Decl(mappedTypeModifiers.ts, 54, 3), Decl(mappedTypeModifiers.ts, 55, 3), Decl(mappedTypeModifiers.ts, 56, 3))
|
||||
>BP : Symbol(BP, Decl(mappedTypeModifiers.ts, 45, 73))
|
||||
>b00 : Symbol(b00, Decl(mappedTypeModifiers.ts, 45, 3), Decl(mappedTypeModifiers.ts, 46, 3), Decl(mappedTypeModifiers.ts, 47, 3), Decl(mappedTypeModifiers.ts, 48, 3), Decl(mappedTypeModifiers.ts, 49, 3))
|
||||
>BP : Symbol(BP, Decl(mappedTypeModifiers.ts, 40, 48))
|
||||
|
||||
var b00: keyof BR;
|
||||
>b00 : Symbol(b00, Decl(mappedTypeModifiers.ts, 51, 3), Decl(mappedTypeModifiers.ts, 52, 3), Decl(mappedTypeModifiers.ts, 53, 3), Decl(mappedTypeModifiers.ts, 54, 3), Decl(mappedTypeModifiers.ts, 55, 3), Decl(mappedTypeModifiers.ts, 56, 3))
|
||||
>BR : Symbol(BR, Decl(mappedTypeModifiers.ts, 46, 51))
|
||||
>b00 : Symbol(b00, Decl(mappedTypeModifiers.ts, 45, 3), Decl(mappedTypeModifiers.ts, 46, 3), Decl(mappedTypeModifiers.ts, 47, 3), Decl(mappedTypeModifiers.ts, 48, 3), Decl(mappedTypeModifiers.ts, 49, 3))
|
||||
>BR : Symbol(BR, Decl(mappedTypeModifiers.ts, 41, 51))
|
||||
|
||||
var b00: keyof BPR;
|
||||
>b00 : Symbol(b00, Decl(mappedTypeModifiers.ts, 51, 3), Decl(mappedTypeModifiers.ts, 52, 3), Decl(mappedTypeModifiers.ts, 53, 3), Decl(mappedTypeModifiers.ts, 54, 3), Decl(mappedTypeModifiers.ts, 55, 3), Decl(mappedTypeModifiers.ts, 56, 3))
|
||||
>BPR : Symbol(BPR, Decl(mappedTypeModifiers.ts, 47, 67))
|
||||
>b00 : Symbol(b00, Decl(mappedTypeModifiers.ts, 45, 3), Decl(mappedTypeModifiers.ts, 46, 3), Decl(mappedTypeModifiers.ts, 47, 3), Decl(mappedTypeModifiers.ts, 48, 3), Decl(mappedTypeModifiers.ts, 49, 3))
|
||||
>BPR : Symbol(BPR, Decl(mappedTypeModifiers.ts, 42, 67))
|
||||
|
||||
// Validate that non-isomorphic mapped types strip modifiers
|
||||
var b01: B;
|
||||
>b01 : Symbol(b01, Decl(mappedTypeModifiers.ts, 59, 3), Decl(mappedTypeModifiers.ts, 60, 3), Decl(mappedTypeModifiers.ts, 61, 3))
|
||||
>B : Symbol(B, Decl(mappedTypeModifiers.ts, 42, 51))
|
||||
>b01 : Symbol(b01, Decl(mappedTypeModifiers.ts, 51, 3), Decl(mappedTypeModifiers.ts, 52, 3), Decl(mappedTypeModifiers.ts, 53, 3), Decl(mappedTypeModifiers.ts, 54, 3))
|
||||
>B : Symbol(B, Decl(mappedTypeModifiers.ts, 38, 51))
|
||||
|
||||
var b01: Pick<BR, keyof B>;
|
||||
>b01 : Symbol(b01, Decl(mappedTypeModifiers.ts, 59, 3), Decl(mappedTypeModifiers.ts, 60, 3), Decl(mappedTypeModifiers.ts, 61, 3))
|
||||
var b01: { [P in keyof B]: B[P] };
|
||||
>b01 : Symbol(b01, Decl(mappedTypeModifiers.ts, 51, 3), Decl(mappedTypeModifiers.ts, 52, 3), Decl(mappedTypeModifiers.ts, 53, 3), Decl(mappedTypeModifiers.ts, 54, 3))
|
||||
>P : Symbol(P, Decl(mappedTypeModifiers.ts, 52, 12))
|
||||
>B : Symbol(B, Decl(mappedTypeModifiers.ts, 38, 51))
|
||||
>B : Symbol(B, Decl(mappedTypeModifiers.ts, 38, 51))
|
||||
>P : Symbol(P, Decl(mappedTypeModifiers.ts, 52, 12))
|
||||
|
||||
var b01: Pick<B, keyof B>;
|
||||
>b01 : Symbol(b01, Decl(mappedTypeModifiers.ts, 51, 3), Decl(mappedTypeModifiers.ts, 52, 3), Decl(mappedTypeModifiers.ts, 53, 3), Decl(mappedTypeModifiers.ts, 54, 3))
|
||||
>Pick : Symbol(Pick, Decl(lib.d.ts, --, --))
|
||||
>BR : Symbol(BR, Decl(mappedTypeModifiers.ts, 46, 51))
|
||||
>B : Symbol(B, Decl(mappedTypeModifiers.ts, 42, 51))
|
||||
>B : Symbol(B, Decl(mappedTypeModifiers.ts, 38, 51))
|
||||
>B : Symbol(B, Decl(mappedTypeModifiers.ts, 38, 51))
|
||||
|
||||
var b01: Pick<Readonly<BR>, keyof B>;
|
||||
>b01 : Symbol(b01, Decl(mappedTypeModifiers.ts, 59, 3), Decl(mappedTypeModifiers.ts, 60, 3), Decl(mappedTypeModifiers.ts, 61, 3))
|
||||
var b01: Pick<Pick<B, keyof B>, keyof B>;
|
||||
>b01 : Symbol(b01, Decl(mappedTypeModifiers.ts, 51, 3), Decl(mappedTypeModifiers.ts, 52, 3), Decl(mappedTypeModifiers.ts, 53, 3), Decl(mappedTypeModifiers.ts, 54, 3))
|
||||
>Pick : Symbol(Pick, Decl(lib.d.ts, --, --))
|
||||
>Readonly : Symbol(Readonly, Decl(lib.d.ts, --, --))
|
||||
>BR : Symbol(BR, Decl(mappedTypeModifiers.ts, 46, 51))
|
||||
>B : Symbol(B, Decl(mappedTypeModifiers.ts, 42, 51))
|
||||
|
||||
// Validate that non-isomorphic mapped types strip modifiers
|
||||
var b02: BU;
|
||||
>b02 : Symbol(b02, Decl(mappedTypeModifiers.ts, 64, 3), Decl(mappedTypeModifiers.ts, 65, 3), Decl(mappedTypeModifiers.ts, 66, 3), Decl(mappedTypeModifiers.ts, 67, 3), Decl(mappedTypeModifiers.ts, 68, 3))
|
||||
>BU : Symbol(BU, Decl(mappedTypeModifiers.ts, 44, 48))
|
||||
|
||||
var b02: Pick<BP, keyof B>;
|
||||
>b02 : Symbol(b02, Decl(mappedTypeModifiers.ts, 64, 3), Decl(mappedTypeModifiers.ts, 65, 3), Decl(mappedTypeModifiers.ts, 66, 3), Decl(mappedTypeModifiers.ts, 67, 3), Decl(mappedTypeModifiers.ts, 68, 3))
|
||||
>Pick : Symbol(Pick, Decl(lib.d.ts, --, --))
|
||||
>BP : Symbol(BP, Decl(mappedTypeModifiers.ts, 45, 73))
|
||||
>B : Symbol(B, Decl(mappedTypeModifiers.ts, 42, 51))
|
||||
>B : Symbol(B, Decl(mappedTypeModifiers.ts, 38, 51))
|
||||
>B : Symbol(B, Decl(mappedTypeModifiers.ts, 38, 51))
|
||||
>B : Symbol(B, Decl(mappedTypeModifiers.ts, 38, 51))
|
||||
|
||||
var b02: Pick<BPR, keyof B>;
|
||||
>b02 : Symbol(b02, Decl(mappedTypeModifiers.ts, 64, 3), Decl(mappedTypeModifiers.ts, 65, 3), Decl(mappedTypeModifiers.ts, 66, 3), Decl(mappedTypeModifiers.ts, 67, 3), Decl(mappedTypeModifiers.ts, 68, 3))
|
||||
>Pick : Symbol(Pick, Decl(lib.d.ts, --, --))
|
||||
>BPR : Symbol(BPR, Decl(mappedTypeModifiers.ts, 47, 67))
|
||||
>B : Symbol(B, Decl(mappedTypeModifiers.ts, 42, 51))
|
||||
var b02: BP;
|
||||
>b02 : Symbol(b02, Decl(mappedTypeModifiers.ts, 56, 3), Decl(mappedTypeModifiers.ts, 57, 3), Decl(mappedTypeModifiers.ts, 58, 3), Decl(mappedTypeModifiers.ts, 59, 3), Decl(mappedTypeModifiers.ts, 60, 3))
|
||||
>BP : Symbol(BP, Decl(mappedTypeModifiers.ts, 40, 48))
|
||||
|
||||
var b02: Pick<Partial<B>, keyof B>;
|
||||
>b02 : Symbol(b02, Decl(mappedTypeModifiers.ts, 64, 3), Decl(mappedTypeModifiers.ts, 65, 3), Decl(mappedTypeModifiers.ts, 66, 3), Decl(mappedTypeModifiers.ts, 67, 3), Decl(mappedTypeModifiers.ts, 68, 3))
|
||||
>Pick : Symbol(Pick, Decl(lib.d.ts, --, --))
|
||||
var b02: { [P in keyof B]?: B[P] };
|
||||
>b02 : Symbol(b02, Decl(mappedTypeModifiers.ts, 56, 3), Decl(mappedTypeModifiers.ts, 57, 3), Decl(mappedTypeModifiers.ts, 58, 3), Decl(mappedTypeModifiers.ts, 59, 3), Decl(mappedTypeModifiers.ts, 60, 3))
|
||||
>P : Symbol(P, Decl(mappedTypeModifiers.ts, 57, 12))
|
||||
>B : Symbol(B, Decl(mappedTypeModifiers.ts, 38, 51))
|
||||
>B : Symbol(B, Decl(mappedTypeModifiers.ts, 38, 51))
|
||||
>P : Symbol(P, Decl(mappedTypeModifiers.ts, 57, 12))
|
||||
|
||||
var b02: Partial<B>;
|
||||
>b02 : Symbol(b02, Decl(mappedTypeModifiers.ts, 56, 3), Decl(mappedTypeModifiers.ts, 57, 3), Decl(mappedTypeModifiers.ts, 58, 3), Decl(mappedTypeModifiers.ts, 59, 3), Decl(mappedTypeModifiers.ts, 60, 3))
|
||||
>Partial : Symbol(Partial, Decl(lib.d.ts, --, --))
|
||||
>B : Symbol(B, Decl(mappedTypeModifiers.ts, 42, 51))
|
||||
>B : Symbol(B, Decl(mappedTypeModifiers.ts, 42, 51))
|
||||
>B : Symbol(B, Decl(mappedTypeModifiers.ts, 38, 51))
|
||||
|
||||
var b02: Pick<Partial<Readonly<B>>, keyof B>;
|
||||
>b02 : Symbol(b02, Decl(mappedTypeModifiers.ts, 64, 3), Decl(mappedTypeModifiers.ts, 65, 3), Decl(mappedTypeModifiers.ts, 66, 3), Decl(mappedTypeModifiers.ts, 67, 3), Decl(mappedTypeModifiers.ts, 68, 3))
|
||||
var b02: { [P in keyof BP]: BP[P] }
|
||||
>b02 : Symbol(b02, Decl(mappedTypeModifiers.ts, 56, 3), Decl(mappedTypeModifiers.ts, 57, 3), Decl(mappedTypeModifiers.ts, 58, 3), Decl(mappedTypeModifiers.ts, 59, 3), Decl(mappedTypeModifiers.ts, 60, 3))
|
||||
>P : Symbol(P, Decl(mappedTypeModifiers.ts, 59, 12))
|
||||
>BP : Symbol(BP, Decl(mappedTypeModifiers.ts, 40, 48))
|
||||
>BP : Symbol(BP, Decl(mappedTypeModifiers.ts, 40, 48))
|
||||
>P : Symbol(P, Decl(mappedTypeModifiers.ts, 59, 12))
|
||||
|
||||
var b02: Pick<BP, keyof BP>;
|
||||
>b02 : Symbol(b02, Decl(mappedTypeModifiers.ts, 56, 3), Decl(mappedTypeModifiers.ts, 57, 3), Decl(mappedTypeModifiers.ts, 58, 3), Decl(mappedTypeModifiers.ts, 59, 3), Decl(mappedTypeModifiers.ts, 60, 3))
|
||||
>Pick : Symbol(Pick, Decl(lib.d.ts, --, --))
|
||||
>BP : Symbol(BP, Decl(mappedTypeModifiers.ts, 40, 48))
|
||||
>BP : Symbol(BP, Decl(mappedTypeModifiers.ts, 40, 48))
|
||||
|
||||
var b03: BR;
|
||||
>b03 : Symbol(b03, Decl(mappedTypeModifiers.ts, 62, 3), Decl(mappedTypeModifiers.ts, 63, 3), Decl(mappedTypeModifiers.ts, 64, 3), Decl(mappedTypeModifiers.ts, 65, 3), Decl(mappedTypeModifiers.ts, 66, 3))
|
||||
>BR : Symbol(BR, Decl(mappedTypeModifiers.ts, 41, 51))
|
||||
|
||||
var b03: { readonly [P in keyof B]: B[P] };
|
||||
>b03 : Symbol(b03, Decl(mappedTypeModifiers.ts, 62, 3), Decl(mappedTypeModifiers.ts, 63, 3), Decl(mappedTypeModifiers.ts, 64, 3), Decl(mappedTypeModifiers.ts, 65, 3), Decl(mappedTypeModifiers.ts, 66, 3))
|
||||
>P : Symbol(P, Decl(mappedTypeModifiers.ts, 63, 21))
|
||||
>B : Symbol(B, Decl(mappedTypeModifiers.ts, 38, 51))
|
||||
>B : Symbol(B, Decl(mappedTypeModifiers.ts, 38, 51))
|
||||
>P : Symbol(P, Decl(mappedTypeModifiers.ts, 63, 21))
|
||||
|
||||
var b03: Readonly<B>;
|
||||
>b03 : Symbol(b03, Decl(mappedTypeModifiers.ts, 62, 3), Decl(mappedTypeModifiers.ts, 63, 3), Decl(mappedTypeModifiers.ts, 64, 3), Decl(mappedTypeModifiers.ts, 65, 3), Decl(mappedTypeModifiers.ts, 66, 3))
|
||||
>Readonly : Symbol(Readonly, Decl(lib.d.ts, --, --))
|
||||
>B : Symbol(B, Decl(mappedTypeModifiers.ts, 38, 51))
|
||||
|
||||
var b03: { [P in keyof BR]: BR[P] }
|
||||
>b03 : Symbol(b03, Decl(mappedTypeModifiers.ts, 62, 3), Decl(mappedTypeModifiers.ts, 63, 3), Decl(mappedTypeModifiers.ts, 64, 3), Decl(mappedTypeModifiers.ts, 65, 3), Decl(mappedTypeModifiers.ts, 66, 3))
|
||||
>P : Symbol(P, Decl(mappedTypeModifiers.ts, 65, 12))
|
||||
>BR : Symbol(BR, Decl(mappedTypeModifiers.ts, 41, 51))
|
||||
>BR : Symbol(BR, Decl(mappedTypeModifiers.ts, 41, 51))
|
||||
>P : Symbol(P, Decl(mappedTypeModifiers.ts, 65, 12))
|
||||
|
||||
var b03: Pick<BR, keyof BR>;
|
||||
>b03 : Symbol(b03, Decl(mappedTypeModifiers.ts, 62, 3), Decl(mappedTypeModifiers.ts, 63, 3), Decl(mappedTypeModifiers.ts, 64, 3), Decl(mappedTypeModifiers.ts, 65, 3), Decl(mappedTypeModifiers.ts, 66, 3))
|
||||
>Pick : Symbol(Pick, Decl(lib.d.ts, --, --))
|
||||
>BR : Symbol(BR, Decl(mappedTypeModifiers.ts, 41, 51))
|
||||
>BR : Symbol(BR, Decl(mappedTypeModifiers.ts, 41, 51))
|
||||
|
||||
var b04: BPR;
|
||||
>b04 : Symbol(b04, Decl(mappedTypeModifiers.ts, 68, 3), Decl(mappedTypeModifiers.ts, 69, 3), Decl(mappedTypeModifiers.ts, 70, 3), Decl(mappedTypeModifiers.ts, 71, 3), Decl(mappedTypeModifiers.ts, 72, 3), Decl(mappedTypeModifiers.ts, 73, 3), Decl(mappedTypeModifiers.ts, 74, 3), Decl(mappedTypeModifiers.ts, 75, 3))
|
||||
>BPR : Symbol(BPR, Decl(mappedTypeModifiers.ts, 42, 67))
|
||||
|
||||
var b04: { readonly [P in keyof B]?: B[P] };
|
||||
>b04 : Symbol(b04, Decl(mappedTypeModifiers.ts, 68, 3), Decl(mappedTypeModifiers.ts, 69, 3), Decl(mappedTypeModifiers.ts, 70, 3), Decl(mappedTypeModifiers.ts, 71, 3), Decl(mappedTypeModifiers.ts, 72, 3), Decl(mappedTypeModifiers.ts, 73, 3), Decl(mappedTypeModifiers.ts, 74, 3), Decl(mappedTypeModifiers.ts, 75, 3))
|
||||
>P : Symbol(P, Decl(mappedTypeModifiers.ts, 69, 21))
|
||||
>B : Symbol(B, Decl(mappedTypeModifiers.ts, 38, 51))
|
||||
>B : Symbol(B, Decl(mappedTypeModifiers.ts, 38, 51))
|
||||
>P : Symbol(P, Decl(mappedTypeModifiers.ts, 69, 21))
|
||||
|
||||
var b04: Partial<BR>;
|
||||
>b04 : Symbol(b04, Decl(mappedTypeModifiers.ts, 68, 3), Decl(mappedTypeModifiers.ts, 69, 3), Decl(mappedTypeModifiers.ts, 70, 3), Decl(mappedTypeModifiers.ts, 71, 3), Decl(mappedTypeModifiers.ts, 72, 3), Decl(mappedTypeModifiers.ts, 73, 3), Decl(mappedTypeModifiers.ts, 74, 3), Decl(mappedTypeModifiers.ts, 75, 3))
|
||||
>Partial : Symbol(Partial, Decl(lib.d.ts, --, --))
|
||||
>BR : Symbol(BR, Decl(mappedTypeModifiers.ts, 41, 51))
|
||||
|
||||
var b04: Readonly<BP>;
|
||||
>b04 : Symbol(b04, Decl(mappedTypeModifiers.ts, 68, 3), Decl(mappedTypeModifiers.ts, 69, 3), Decl(mappedTypeModifiers.ts, 70, 3), Decl(mappedTypeModifiers.ts, 71, 3), Decl(mappedTypeModifiers.ts, 72, 3), Decl(mappedTypeModifiers.ts, 73, 3), Decl(mappedTypeModifiers.ts, 74, 3), Decl(mappedTypeModifiers.ts, 75, 3))
|
||||
>Readonly : Symbol(Readonly, Decl(lib.d.ts, --, --))
|
||||
>BP : Symbol(BP, Decl(mappedTypeModifiers.ts, 40, 48))
|
||||
|
||||
var b04: Partial<Readonly<B>>;
|
||||
>b04 : Symbol(b04, Decl(mappedTypeModifiers.ts, 68, 3), Decl(mappedTypeModifiers.ts, 69, 3), Decl(mappedTypeModifiers.ts, 70, 3), Decl(mappedTypeModifiers.ts, 71, 3), Decl(mappedTypeModifiers.ts, 72, 3), Decl(mappedTypeModifiers.ts, 73, 3), Decl(mappedTypeModifiers.ts, 74, 3), Decl(mappedTypeModifiers.ts, 75, 3))
|
||||
>Partial : Symbol(Partial, Decl(lib.d.ts, --, --))
|
||||
>Readonly : Symbol(Readonly, Decl(lib.d.ts, --, --))
|
||||
>B : Symbol(B, Decl(mappedTypeModifiers.ts, 42, 51))
|
||||
>B : Symbol(B, Decl(mappedTypeModifiers.ts, 42, 51))
|
||||
>B : Symbol(B, Decl(mappedTypeModifiers.ts, 38, 51))
|
||||
|
||||
// Validate that isomorphic mapped types preserve optional modifier
|
||||
var b03: BP;
|
||||
>b03 : Symbol(b03, Decl(mappedTypeModifiers.ts, 71, 3), Decl(mappedTypeModifiers.ts, 72, 3))
|
||||
>BP : Symbol(BP, Decl(mappedTypeModifiers.ts, 45, 73))
|
||||
|
||||
var b03: Partial<B>;
|
||||
>b03 : Symbol(b03, Decl(mappedTypeModifiers.ts, 71, 3), Decl(mappedTypeModifiers.ts, 72, 3))
|
||||
>Partial : Symbol(Partial, Decl(lib.d.ts, --, --))
|
||||
>B : Symbol(B, Decl(mappedTypeModifiers.ts, 42, 51))
|
||||
|
||||
// Validate that isomorphic mapped types preserve readonly modifier
|
||||
var b04: BR;
|
||||
>b04 : Symbol(b04, Decl(mappedTypeModifiers.ts, 75, 3), Decl(mappedTypeModifiers.ts, 76, 3))
|
||||
>BR : Symbol(BR, Decl(mappedTypeModifiers.ts, 46, 51))
|
||||
|
||||
var b04: Readonly<B>;
|
||||
>b04 : Symbol(b04, Decl(mappedTypeModifiers.ts, 75, 3), Decl(mappedTypeModifiers.ts, 76, 3))
|
||||
>Readonly : Symbol(Readonly, Decl(lib.d.ts, --, --))
|
||||
>B : Symbol(B, Decl(mappedTypeModifiers.ts, 42, 51))
|
||||
|
||||
// Validate that isomorphic mapped types preserve both partial and readonly modifiers
|
||||
var b05: BPR;
|
||||
>b05 : Symbol(b05, Decl(mappedTypeModifiers.ts, 79, 3), Decl(mappedTypeModifiers.ts, 80, 3), Decl(mappedTypeModifiers.ts, 81, 3), Decl(mappedTypeModifiers.ts, 82, 3), Decl(mappedTypeModifiers.ts, 83, 3))
|
||||
>BPR : Symbol(BPR, Decl(mappedTypeModifiers.ts, 47, 67))
|
||||
|
||||
var b05: Partial<BR>;
|
||||
>b05 : Symbol(b05, Decl(mappedTypeModifiers.ts, 79, 3), Decl(mappedTypeModifiers.ts, 80, 3), Decl(mappedTypeModifiers.ts, 81, 3), Decl(mappedTypeModifiers.ts, 82, 3), Decl(mappedTypeModifiers.ts, 83, 3))
|
||||
>Partial : Symbol(Partial, Decl(lib.d.ts, --, --))
|
||||
>BR : Symbol(BR, Decl(mappedTypeModifiers.ts, 46, 51))
|
||||
|
||||
var b05: Readonly<BP>;
|
||||
>b05 : Symbol(b05, Decl(mappedTypeModifiers.ts, 79, 3), Decl(mappedTypeModifiers.ts, 80, 3), Decl(mappedTypeModifiers.ts, 81, 3), Decl(mappedTypeModifiers.ts, 82, 3), Decl(mappedTypeModifiers.ts, 83, 3))
|
||||
>Readonly : Symbol(Readonly, Decl(lib.d.ts, --, --))
|
||||
>BP : Symbol(BP, Decl(mappedTypeModifiers.ts, 45, 73))
|
||||
|
||||
var b05: Partial<Readonly<B>>;
|
||||
>b05 : Symbol(b05, Decl(mappedTypeModifiers.ts, 79, 3), Decl(mappedTypeModifiers.ts, 80, 3), Decl(mappedTypeModifiers.ts, 81, 3), Decl(mappedTypeModifiers.ts, 82, 3), Decl(mappedTypeModifiers.ts, 83, 3))
|
||||
>Partial : Symbol(Partial, Decl(lib.d.ts, --, --))
|
||||
>Readonly : Symbol(Readonly, Decl(lib.d.ts, --, --))
|
||||
>B : Symbol(B, Decl(mappedTypeModifiers.ts, 42, 51))
|
||||
|
||||
var b05: Readonly<Partial<B>>;
|
||||
>b05 : Symbol(b05, Decl(mappedTypeModifiers.ts, 79, 3), Decl(mappedTypeModifiers.ts, 80, 3), Decl(mappedTypeModifiers.ts, 81, 3), Decl(mappedTypeModifiers.ts, 82, 3), Decl(mappedTypeModifiers.ts, 83, 3))
|
||||
var b04: Readonly<Partial<B>>;
|
||||
>b04 : Symbol(b04, Decl(mappedTypeModifiers.ts, 68, 3), Decl(mappedTypeModifiers.ts, 69, 3), Decl(mappedTypeModifiers.ts, 70, 3), Decl(mappedTypeModifiers.ts, 71, 3), Decl(mappedTypeModifiers.ts, 72, 3), Decl(mappedTypeModifiers.ts, 73, 3), Decl(mappedTypeModifiers.ts, 74, 3), Decl(mappedTypeModifiers.ts, 75, 3))
|
||||
>Readonly : Symbol(Readonly, Decl(lib.d.ts, --, --))
|
||||
>Partial : Symbol(Partial, Decl(lib.d.ts, --, --))
|
||||
>B : Symbol(B, Decl(mappedTypeModifiers.ts, 42, 51))
|
||||
>B : Symbol(B, Decl(mappedTypeModifiers.ts, 38, 51))
|
||||
|
||||
var b04: { [P in keyof BPR]: BPR[P] }
|
||||
>b04 : Symbol(b04, Decl(mappedTypeModifiers.ts, 68, 3), Decl(mappedTypeModifiers.ts, 69, 3), Decl(mappedTypeModifiers.ts, 70, 3), Decl(mappedTypeModifiers.ts, 71, 3), Decl(mappedTypeModifiers.ts, 72, 3), Decl(mappedTypeModifiers.ts, 73, 3), Decl(mappedTypeModifiers.ts, 74, 3), Decl(mappedTypeModifiers.ts, 75, 3))
|
||||
>P : Symbol(P, Decl(mappedTypeModifiers.ts, 74, 12))
|
||||
>BPR : Symbol(BPR, Decl(mappedTypeModifiers.ts, 42, 67))
|
||||
>BPR : Symbol(BPR, Decl(mappedTypeModifiers.ts, 42, 67))
|
||||
>P : Symbol(P, Decl(mappedTypeModifiers.ts, 74, 12))
|
||||
|
||||
var b04: Pick<BPR, keyof BPR>;
|
||||
>b04 : Symbol(b04, Decl(mappedTypeModifiers.ts, 68, 3), Decl(mappedTypeModifiers.ts, 69, 3), Decl(mappedTypeModifiers.ts, 70, 3), Decl(mappedTypeModifiers.ts, 71, 3), Decl(mappedTypeModifiers.ts, 72, 3), Decl(mappedTypeModifiers.ts, 73, 3), Decl(mappedTypeModifiers.ts, 74, 3), Decl(mappedTypeModifiers.ts, 75, 3))
|
||||
>Pick : Symbol(Pick, Decl(lib.d.ts, --, --))
|
||||
>BPR : Symbol(BPR, Decl(mappedTypeModifiers.ts, 42, 67))
|
||||
>BPR : Symbol(BPR, Decl(mappedTypeModifiers.ts, 42, 67))
|
||||
|
||||
|
||||
@@ -5,11 +5,6 @@ type T = { a: number, b: string };
|
||||
>a : number
|
||||
>b : string
|
||||
|
||||
type TU = { a: number | undefined, b: string | undefined };
|
||||
>TU : TU
|
||||
>a : number | undefined
|
||||
>b : string | undefined
|
||||
|
||||
type TP = { a?: number, b?: string };
|
||||
>TP : TP
|
||||
>a : number | undefined
|
||||
@@ -25,7 +20,6 @@ type TPR = { readonly a?: number, readonly b?: string };
|
||||
>a : number | undefined
|
||||
>b : string | undefined
|
||||
|
||||
// Validate they all have the same keys
|
||||
var v00: "a" | "b";
|
||||
>v00 : "a" | "b"
|
||||
|
||||
@@ -33,10 +27,6 @@ var v00: keyof T;
|
||||
>v00 : "a" | "b"
|
||||
>T : T
|
||||
|
||||
var v00: keyof TU;
|
||||
>v00 : "a" | "b"
|
||||
>TU : TU
|
||||
|
||||
var v00: keyof TP;
|
||||
>v00 : "a" | "b"
|
||||
>TP : TP
|
||||
@@ -49,103 +39,135 @@ var v00: keyof TPR;
|
||||
>v00 : "a" | "b"
|
||||
>TPR : TPR
|
||||
|
||||
// Validate that non-isomorphic mapped types strip modifiers
|
||||
var v01: T;
|
||||
>v01 : T
|
||||
>T : T
|
||||
|
||||
var v01: Pick<TR, keyof T>;
|
||||
var v01: { [P in keyof T]: T[P] };
|
||||
>v01 : T
|
||||
>P : P
|
||||
>T : T
|
||||
>T : T
|
||||
>P : P
|
||||
|
||||
var v01: Pick<T, keyof T>;
|
||||
>v01 : T
|
||||
>Pick : Pick<T, K>
|
||||
>TR : TR
|
||||
>T : T
|
||||
>T : T
|
||||
|
||||
var v01: Pick<Readonly<T>, keyof T>;
|
||||
var v01: Pick<Pick<T, keyof T>, keyof T>;
|
||||
>v01 : T
|
||||
>Pick : Pick<T, K>
|
||||
>Readonly : Readonly<T>
|
||||
>T : T
|
||||
>T : T
|
||||
|
||||
// Validate that non-isomorphic mapped types strip modifiers
|
||||
var v02: TU;
|
||||
>v02 : TU
|
||||
>TU : TU
|
||||
|
||||
var v02: Pick<TP, keyof T>;
|
||||
>v02 : TU
|
||||
>Pick : Pick<T, K>
|
||||
>TP : TP
|
||||
>T : T
|
||||
|
||||
var v02: Pick<TPR, keyof T>;
|
||||
>v02 : TU
|
||||
>Pick : Pick<T, K>
|
||||
>TPR : TPR
|
||||
>T : T
|
||||
|
||||
var v02: Pick<Partial<T>, keyof T>;
|
||||
>v02 : TU
|
||||
>Pick : Pick<T, K>
|
||||
>Partial : Partial<T>
|
||||
>T : T
|
||||
>T : T
|
||||
|
||||
var v02: Pick<Partial<Readonly<T>>, keyof T>;
|
||||
>v02 : TU
|
||||
>Pick : Pick<T, K>
|
||||
>Partial : Partial<T>
|
||||
>Readonly : Readonly<T>
|
||||
>T : T
|
||||
>T : T
|
||||
|
||||
// Validate that isomorphic mapped types preserve optional modifier
|
||||
var v03: TP;
|
||||
>v03 : TP
|
||||
var v02: TP;
|
||||
>v02 : TP
|
||||
>TP : TP
|
||||
|
||||
var v03: Partial<T>;
|
||||
>v03 : TP
|
||||
var v02: { [P in keyof T]?: T[P] };
|
||||
>v02 : TP
|
||||
>P : P
|
||||
>T : T
|
||||
>T : T
|
||||
>P : P
|
||||
|
||||
var v02: Partial<T>;
|
||||
>v02 : TP
|
||||
>Partial : Partial<T>
|
||||
>T : T
|
||||
|
||||
// Validate that isomorphic mapped types preserve readonly modifier
|
||||
var v04: TR;
|
||||
>v04 : TR
|
||||
var v02: { [P in keyof TP]: TP[P] }
|
||||
>v02 : TP
|
||||
>P : P
|
||||
>TP : TP
|
||||
>TP : TP
|
||||
>P : P
|
||||
|
||||
var v02: Pick<TP, keyof TP>;
|
||||
>v02 : TP
|
||||
>Pick : Pick<T, K>
|
||||
>TP : TP
|
||||
>TP : TP
|
||||
|
||||
var v03: TR;
|
||||
>v03 : TR
|
||||
>TR : TR
|
||||
|
||||
var v04: Readonly<T>;
|
||||
>v04 : TR
|
||||
var v03: { readonly [P in keyof T]: T[P] };
|
||||
>v03 : TR
|
||||
>P : P
|
||||
>T : T
|
||||
>T : T
|
||||
>P : P
|
||||
|
||||
var v03: Readonly<T>;
|
||||
>v03 : TR
|
||||
>Readonly : Readonly<T>
|
||||
>T : T
|
||||
|
||||
// Validate that isomorphic mapped types preserve both partial and readonly modifiers
|
||||
var v05: TPR;
|
||||
>v05 : TPR
|
||||
var v03: { [P in keyof TR]: TR[P] }
|
||||
>v03 : TR
|
||||
>P : P
|
||||
>TR : TR
|
||||
>TR : TR
|
||||
>P : P
|
||||
|
||||
var v03: Pick<TR, keyof TR>;
|
||||
>v03 : TR
|
||||
>Pick : Pick<T, K>
|
||||
>TR : TR
|
||||
>TR : TR
|
||||
|
||||
var v04: TPR;
|
||||
>v04 : TPR
|
||||
>TPR : TPR
|
||||
|
||||
var v05: Partial<TR>;
|
||||
>v05 : TPR
|
||||
var v04: { readonly [P in keyof T]?: T[P] };
|
||||
>v04 : TPR
|
||||
>P : P
|
||||
>T : T
|
||||
>T : T
|
||||
>P : P
|
||||
|
||||
var v04: Partial<TR>;
|
||||
>v04 : TPR
|
||||
>Partial : Partial<T>
|
||||
>TR : TR
|
||||
|
||||
var v05: Readonly<TP>;
|
||||
>v05 : TPR
|
||||
var v04: Readonly<TP>;
|
||||
>v04 : TPR
|
||||
>Readonly : Readonly<T>
|
||||
>TP : TP
|
||||
|
||||
var v05: Partial<Readonly<T>>;
|
||||
>v05 : TPR
|
||||
var v04: Partial<Readonly<T>>;
|
||||
>v04 : TPR
|
||||
>Partial : Partial<T>
|
||||
>Readonly : Readonly<T>
|
||||
>T : T
|
||||
|
||||
var v05: Readonly<Partial<T>>;
|
||||
>v05 : TPR
|
||||
var v04: Readonly<Partial<T>>;
|
||||
>v04 : TPR
|
||||
>Readonly : Readonly<T>
|
||||
>Partial : Partial<T>
|
||||
>T : T
|
||||
|
||||
var v04: { [P in keyof TPR]: TPR[P] }
|
||||
>v04 : TPR
|
||||
>P : P
|
||||
>TPR : TPR
|
||||
>TPR : TPR
|
||||
>P : P
|
||||
|
||||
var v04: Pick<TPR, keyof T>;
|
||||
>v04 : TPR
|
||||
>Pick : Pick<T, K>
|
||||
>TPR : TPR
|
||||
>T : T
|
||||
|
||||
type Boxified<T> = { [P in keyof T]: { x: T[P] } };
|
||||
>Boxified : Boxified<T>
|
||||
>T : T
|
||||
@@ -162,13 +184,6 @@ type B = { a: { x: number }, b: { x: string } };
|
||||
>b : { x: string; }
|
||||
>x : string
|
||||
|
||||
type BU = { a: { x: number } | undefined, b: { x: string } | undefined };
|
||||
>BU : BU
|
||||
>a : { x: number; } | undefined
|
||||
>x : number
|
||||
>b : { x: string; } | undefined
|
||||
>x : string
|
||||
|
||||
type BP = { a?: { x: number }, b?: { x: string } };
|
||||
>BP : BP
|
||||
>a : { x: number; } | undefined
|
||||
@@ -190,7 +205,6 @@ type BPR = { readonly a?: { x: number }, readonly b?: { x: string } };
|
||||
>b : { x: string; } | undefined
|
||||
>x : string
|
||||
|
||||
// Validate they all have the same keys
|
||||
var b00: "a" | "b";
|
||||
>b00 : "a" | "b"
|
||||
|
||||
@@ -198,10 +212,6 @@ var b00: keyof B;
|
||||
>b00 : "a" | "b"
|
||||
>B : B
|
||||
|
||||
var b00: keyof BU;
|
||||
>b00 : "a" | "b"
|
||||
>BU : BU
|
||||
|
||||
var b00: keyof BP;
|
||||
>b00 : "a" | "b"
|
||||
>BP : BP
|
||||
@@ -214,100 +224,132 @@ var b00: keyof BPR;
|
||||
>b00 : "a" | "b"
|
||||
>BPR : BPR
|
||||
|
||||
// Validate that non-isomorphic mapped types strip modifiers
|
||||
var b01: B;
|
||||
>b01 : B
|
||||
>B : B
|
||||
|
||||
var b01: Pick<BR, keyof B>;
|
||||
var b01: { [P in keyof B]: B[P] };
|
||||
>b01 : B
|
||||
>P : P
|
||||
>B : B
|
||||
>B : B
|
||||
>P : P
|
||||
|
||||
var b01: Pick<B, keyof B>;
|
||||
>b01 : B
|
||||
>Pick : Pick<T, K>
|
||||
>BR : BR
|
||||
>B : B
|
||||
>B : B
|
||||
|
||||
var b01: Pick<Readonly<BR>, keyof B>;
|
||||
var b01: Pick<Pick<B, keyof B>, keyof B>;
|
||||
>b01 : B
|
||||
>Pick : Pick<T, K>
|
||||
>Readonly : Readonly<T>
|
||||
>BR : BR
|
||||
>B : B
|
||||
|
||||
// Validate that non-isomorphic mapped types strip modifiers
|
||||
var b02: BU;
|
||||
>b02 : BU
|
||||
>BU : BU
|
||||
|
||||
var b02: Pick<BP, keyof B>;
|
||||
>b02 : BU
|
||||
>Pick : Pick<T, K>
|
||||
>BP : BP
|
||||
>B : B
|
||||
|
||||
var b02: Pick<BPR, keyof B>;
|
||||
>b02 : BU
|
||||
>Pick : Pick<T, K>
|
||||
>BPR : BPR
|
||||
>B : B
|
||||
|
||||
var b02: Pick<Partial<B>, keyof B>;
|
||||
>b02 : BU
|
||||
>Pick : Pick<T, K>
|
||||
>Partial : Partial<T>
|
||||
>B : B
|
||||
>B : B
|
||||
|
||||
var b02: Pick<Partial<Readonly<B>>, keyof B>;
|
||||
>b02 : BU
|
||||
>Pick : Pick<T, K>
|
||||
>Partial : Partial<T>
|
||||
>Readonly : Readonly<T>
|
||||
>B : B
|
||||
>B : B
|
||||
|
||||
// Validate that isomorphic mapped types preserve optional modifier
|
||||
var b03: BP;
|
||||
>b03 : BP
|
||||
var b02: BP;
|
||||
>b02 : BP
|
||||
>BP : BP
|
||||
|
||||
var b03: Partial<B>;
|
||||
>b03 : BP
|
||||
var b02: { [P in keyof B]?: B[P] };
|
||||
>b02 : BP
|
||||
>P : P
|
||||
>B : B
|
||||
>B : B
|
||||
>P : P
|
||||
|
||||
var b02: Partial<B>;
|
||||
>b02 : BP
|
||||
>Partial : Partial<T>
|
||||
>B : B
|
||||
|
||||
// Validate that isomorphic mapped types preserve readonly modifier
|
||||
var b04: BR;
|
||||
>b04 : BR
|
||||
var b02: { [P in keyof BP]: BP[P] }
|
||||
>b02 : BP
|
||||
>P : P
|
||||
>BP : BP
|
||||
>BP : BP
|
||||
>P : P
|
||||
|
||||
var b02: Pick<BP, keyof BP>;
|
||||
>b02 : BP
|
||||
>Pick : Pick<T, K>
|
||||
>BP : BP
|
||||
>BP : BP
|
||||
|
||||
var b03: BR;
|
||||
>b03 : BR
|
||||
>BR : BR
|
||||
|
||||
var b04: Readonly<B>;
|
||||
>b04 : BR
|
||||
var b03: { readonly [P in keyof B]: B[P] };
|
||||
>b03 : BR
|
||||
>P : P
|
||||
>B : B
|
||||
>B : B
|
||||
>P : P
|
||||
|
||||
var b03: Readonly<B>;
|
||||
>b03 : BR
|
||||
>Readonly : Readonly<T>
|
||||
>B : B
|
||||
|
||||
// Validate that isomorphic mapped types preserve both partial and readonly modifiers
|
||||
var b05: BPR;
|
||||
>b05 : BPR
|
||||
var b03: { [P in keyof BR]: BR[P] }
|
||||
>b03 : BR
|
||||
>P : P
|
||||
>BR : BR
|
||||
>BR : BR
|
||||
>P : P
|
||||
|
||||
var b03: Pick<BR, keyof BR>;
|
||||
>b03 : BR
|
||||
>Pick : Pick<T, K>
|
||||
>BR : BR
|
||||
>BR : BR
|
||||
|
||||
var b04: BPR;
|
||||
>b04 : BPR
|
||||
>BPR : BPR
|
||||
|
||||
var b05: Partial<BR>;
|
||||
>b05 : BPR
|
||||
var b04: { readonly [P in keyof B]?: B[P] };
|
||||
>b04 : BPR
|
||||
>P : P
|
||||
>B : B
|
||||
>B : B
|
||||
>P : P
|
||||
|
||||
var b04: Partial<BR>;
|
||||
>b04 : BPR
|
||||
>Partial : Partial<T>
|
||||
>BR : BR
|
||||
|
||||
var b05: Readonly<BP>;
|
||||
>b05 : BPR
|
||||
var b04: Readonly<BP>;
|
||||
>b04 : BPR
|
||||
>Readonly : Readonly<T>
|
||||
>BP : BP
|
||||
|
||||
var b05: Partial<Readonly<B>>;
|
||||
>b05 : BPR
|
||||
var b04: Partial<Readonly<B>>;
|
||||
>b04 : BPR
|
||||
>Partial : Partial<T>
|
||||
>Readonly : Readonly<T>
|
||||
>B : B
|
||||
|
||||
var b05: Readonly<Partial<B>>;
|
||||
>b05 : BPR
|
||||
var b04: Readonly<Partial<B>>;
|
||||
>b04 : BPR
|
||||
>Readonly : Readonly<T>
|
||||
>Partial : Partial<T>
|
||||
>B : B
|
||||
|
||||
var b04: { [P in keyof BPR]: BPR[P] }
|
||||
>b04 : BPR
|
||||
>P : P
|
||||
>BPR : BPR
|
||||
>BPR : BPR
|
||||
>P : P
|
||||
|
||||
var b04: Pick<BPR, keyof BPR>;
|
||||
>b04 : BPR
|
||||
>Pick : Pick<T, K>
|
||||
>BPR : BPR
|
||||
>BPR : BPR
|
||||
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
tests/cases/compiler/nestedFreshLiteral.ts(12,21): error TS2322: Type '{ nested: { prop: { colour: string; }; }; }' is not assignable to type 'NestedCSSProps'.
|
||||
Types of property 'nested' are incompatible.
|
||||
Type '{ prop: { colour: string; }; }' is not assignable to type 'NestedSelector | undefined'.
|
||||
Type '{ prop: { colour: string; }; }' is not assignable to type 'NestedSelector'.
|
||||
Types of property 'prop' are incompatible.
|
||||
Type '{ colour: string; }' is not assignable to type 'CSSProps'.
|
||||
Object literal may only specify known properties, and 'colour' does not exist in type 'CSSProps'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/nestedFreshLiteral.ts (1 errors) ====
|
||||
interface CSSProps {
|
||||
color?: string
|
||||
}
|
||||
interface NestedCSSProps {
|
||||
nested?: NestedSelector
|
||||
}
|
||||
interface NestedSelector {
|
||||
prop: CSSProps;
|
||||
}
|
||||
|
||||
let stylen: NestedCSSProps = {
|
||||
nested: { prop: { colour: 'red' } }
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2322: Type '{ nested: { prop: { colour: string; }; }; }' is not assignable to type 'NestedCSSProps'.
|
||||
!!! error TS2322: Types of property 'nested' are incompatible.
|
||||
!!! error TS2322: Type '{ prop: { colour: string; }; }' is not assignable to type 'NestedSelector | undefined'.
|
||||
!!! error TS2322: Type '{ prop: { colour: string; }; }' is not assignable to type 'NestedSelector'.
|
||||
!!! error TS2322: Types of property 'prop' are incompatible.
|
||||
!!! error TS2322: Type '{ colour: string; }' is not assignable to type 'CSSProps'.
|
||||
!!! error TS2322: Object literal may only specify known properties, and 'colour' does not exist in type 'CSSProps'.
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
//// [nestedFreshLiteral.ts]
|
||||
interface CSSProps {
|
||||
color?: string
|
||||
}
|
||||
interface NestedCSSProps {
|
||||
nested?: NestedSelector
|
||||
}
|
||||
interface NestedSelector {
|
||||
prop: CSSProps;
|
||||
}
|
||||
|
||||
let stylen: NestedCSSProps = {
|
||||
nested: { prop: { colour: 'red' } }
|
||||
}
|
||||
|
||||
//// [nestedFreshLiteral.js]
|
||||
var stylen = {
|
||||
nested: { prop: { colour: 'red' } }
|
||||
};
|
||||
@@ -0,0 +1,31 @@
|
||||
//// [newLexicalEnvironmentForConvertedLoop.ts]
|
||||
function baz(x: any) {
|
||||
return [[x, x]];
|
||||
}
|
||||
|
||||
function foo(set: any) {
|
||||
for (const [value, i] of baz(set.values)) {
|
||||
const bar: any = [];
|
||||
(() => bar);
|
||||
|
||||
set.values.push(...[]);
|
||||
}
|
||||
};
|
||||
|
||||
//// [newLexicalEnvironmentForConvertedLoop.js]
|
||||
function baz(x) {
|
||||
return [[x, x]];
|
||||
}
|
||||
function foo(set) {
|
||||
var _loop_1 = function (value, i) {
|
||||
var bar = [];
|
||||
(function () { return bar; });
|
||||
(_a = set.values).push.apply(_a, []);
|
||||
var _a;
|
||||
};
|
||||
for (var _i = 0, _a = baz(set.values); _i < _a.length; _i++) {
|
||||
var _b = _a[_i], value = _b[0], i = _b[1];
|
||||
_loop_1(value, i);
|
||||
}
|
||||
}
|
||||
;
|
||||
@@ -0,0 +1,30 @@
|
||||
=== tests/cases/compiler/newLexicalEnvironmentForConvertedLoop.ts ===
|
||||
function baz(x: any) {
|
||||
>baz : Symbol(baz, Decl(newLexicalEnvironmentForConvertedLoop.ts, 0, 0))
|
||||
>x : Symbol(x, Decl(newLexicalEnvironmentForConvertedLoop.ts, 0, 13))
|
||||
|
||||
return [[x, x]];
|
||||
>x : Symbol(x, Decl(newLexicalEnvironmentForConvertedLoop.ts, 0, 13))
|
||||
>x : Symbol(x, Decl(newLexicalEnvironmentForConvertedLoop.ts, 0, 13))
|
||||
}
|
||||
|
||||
function foo(set: any) {
|
||||
>foo : Symbol(foo, Decl(newLexicalEnvironmentForConvertedLoop.ts, 2, 1))
|
||||
>set : Symbol(set, Decl(newLexicalEnvironmentForConvertedLoop.ts, 4, 13))
|
||||
|
||||
for (const [value, i] of baz(set.values)) {
|
||||
>value : Symbol(value, Decl(newLexicalEnvironmentForConvertedLoop.ts, 5, 14))
|
||||
>i : Symbol(i, Decl(newLexicalEnvironmentForConvertedLoop.ts, 5, 20))
|
||||
>baz : Symbol(baz, Decl(newLexicalEnvironmentForConvertedLoop.ts, 0, 0))
|
||||
>set : Symbol(set, Decl(newLexicalEnvironmentForConvertedLoop.ts, 4, 13))
|
||||
|
||||
const bar: any = [];
|
||||
>bar : Symbol(bar, Decl(newLexicalEnvironmentForConvertedLoop.ts, 6, 9))
|
||||
|
||||
(() => bar);
|
||||
>bar : Symbol(bar, Decl(newLexicalEnvironmentForConvertedLoop.ts, 6, 9))
|
||||
|
||||
set.values.push(...[]);
|
||||
>set : Symbol(set, Decl(newLexicalEnvironmentForConvertedLoop.ts, 4, 13))
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,45 @@
|
||||
=== tests/cases/compiler/newLexicalEnvironmentForConvertedLoop.ts ===
|
||||
function baz(x: any) {
|
||||
>baz : (x: any) => any[][]
|
||||
>x : any
|
||||
|
||||
return [[x, x]];
|
||||
>[[x, x]] : any[][]
|
||||
>[x, x] : any[]
|
||||
>x : any
|
||||
>x : any
|
||||
}
|
||||
|
||||
function foo(set: any) {
|
||||
>foo : (set: any) => void
|
||||
>set : any
|
||||
|
||||
for (const [value, i] of baz(set.values)) {
|
||||
>value : any
|
||||
>i : any
|
||||
>baz(set.values) : any[][]
|
||||
>baz : (x: any) => any[][]
|
||||
>set.values : any
|
||||
>set : any
|
||||
>values : any
|
||||
|
||||
const bar: any = [];
|
||||
>bar : any
|
||||
>[] : undefined[]
|
||||
|
||||
(() => bar);
|
||||
>(() => bar) : () => any
|
||||
>() => bar : () => any
|
||||
>bar : any
|
||||
|
||||
set.values.push(...[]);
|
||||
>set.values.push(...[]) : any
|
||||
>set.values.push : any
|
||||
>set.values : any
|
||||
>set : any
|
||||
>values : any
|
||||
>push : any
|
||||
>...[] : undefined
|
||||
>[] : undefined[]
|
||||
}
|
||||
};
|
||||
@@ -200,7 +200,6 @@ let cplus: { p: number, plus(): void } = { ...c, plus() { return this.p + 1; } }
|
||||
>plus : Symbol(plus, Decl(objectSpread.ts, 49, 23))
|
||||
>c : Symbol(c, Decl(objectSpread.ts, 45, 3))
|
||||
>plus : Symbol(plus, Decl(objectSpread.ts, 49, 48))
|
||||
>this : Symbol(__object, Decl(objectSpread.ts, 41, 15))
|
||||
|
||||
cplus.plus();
|
||||
>cplus.plus : Symbol(plus, Decl(objectSpread.ts, 49, 23))
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
tests/cases/compiler/selfReferencingSpreadInLoop.ts(1,5): error TS7034: Variable 'additional' implicitly has type 'any[]' in some locations where its type cannot be determined.
|
||||
tests/cases/compiler/selfReferencingSpreadInLoop.ts(3,22): error TS7005: Variable 'additional' implicitly has an 'any[]' type.
|
||||
|
||||
|
||||
==== tests/cases/compiler/selfReferencingSpreadInLoop.ts (2 errors) ====
|
||||
let additional = [];
|
||||
~~~~~~~~~~
|
||||
!!! error TS7034: Variable 'additional' implicitly has type 'any[]' in some locations where its type cannot be determined.
|
||||
for (const subcomponent of [1, 2, 3]) {
|
||||
additional = [...additional, subcomponent];
|
||||
~~~~~~~~~~
|
||||
!!! error TS7005: Variable 'additional' implicitly has an 'any[]' type.
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
//// [selfReferencingSpreadInLoop.ts]
|
||||
let additional = [];
|
||||
for (const subcomponent of [1, 2, 3]) {
|
||||
additional = [...additional, subcomponent];
|
||||
}
|
||||
|
||||
|
||||
//// [selfReferencingSpreadInLoop.js]
|
||||
var additional = [];
|
||||
for (var _i = 0, _a = [1, 2, 3]; _i < _a.length; _i++) {
|
||||
var subcomponent = _a[_i];
|
||||
additional = additional.concat([subcomponent]);
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
//// [subSubClassCanAccessProtectedConstructor.ts]
|
||||
class Base {
|
||||
protected constructor() { }
|
||||
public instance1 = new Base(); // allowed
|
||||
}
|
||||
|
||||
class Subclass extends Base {
|
||||
public instance1_1 = new Base(); // allowed
|
||||
public instance1_2 = new Subclass(); // allowed
|
||||
}
|
||||
|
||||
class SubclassOfSubclass extends Subclass {
|
||||
public instance2_1 = new Base(); // allowed
|
||||
public instance2_2 = new Subclass(); // allowed
|
||||
public instance2_3 = new SubclassOfSubclass(); // allowed
|
||||
}
|
||||
|
||||
|
||||
//// [subSubClassCanAccessProtectedConstructor.js]
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
var Base = (function () {
|
||||
function Base() {
|
||||
this.instance1 = new Base(); // allowed
|
||||
}
|
||||
return Base;
|
||||
}());
|
||||
var Subclass = (function (_super) {
|
||||
__extends(Subclass, _super);
|
||||
function Subclass() {
|
||||
var _this = _super.apply(this, arguments) || this;
|
||||
_this.instance1_1 = new Base(); // allowed
|
||||
_this.instance1_2 = new Subclass(); // allowed
|
||||
return _this;
|
||||
}
|
||||
return Subclass;
|
||||
}(Base));
|
||||
var SubclassOfSubclass = (function (_super) {
|
||||
__extends(SubclassOfSubclass, _super);
|
||||
function SubclassOfSubclass() {
|
||||
var _this = _super.apply(this, arguments) || this;
|
||||
_this.instance2_1 = new Base(); // allowed
|
||||
_this.instance2_2 = new Subclass(); // allowed
|
||||
_this.instance2_3 = new SubclassOfSubclass(); // allowed
|
||||
return _this;
|
||||
}
|
||||
return SubclassOfSubclass;
|
||||
}(Subclass));
|
||||
@@ -0,0 +1,40 @@
|
||||
=== tests/cases/compiler/subSubClassCanAccessProtectedConstructor.ts ===
|
||||
class Base {
|
||||
>Base : Symbol(Base, Decl(subSubClassCanAccessProtectedConstructor.ts, 0, 0))
|
||||
|
||||
protected constructor() { }
|
||||
public instance1 = new Base(); // allowed
|
||||
>instance1 : Symbol(Base.instance1, Decl(subSubClassCanAccessProtectedConstructor.ts, 1, 31))
|
||||
>Base : Symbol(Base, Decl(subSubClassCanAccessProtectedConstructor.ts, 0, 0))
|
||||
}
|
||||
|
||||
class Subclass extends Base {
|
||||
>Subclass : Symbol(Subclass, Decl(subSubClassCanAccessProtectedConstructor.ts, 3, 1))
|
||||
>Base : Symbol(Base, Decl(subSubClassCanAccessProtectedConstructor.ts, 0, 0))
|
||||
|
||||
public instance1_1 = new Base(); // allowed
|
||||
>instance1_1 : Symbol(Subclass.instance1_1, Decl(subSubClassCanAccessProtectedConstructor.ts, 5, 29))
|
||||
>Base : Symbol(Base, Decl(subSubClassCanAccessProtectedConstructor.ts, 0, 0))
|
||||
|
||||
public instance1_2 = new Subclass(); // allowed
|
||||
>instance1_2 : Symbol(Subclass.instance1_2, Decl(subSubClassCanAccessProtectedConstructor.ts, 6, 36))
|
||||
>Subclass : Symbol(Subclass, Decl(subSubClassCanAccessProtectedConstructor.ts, 3, 1))
|
||||
}
|
||||
|
||||
class SubclassOfSubclass extends Subclass {
|
||||
>SubclassOfSubclass : Symbol(SubclassOfSubclass, Decl(subSubClassCanAccessProtectedConstructor.ts, 8, 1))
|
||||
>Subclass : Symbol(Subclass, Decl(subSubClassCanAccessProtectedConstructor.ts, 3, 1))
|
||||
|
||||
public instance2_1 = new Base(); // allowed
|
||||
>instance2_1 : Symbol(SubclassOfSubclass.instance2_1, Decl(subSubClassCanAccessProtectedConstructor.ts, 10, 43))
|
||||
>Base : Symbol(Base, Decl(subSubClassCanAccessProtectedConstructor.ts, 0, 0))
|
||||
|
||||
public instance2_2 = new Subclass(); // allowed
|
||||
>instance2_2 : Symbol(SubclassOfSubclass.instance2_2, Decl(subSubClassCanAccessProtectedConstructor.ts, 11, 36))
|
||||
>Subclass : Symbol(Subclass, Decl(subSubClassCanAccessProtectedConstructor.ts, 3, 1))
|
||||
|
||||
public instance2_3 = new SubclassOfSubclass(); // allowed
|
||||
>instance2_3 : Symbol(SubclassOfSubclass.instance2_3, Decl(subSubClassCanAccessProtectedConstructor.ts, 12, 40))
|
||||
>SubclassOfSubclass : Symbol(SubclassOfSubclass, Decl(subSubClassCanAccessProtectedConstructor.ts, 8, 1))
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
=== tests/cases/compiler/subSubClassCanAccessProtectedConstructor.ts ===
|
||||
class Base {
|
||||
>Base : Base
|
||||
|
||||
protected constructor() { }
|
||||
public instance1 = new Base(); // allowed
|
||||
>instance1 : Base
|
||||
>new Base() : Base
|
||||
>Base : typeof Base
|
||||
}
|
||||
|
||||
class Subclass extends Base {
|
||||
>Subclass : Subclass
|
||||
>Base : Base
|
||||
|
||||
public instance1_1 = new Base(); // allowed
|
||||
>instance1_1 : Base
|
||||
>new Base() : Base
|
||||
>Base : typeof Base
|
||||
|
||||
public instance1_2 = new Subclass(); // allowed
|
||||
>instance1_2 : Subclass
|
||||
>new Subclass() : Subclass
|
||||
>Subclass : typeof Subclass
|
||||
}
|
||||
|
||||
class SubclassOfSubclass extends Subclass {
|
||||
>SubclassOfSubclass : SubclassOfSubclass
|
||||
>Subclass : Subclass
|
||||
|
||||
public instance2_1 = new Base(); // allowed
|
||||
>instance2_1 : Base
|
||||
>new Base() : Base
|
||||
>Base : typeof Base
|
||||
|
||||
public instance2_2 = new Subclass(); // allowed
|
||||
>instance2_2 : Subclass
|
||||
>new Subclass() : Subclass
|
||||
>Subclass : typeof Subclass
|
||||
|
||||
public instance2_3 = new SubclassOfSubclass(); // allowed
|
||||
>instance2_3 : SubclassOfSubclass
|
||||
>new SubclassOfSubclass() : SubclassOfSubclass
|
||||
>SubclassOfSubclass : typeof SubclassOfSubclass
|
||||
}
|
||||
|
||||
@@ -2,10 +2,13 @@ tests/cases/compiler/superAccess2.ts(7,15): error TS1034: 'super' must be follow
|
||||
tests/cases/compiler/superAccess2.ts(8,17): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.
|
||||
tests/cases/compiler/superAccess2.ts(8,22): error TS1034: 'super' must be followed by an argument list or member access.
|
||||
tests/cases/compiler/superAccess2.ts(11,28): error TS2336: 'super' cannot be referenced in constructor arguments.
|
||||
tests/cases/compiler/superAccess2.ts(11,28): error TS17011: 'super' must be called before accessing a property of 'super' in the constructor of a derived class.
|
||||
tests/cases/compiler/superAccess2.ts(11,33): error TS1034: 'super' must be followed by an argument list or member access.
|
||||
tests/cases/compiler/superAccess2.ts(11,40): error TS2336: 'super' cannot be referenced in constructor arguments.
|
||||
tests/cases/compiler/superAccess2.ts(11,40): error TS17011: 'super' must be called before accessing a property of 'super' in the constructor of a derived class.
|
||||
tests/cases/compiler/superAccess2.ts(11,45): error TS1034: 'super' must be followed by an argument list or member access.
|
||||
tests/cases/compiler/superAccess2.ts(11,59): error TS2336: 'super' cannot be referenced in constructor arguments.
|
||||
tests/cases/compiler/superAccess2.ts(11,59): error TS17011: 'super' must be called before accessing a property of 'super' in the constructor of a derived class.
|
||||
tests/cases/compiler/superAccess2.ts(11,64): error TS1034: 'super' must be followed by an argument list or member access.
|
||||
tests/cases/compiler/superAccess2.ts(15,19): error TS1034: 'super' must be followed by an argument list or member access.
|
||||
tests/cases/compiler/superAccess2.ts(17,15): error TS2339: Property 'y' does not exist on type 'P'.
|
||||
@@ -13,7 +16,7 @@ tests/cases/compiler/superAccess2.ts(20,26): error TS1034: 'super' must be follo
|
||||
tests/cases/compiler/superAccess2.ts(21,15): error TS2339: Property 'x' does not exist on type 'typeof P'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/superAccess2.ts (13 errors) ====
|
||||
==== tests/cases/compiler/superAccess2.ts (16 errors) ====
|
||||
class P {
|
||||
x() { }
|
||||
static y() { }
|
||||
@@ -33,14 +36,20 @@ tests/cases/compiler/superAccess2.ts(21,15): error TS2339: Property 'x' does not
|
||||
constructor(public z = super, zz = super, zzz = () => super) {
|
||||
~~~~~
|
||||
!!! error TS2336: 'super' cannot be referenced in constructor arguments.
|
||||
~~~~~
|
||||
!!! error TS17011: 'super' must be called before accessing a property of 'super' in the constructor of a derived class.
|
||||
~
|
||||
!!! error TS1034: 'super' must be followed by an argument list or member access.
|
||||
~~~~~
|
||||
!!! error TS2336: 'super' cannot be referenced in constructor arguments.
|
||||
~~~~~
|
||||
!!! error TS17011: 'super' must be called before accessing a property of 'super' in the constructor of a derived class.
|
||||
~
|
||||
!!! error TS1034: 'super' must be followed by an argument list or member access.
|
||||
~~~~~
|
||||
!!! error TS2336: 'super' cannot be referenced in constructor arguments.
|
||||
~~~~~
|
||||
!!! error TS17011: 'super' must be called before accessing a property of 'super' in the constructor of a derived class.
|
||||
~
|
||||
!!! error TS1034: 'super' must be followed by an argument list or member access.
|
||||
super();
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
tests/cases/compiler/superInConstructorParam1.ts(8,3): error TS2377: Constructors for derived classes must contain a 'super' call.
|
||||
tests/cases/compiler/superInConstructorParam1.ts(8,19): error TS2336: 'super' cannot be referenced in constructor arguments.
|
||||
tests/cases/compiler/superInConstructorParam1.ts(8,19): error TS17011: 'super' must be called before accessing a property of 'super' in the constructor of a derived class.
|
||||
|
||||
|
||||
==== tests/cases/compiler/superInConstructorParam1.ts (2 errors) ====
|
||||
==== tests/cases/compiler/superInConstructorParam1.ts (3 errors) ====
|
||||
class B {
|
||||
public foo(): number {
|
||||
return 0;
|
||||
@@ -14,6 +15,8 @@ tests/cases/compiler/superInConstructorParam1.ts(8,19): error TS2336: 'super' ca
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
~~~~~
|
||||
!!! error TS2336: 'super' cannot be referenced in constructor arguments.
|
||||
~~~~~
|
||||
!!! error TS17011: 'super' must be called before accessing a property of 'super' in the constructor of a derived class.
|
||||
}
|
||||
~~~
|
||||
!!! error TS2377: Constructors for derived classes must contain a 'super' call.
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
tests/cases/compiler/superNewCall1.ts(9,5): error TS2377: Constructors for derived classes must contain a 'super' call.
|
||||
tests/cases/compiler/superNewCall1.ts(10,9): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
|
||||
tests/cases/compiler/superNewCall1.ts(10,13): error TS17011: 'super' must be called before accessing a property of 'super' in the constructor of a derived class.
|
||||
|
||||
|
||||
==== tests/cases/compiler/superNewCall1.ts (2 errors) ====
|
||||
==== tests/cases/compiler/superNewCall1.ts (3 errors) ====
|
||||
|
||||
class A<T1, T2> {
|
||||
constructor(private map: (value: T1) => T2) {
|
||||
@@ -17,6 +18,8 @@ tests/cases/compiler/superNewCall1.ts(10,9): error TS2351: Cannot use 'new' with
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
|
||||
~~~~~
|
||||
!!! error TS17011: 'super' must be called before accessing a property of 'super' in the constructor of a derived class.
|
||||
}
|
||||
~~~~~
|
||||
!!! error TS2377: Constructors for derived classes must contain a 'super' call.
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user