Skip to content

Commit 758e1ff

Browse files
author
Arthur Ozga
committed
temp
1 parent 8020e24 commit 758e1ff

File tree

3 files changed

+4
-11
lines changed

3 files changed

+4
-11
lines changed

src/compiler/checker.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2293,25 +2293,18 @@ namespace ts {
22932293
}
22942294
if (objectFlags & ObjectFlags.ClassOrInterface) {
22952295
Debug.assert(!!(type.flags & TypeFlags.Object));
2296+
// TODO: Detect whether class is named and fail if not.
22962297
const name = getNameOfSymbol(type.symbol);
22972298
// TODO: handle type arguments.
2298-
// TODO: handle anonymous classes.
22992299
return createTypeReferenceNode(name, /*typeParameters*/undefined);
23002300
}
23012301
if (type.flags & TypeFlags.TypeParameter) {
2302-
const constraint = createTypeNode(getConstraintFromTypeParameter(<TypeParameter>type)) as TypeNode;
2303-
const defaultParameter = createTypeNode(getDefaultFromTypeParameter(<TypeParameter>type)) as TypeNode;
2304-
if(constraint || defaultParameter) {
2305-
// Type parameters in type position can't have constraints or defaults.
2306-
encounteredError = true;
2307-
return undefined;
2308-
}
23092302
// TODO: get qualified name when necessary instead of string.
23102303
const name = symbolToString(type.symbol);
2304+
// Ignore constraint/default when creating a usage (as opposed to declaration) of a type parameter.
23112305
return createTypeReferenceNode(name, /*typeArguments*/ undefined);
23122306
}
23132307

2314-
// accessible type aliasSymbol
23152308
// TODO: move back up later on?
23162309
if (checkAlias && type.aliasSymbol) {
23172310
const name = getNameOfSymbol(type.aliasSymbol);

src/services/codefixes/helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ namespace ts.codefix {
225225

226226
function createParameterDeclarationFromSymbol(parameterSymbol: Symbol, enclosingDeclaration: ClassLikeDeclaration, checker: TypeChecker) {
227227
const parameterDeclaration = parameterSymbol.getDeclarations()[0] as ParameterDeclaration;
228-
const parameterType = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(parameterSymbol, enclosingDeclaration));
228+
const parameterType = checker.getTypeOfSymbolAtLocation(parameterSymbol, enclosingDeclaration);
229229
const parameterTypeNode = checker.createTypeNode(parameterType);
230230
// TODO: deep cloning of decorators/any node.
231231
const parameterNode = createParameter(

tests/cases/fourslash/codeFixUndeclaredIndexSignatureNumericLiteral.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
verify.rangeAfterCodeFix(`
1010
class A {
11-
[name: string]: number;
11+
[x: string]: number;
1212
1313
constructor() {
1414
this.x = 10;

0 commit comments

Comments
 (0)