Skip to content

Quick fix for no-implicit-any errors to add explicit type annotation #14786

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 45 commits into from
Oct 12, 2017
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
a4ce5e6
Infer from usage quick fix
mhegazy Feb 26, 2017
d79fbc0
Change full function singature
mhegazy Feb 28, 2017
69a4b8c
Add property/element access support
mhegazy Feb 28, 2017
33467cf
Fix a few issues
mhegazy Mar 2, 2017
ab39813
Merge branch 'master' into inferFromUsage
mhegazy Mar 16, 2017
d87eae9
Some cleanup
mhegazy Mar 16, 2017
a18a950
Expose getArrayType and getPromiseType
mhegazy Mar 16, 2017
bea4591
Switch to collecting all usage before infering
mhegazy Mar 16, 2017
55ffe2d
Infer array and promise type arguments
mhegazy Mar 16, 2017
b82dc8d
Handel enums in binary operators
mhegazy Mar 16, 2017
7a52545
consolidate usage of addCandidateTypes
mhegazy Mar 16, 2017
8088415
Handel rest paramters
mhegazy Mar 18, 2017
0413165
Properly handel `+=` and `+` inference for numbers and strings
mhegazy Mar 18, 2017
ea483a7
Add print quickfixes debug helper
mhegazy Mar 18, 2017
ea344b2
Add rest param tests
mhegazy Mar 18, 2017
a1efc1a
Add optional paramter tests
mhegazy Mar 18, 2017
ff15dc6
Handel set accessors
mhegazy Mar 18, 2017
e2e43d1
Support getters
mhegazy Mar 20, 2017
2929af4
Support no implicit any error for variable at use site
mhegazy Mar 21, 2017
b395057
Support properties
mhegazy Mar 21, 2017
15eb7de
Only offer quick fix if an infered type other than any is available
mhegazy Mar 21, 2017
2a9032b
Rename functions
mhegazy Mar 21, 2017
057016b
Move to a separate namespace
mhegazy Mar 21, 2017
32aa07d
Check cancellation token
mhegazy Mar 21, 2017
5da31bb
Cleanup
mhegazy Mar 21, 2017
dc431e4
Check for accesibile symbols where serializing types
mhegazy Mar 22, 2017
561cfe6
Remove JS support
mhegazy Mar 22, 2017
002e8ad
Reorganize functions
mhegazy Mar 22, 2017
3822d8d
Mark APIs as internal
mhegazy Mar 22, 2017
41ed553
Fix lint errors
mhegazy Mar 22, 2017
c3071a8
Merge remote-tracking branch 'origin/master' into inferFromUsage
mhegazy Mar 22, 2017
a12dc45
Merge branch 'master' into inferFromUsage
mhegazy May 8, 2017
791bb4a
Merge branch 'master' into inferFromUsage
DanielRosenwasser Aug 1, 2017
0047ae3
Removed conflict markers.
DanielRosenwasser Aug 1, 2017
5a15e93
Update 'createSymbol' to use '__String'.
DanielRosenwasser Sep 19, 2017
9daaffa
Fixed most problems relating to '__String' and 'includeJsDocComments'…
DanielRosenwasser Sep 19, 2017
b5e94a7
Addressed most API changes.
DanielRosenwasser Sep 19, 2017
3b49776
Merge remote-tracking branch 'origin/master' into inferFromUsage
DanielRosenwasser Sep 19, 2017
3f488ce
Merge branch 'master' into inferFromUsage
mhegazy Oct 5, 2017
6bdaf8a
Make all helpers internal
mhegazy Oct 6, 2017
25f8aa6
Use a diffrent writer and not the built-in single line write
mhegazy Oct 6, 2017
761bd7b
Infer types for all parameters in a parameter list instead of one at …
mhegazy Oct 7, 2017
ffa8272
Accept baselines
mhegazy Oct 7, 2017
5abd72d
Code review commments
mhegazy Oct 7, 2017
1e39d48
Respond to code review comments
mhegazy Oct 12, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,23 @@ namespace ts {
return tryFindAmbientModule(moduleName, /*withAugmentations*/ false);
},
getApparentType,
getUnionType,
createAnonymousType,
createSignature,
createSymbol,
createIndexInfo,
getAnyType: () => anyType,
getStringType: () => stringType,
getNumberType: () => numberType,
createPromiseType,
createArrayType,
getBooleanType: () => booleanType,
getVoidType: () => voidType,
getUndefinedType: () => undefinedType,
getNullType: () => nullType,
getESSymbolType: () => esSymbolType,
getNeverType: () => neverType,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a concern, we have multiple never types internally. I feel somewhat uneasy about exposing it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

made them all them internal for now.

isSymbolAccessible,
getAllPossiblePropertiesOfType,
getSuggestionForNonexistentProperty: (node, type) => unescapeLeadingUnderscores(getSuggestionForNonexistentProperty(node, type)),
getSuggestionForNonexistentSymbol: (location, name, meaning) => unescapeLeadingUnderscores(getSuggestionForNonexistentSymbol(location, escapeLeadingUnderscores(name), meaning)),
Expand Down Expand Up @@ -3638,6 +3655,7 @@ namespace ts {

function buildParameterDisplay(p: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, symbolStack?: Symbol[]) {
const parameterNode = <ParameterDeclaration>p.valueDeclaration;

if (parameterNode ? isRestParameter(parameterNode) : isTransientSymbol(p) && p.isRestParameter) {
writePunctuation(writer, SyntaxKind.DotDotDotToken);
}
Expand Down
5 changes: 5 additions & 0 deletions src/compiler/diagnosticMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -3629,6 +3629,7 @@
"category": "Message",
"code": 90017
},

"Disable checking for this file.": {
"category": "Message",
"code": 90018
Expand Down Expand Up @@ -3665,6 +3666,10 @@
"category": "Message",
"code": 90026
},
"Infer type of '{0}'.": {
"category": "Message",
"code": 90027
},

"Convert function to an ES2015 class": {
"category": "Message",
Expand Down
18 changes: 18 additions & 0 deletions src/compiler/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2588,6 +2588,24 @@ namespace ts {
getSuggestionForNonexistentSymbol(location: Node, name: string, meaning: SymbolFlags): string | undefined;
/* @internal */ getBaseConstraintOfType(type: Type): Type | undefined;

getAnyType(): Type;
getStringType(): Type;
getNumberType(): Type;
getBooleanType(): Type;
getVoidType(): Type;
getUndefinedType(): Type;
getNullType(): Type;
getESSymbolType(): Type;
getNeverType(): Type;
getUnionType(types: Type[], subtypeReduction?: boolean): Type;
createArrayType(elementType: Type): Type;
createPromiseType(type: Type): Type;

/* @internal */ createAnonymousType(symbol: Symbol, members: SymbolTable, callSignatures: Signature[], constructSignatures: Signature[], stringIndexInfo: IndexInfo, numberIndexInfo: IndexInfo): Type;
/* @internal */ createSignature(declaration: SignatureDeclaration, typeParameters: TypeParameter[], thisParameter: Symbol | undefined, parameters: Symbol[], resolvedReturnType: Type, typePredicate: TypePredicate, minArgumentCount: number, hasRestParameter: boolean, hasLiteralTypes: boolean): Signature;
/* @internal */ createSymbol(flags: SymbolFlags, name: string): TransientSymbol;
/* @internal */ createIndexInfo(type: Type, isReadonly: boolean, declaration?: SignatureDeclaration): IndexInfo;
/* @internal */ isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags, shouldComputeAliasToMarkVisible: boolean): SymbolAccessibilityResult;
/* @internal */ tryFindAmbientModuleWithoutAugmentations(moduleName: string): Symbol | undefined;

// Should not be called directly. Should only be accessed through the Program instance.
Expand Down
8 changes: 8 additions & 0 deletions src/compiler/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5425,4 +5425,12 @@ namespace ts {
export function isJSDocTag(node: Node): boolean {
return node.kind >= SyntaxKind.FirstJSDocTagNode && node.kind <= SyntaxKind.LastJSDocTagNode;
}

export function isSetAccessor(node: Node): node is SetAccessorDeclaration {
return node.kind === SyntaxKind.SetAccessor;
}

export function isGetAccessor(node: Node): node is GetAccessorDeclaration {
return node.kind === SyntaxKind.GetAccessor;
}
}
1 change: 1 addition & 0 deletions src/services/codefixes/fixes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@
/// <reference path='importFixes.ts' />
/// <reference path='disableJsDiagnostics.ts' />
/// <reference path='helpers.ts' />
/// <reference path='inferFromUsage.ts' />
Loading